hsd icon indicating copy to clipboard operation
hsd copied to clipboard

txdb: REVEALs could be stored with pointer to the corresponding BID

Open pinheadmz opened this issue 2 years ago • 2 comments

When the wallet encounters a REVEAL for a name it is watching, it saves it as a specific object in a specific bucket in the txdb:

BidReveal

This object is indexed by its outpoint, and contains these data:

https://github.com/handshake-org/hsd/blob/35ea46d81f6f72e48f145fc6cf02ff66274d19f5/lib/wallet/txdb.js#L3984-L3988

Saving a BidReveal for a non-wallet REVEAL:

https://github.com/handshake-org/hsd/blob/35ea46d81f6f72e48f145fc6cf02ff66274d19f5/lib/wallet/txdb.js#L2005-L2014

NOT storing the entire transaction for a non-wallet REVEAL:

https://github.com/handshake-org/hsd/blob/35ea46d81f6f72e48f145fc6cf02ff66274d19f5/lib/wallet/txdb.js#L1044-L1047

These objects in JSON contain a poorly-named field prevout which is the REVEAL's actual outpoint. However, this object does not contain the actual prevout being spent in the linked input, i.e. the corresponding BID. This would be trivial to add to the BidReveal object, serialize and store in the txdb and it would give hsd users enough data to connect BIDs and REVEALs.

Bob Wallet does this in the UI but relies on --tx-index to retrieve the parent transaction for every BID and REVEAL, look up the outpoint and get the address. Then it attempts to link BIDs and REVEALs by matching addresses. This, of course, is not a garuntee because there could be multiple BID/REVEAL pairs using the same address! The best method is to link by actual prevout in the REVEAL.

pinheadmz avatar Apr 22 '22 13:04 pinheadmz

Also, REVEALs have a height property but BIDs don't ... why ?!

pinheadmz avatar Apr 22 '22 13:04 pinheadmz

It is possible to use the wallet tx index to link our own bids and reveals, but not other users. In Palm Reader, the table looks a bit confusing for now:

Screen Shot 2022-04-22 at 10 27 54 AM

pinheadmz avatar Apr 22 '22 14:04 pinheadmz