BIP370: add Input Finalizer section; BIP371: remove finalizer clause from an output field - #2277
Open
fametrano wants to merge 2 commits into
Open
BIP370: add Input Finalizer section; BIP371: remove finalizer clause from an output field#2277fametrano wants to merge 2 commits into
fametrano wants to merge 2 commits into
Conversation
BIP 174 tells the Input Finalizer to clear all other data except the UTXO and unknown fields from a finalized input. It was written when the unsigned transaction was a global field. PSBTv2 moves the data that defines the input into the input map, and a finalizer that follows the sentence literally removes it: without PSBT_IN_PREVIOUS_TXID or PSBT_IN_OUTPUT_INDEX the result is invalid, and without PSBT_IN_SEQUENCE and the locktime fields the Transaction Extractor builds a different transaction. BIP 370 amends Creator, Updater, Signer and Transaction Extractor for PSBTv2, adds the Constructor, and says nothing about the Input Finalizer. Add the section: the five fields are kept. Bitcoin Core does this today: at 19b0ff2fa0, PSBTInput::Serialize in src/psbt.h writes them for every PSBTv2 input, finalized or not.
The six taproot input fields say "Finalizers should remove this field after PSBT_IN_FINAL_SCRIPTWITNESS is constructed", and so does the output field PSBT_OUT_TAP_BIP32_DERIVATION. An output has no PSBT_IN_FINAL_SCRIPTWITNESS, the clause names no input, and its two neighbours in the output table carry no such clause. Drop it; Bitcoin Core does not clear output fields on finalization.
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.
Two independent commits.
BIP370: add an Input Finalizer section
In a version 2 PSBT, the fields that define an input live in the input map:
PSBT_IN_PREVIOUS_TXID,PSBT_IN_OUTPUT_INDEX,PSBT_IN_SEQUENCE, and the two required-locktime fields.BIP174 tells the Input Finalizer to clear every field of a finalized input except the UTXO and unknown fields. Followed literally on a version 2 input, this deletes the fields above. Without
PSBT_IN_PREVIOUS_TXIDorPSBT_IN_OUTPUT_INDEXthe PSBT is invalid; without the sequence and locktime fields the Transaction Extractor builds a different transaction.BIP370 defines every other role for version 2 but has no Input Finalizer section. This adds one, stating that the finalizer keeps those five fields. Bitcoin Core already does this: its input serializer writes them whether or not the input is finalized.
BIP371: remove a finalizer clause from an output field
PSBT_OUT_TAP_BIP32_DERIVATIONcarries the note "Finalizers should remove this field afterPSBT_IN_FINAL_SCRIPTWITNESSis constructed".This is an output field. An output has no
PSBT_IN_FINAL_SCRIPTWITNESS, and the clause names no input to act on. The two neighbouring output fields carry no such note. This removes it.Both are minor amendments to Deployed BIPs.