Categorygithub.com/btcsuite/btcutil/psbt
modulepackage
1.0.2
Repository: https://github.com/btcsuite/btcutil.git
Documentation: pkg.go.dev

# Functions

Extract takes a finalized psbt.Packet and outputs a finalized transaction instance.
Finalize assumes that the provided psbt.Packet struct has all partial signatures and redeem scripts/witness scripts already prepared for the specified input, and so removes all temporary data and replaces them with completed sigScript and witness fields, which are stored in key-types 07 and 08.
MaybeFinalize attempts to finalize the input at index inIndex in the PSBT p, returning true with no error if it succeeds, OR if the input has already been finalized.
MaybeFinalizeAll attempts to finalize all inputs of the psbt.Packet that are not already finalized, and returns an error if it fails to do so.
New on provision of an input and output 'skeleton' for the transaction, a new partially populated PBST packet.
NewFromRawBytes returns a new instance of a Packet struct created by reading from a byte slice.
NewFromUnsignedTx creates a new Psbt struct, without any signatures (i.e.
NewPsbtInput creates an instance of PsbtInput given either a nonWitnessUtxo or a witnessUtxo.
NewPsbtOutput creates an instance of PsbtOutput; the three parameters redeemScript, witnessScript and Bip32Derivation are all allowed to be `nil`.
NewUpdater returns a new instance of Updater, if the passed Psbt struct is in a valid form, else an error.
SerializeBIP32Derivation takes a master key fingerprint as defined in BIP32, along with a path specified as a list of uint32 values, and returns a bytestring specifying the derivation in the format required by BIP174: // master key fingerprint (4) || child index (4) || child index (4) || ....

# Constants

Bip32DerivationInputType is a type that carries the pubkey along with the key ({0x06}|{public key}).
needed to spend this output.
FinalScriptSigType is an empty key ({0x07}).
FinalScriptWitnessType is an empty key ({0x08}).
MaxPsbtKeyLength is the length of the largest key that we'll successfully deserialize from the wire.
MaxPsbtValueLength is the size of the largest transaction serialization that could be passed in a NonWitnessUtxo field.
MinTxVersion is the lowest transaction version that we'll permit.
NonWitnessUtxoType has no key ({0x00}) and houses the transaction in network serialization format the current input spends from.
PartialSigType is used to include a partial signature with key ({0x02}|{public key}).
ProprietaryGlobalType is used to house any proper chary global-scope keys within the PSBT.
ProprietaryInputType is a custom type for use by devs.
RedeemScriptInputType is an empty key ({0x40}).
RedeemScriptOutputType is an empty key ({0x00}> The value is the redeemScript for this output if it has one.
SighashType is an empty key ({0x03}).
SignFinalized indicates that this input is already finalized, so the provided signature was *not* attached.
SignInvalid indicates that the provided signature data was not valid.
SignSuccesful indicates that the partial signature was successfully attached.
UnsignedTxType is the global scope key that houses the unsigned transaction of the PSBT.
VersionType houses the global version number of this PSBT.
WitnessScriptInputType is an empty key ({0x05}).
WitnessScriptOutputType is an empty key ({0x01}).
WitnessUtxoType has no key ({0x01}), and houses the entire transaction output in network serialization which the current input spends from.
XpubType houses a global xpub for the entire PSBT packet.

# Variables

ErrDuplicateKey indicates that a passed Psbt serialization is invalid due to having the same key repeated in the same key-value pair.
ErrIncompletePSBT indicates that the Extractor object was unable to successfully extract the passed Psbt struct because it is not complete.
ErrInputAlreadyFinalized indicates that the PSBT passed to a Finalizer already contains the finalized scriptSig or witness.
ErrInvalidKeydata indicates that a key-value pair in the PSBT serialization contains data in the key which is not valid.
ErrInvalidMagicBytes indicates that a passed Psbt serialization is invalid due to having incorrect magic bytes.
ErrInvalidPrevOutNonWitnessTransaction indicates that the transaction hash (i.e.
ErrInvalidPsbtFormat is a generic error for any situation in which a provided Psbt serialization does not conform to the rules of BIP174.
ErrInvalidRawTxSigned indicates that the raw serialized transaction in the global section of the passed Psbt serialization is invalid because it contains scriptSigs/witnesses (i.e.
ErrInvalidSigHashFlags indicates that a signature added to the PSBT uses Sighash flags that are not in accordance with the requirement according to the entry in PsbtInSighashType, or otherwise not the default value (SIGHASH_ALL).
ErrInvalidSignatureForInput indicates that the signature the user is trying to append to the PSBT is invalid, either because it does not correspond to the previous transaction hash, or redeem script, or witness script.
ErrNotFinalizable indicates that the PSBT struct does not have sufficient data (e.g.
ErrUnsupportedScriptType indicates that the redeem script or scriptwitness given is not supported by this codebase, or is otherwise not valid.

# Structs

Bip32Derivation encapsulates the data for the input and output Bip32Derivation key-value fields.
Packet is the actual psbt repreesntation.
PartialSig encapsulate a (BTC public key, ECDSA signature) pair, note that the fields are stored as byte slices, not btcec.PublicKey or btcec.Signature (because manipulations will be with the former not the latter, here); compliance with consensus serialization is enforced with .checkValid().
PInput is a struct encapsulating all the data that can be attached to any specific input of the PSBT.
POutput is a struct encapsulating all the data that can be attached to any specific output of the PSBT.
Unknown is a struct encapsulating a key-value pair for which the key type is unknown by this package; these fields are allowed in both the 'Global' and the 'Input' section of a PSBT.
Updater encapsulates the role 'Updater' as specified in BIP174; it accepts Psbt structs and has methods to add fields to the inputs and outputs.

# Type aliases

Bip32Sorter implements sort.Interface for the Bip32Derivation struct.
GlobalType is the set of types that are used at the global scope level within the PSBT.
InputType is the set of types that are defined for each input included within the PSBT.
OutputType is the set of types defined per output within the PSBT.
PartialSigSorter implements sort.Interface for PartialSig.
SignOutcome is a enum-like value that expresses the outcome of a call to the Sign method.