Create txdb credit for known key paths when confirming #262
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a port of bcoin-org/bcoin#829
Refer to original post for summary and discussion.
Note the hsd wallet has one extra detail in the
txdb.confirm()
function, it adds coins from the tx input to aview
, which gets passed toconnectNames()
-- clearly not necessary in bcoin.Since this PR only affects the handling of tx outputs, we should be ok. But reviewers more familiar with hsd might wanna double check me on that.
The reason we don't need to do anything for the inputs was discussed offline:
When txdb confirms a tx, it assumes that all input coins are confirmed. In fact, this is consensus for obvious reasons. If it sees an input it doesn't own, it ignores it. Even if the tx gets unconfirmed and re-confirmed, txdb will not recognize that credit or create a new credit. That makes sense because if we want to get that output/credit/coin into the txdb - we must go back and txdb.confirm() the original tx that created it, and I believe that is the case the PR already addresses. We wouldn't really be able to create a new coin at this point anyway, since all we know if the outpoint (hash/index), not the script or sender address or value...