Allow transaction lookup by bare txid#76
Closed
domob1812 wants to merge 3 commits intoDiviProject:DevelopmentOutdatedfrom
Closed
Allow transaction lookup by bare txid#76domob1812 wants to merge 3 commits intoDiviProject:DevelopmentOutdatedfrom
domob1812 wants to merge 3 commits intoDiviProject:DevelopmentOutdatedfrom
Conversation
This extends the two functions GetWalletTx and GetTransaction to (also) find transactions by bare txid, not just by the normal txid. These methods are mainly used in places where we need to look up e.g. the previous transaction to a spend, so that we can know the address that is being spent or the value of the input. The change is fine to do (won't cause any extra consensus changes) because all it does is make those methods return the correct previous transaction (for after the fork) in cases where they would have failed otherwise (since both are SHA-256d hashes and thus cannot have collisions). Also actual checks that some spent coin actually exists are the explicitly on the consensus-level anyway.
When the transaction index is enabled (-txindex), this change also keeps an index from bare txid to the disk position, so that lookups with the index work on both normal txids and bare txids. With this, the previous change made to GetTransaction will be improved for enabled -txindex, and it will also allow us to look up any transaction by bare txid, even if the fallbacks in GetTransaction fail.
This extends the txindex.py test, to check lookups also by bare txid where this is possible (mempool and txindex). Lookups by UTXO set only work on whatever hash is used for the UTXO before/after segwit light.
Author
|
Reopened in #79 with the correct branches. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 extends
GetTransaction(lookup of a transaction from disk) andGetWalletTx(lookup of a transaction in the wallet) to find transactions both by txid and bare txid. For this, we also extend the on-disk index created when-txindexis enabled.This will be needed after segwit light, to look up previous transactions given a
CTxInprevoutpointer. Note that this change by itself does not affect consensus. It only makes those lookups succeed in some cases that failed before, and all places that do lookups withGetTransactionin the consensus logic do that just as part of more checks (e.g. to access a previous transaction's output script) where other checks will fail accordingly before the fork.