Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
pinheadmz opened this issue Apr 22, 2022 · 2 comments · Fixed by #896
Closed

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

pinheadmz opened this issue Apr 22, 2022 · 2 comments · Fixed by #896
Milestone

Comments

@pinheadmz
Copy link
Member

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:

hsd/lib/wallet/txdb.js

Lines 3984 to 3988 in 35ea46d

bw.writeU8(this.name.length);
bw.writeBytes(this.name);
bw.writeU64(this.value);
bw.writeU32(height);
bw.writeU8(this.own ? 1 : 0);

Saving a BidReveal for a non-wallet REVEAL:

hsd/lib/wallet/txdb.js

Lines 2005 to 2014 in 35ea46d

if (!path) {
this.putReveal(b, nameHash, outpoint, {
name: ns.name,
value: output.value,
height: height,
own: false
});
updated = true;
break;
}

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

hsd/lib/wallet/txdb.js

Lines 1044 to 1047 in 35ea46d

// If this didn't update any coins,
// it's not our transaction.
if (!state.updated())
return null;

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
Copy link
Member Author

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

@pinheadmz
Copy link
Member Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants