Documentation ¶
Index ¶
- Constants
- Variables
- func Extract(p *Pset) (*transaction.Transaction, error)
- func Finalize(p *Pset, inIndex int) error
- func FinalizeAll(p *Pset) error
- func MaybeFinalize(p *Pset, inIndex int) (bool, error)
- func MaybeFinalizeAll(p *Pset) error
- func SerializeBIP32Derivation(masterKeyFingerprint uint32, bip32Path []uint32) []byte
- type AddInIssuanceArgs
- type AddInReissuanceArgs
- type Bip32Sorter
- type BitSet
- type Blinder
- type BlindingGenerator
- type BlindingValidator
- type DerivationPath
- type DerivationPathWithPubKey
- type Global
- type Input
- type InputArgs
- type InputIssuanceBlindingArgs
- type Key
- type KeyPair
- type Output
- type OutputArgs
- type OutputBlindingArgs
- type OwnedInput
- type PartialSig
- type PartialSigSorter
- type ProprietaryData
- type Pset
- func (p *Pset) Copy() *Pset
- func (p *Pset) HasSighashSingle() bool
- func (p *Pset) InputsModifiable() bool
- func (p *Pset) IsComplete() bool
- func (p *Pset) IsFullyBlinded() bool
- func (p *Pset) Locktime() uint32
- func (p *Pset) NeedsBlinding() bool
- func (p *Pset) OutputsModifiable() bool
- func (p *Pset) SanityCheck() error
- func (p *Pset) ToBase64() (string, error)
- func (p *Pset) UnsignedTx() (*transaction.Transaction, error)
- func (p *Pset) ValidateAllSignatures() (bool, error)
- func (p *Pset) ValidateInputSignatures(inputIndex int) (bool, error)
- type Signer
- type Updater
- func (u *Updater) AddInBip32Derivation(inIndex int, bip32Derivation DerivationPathWithPubKey) error
- func (u *Updater) AddInExplicitAsset(inIndex int, asset, proof []byte) error
- func (u *Updater) AddInExplicitValue(inIndex int, value uint64, proof []byte) error
- func (u *Updater) AddInIssuance(inputIndex int, arg AddInIssuanceArgs) error
- func (u *Updater) AddInNonWitnessUtxo(inIndex int, tx *transaction.Transaction) error
- func (u *Updater) AddInRedeemScript(inIndex int, redeemScript []byte) error
- func (u *Updater) AddInReissuance(inputIndex int, arg AddInReissuanceArgs) error
- func (u *Updater) AddInSighashType(inIndex int, sighashType txscript.SigHashType) error
- func (u *Updater) AddInUtxoRangeProof(inIndex int, proof []byte) error
- func (u *Updater) AddInWitnessScript(inIndex int, witnessScript []byte) error
- func (u *Updater) AddInWitnessUtxo(inIndex int, txout *transaction.TxOutput) error
- func (u *Updater) AddInputs(inputs []InputArgs) error
- func (u *Updater) AddOutBip32Derivation(outIndex int, bip32Derivation DerivationPathWithPubKey) error
- func (u *Updater) AddOutRedeemScript(outIndex int, redeemScript []byte) error
- func (u *Updater) AddOutWitnessScript(outIndex int, witnessScript []byte) error
- func (u *Updater) AddOutputs(outputs []OutputArgs) error
- type Xpub
Constants ¶
const ( //Per output types: BIP 174, 370, 371 GlobalXpub = 0x01 //BIP 174 GlobalTxVersion = 0x02 //BIP 370 GlobalFallbackLocktime = 0x03 //BIP 370 GlobalInputCount = 0x04 //BIP 370 GlobalOutputCount = 0x05 //BIP 370 GlobalTxModifiable = 0x06 //BIP 370 GlobalVersion = 0xFB //BIP 174 //Elements Proprietary types GlobalScalar = 0x00 GlobalModifiable = 0x01 )
const ( //Per input types: BIP 127, 174, 370, 371 InputNonWitnessUtxo = 0x00 //BIP 174 InputWitnessUtxo = 0x01 //BIP 174 InputPartialSig = 0x02 //BIP 174 InputSighashType = 0x03 //BIP 174 InputRedeemScript = 0x04 //BIP 174 InputWitnessScript = 0x05 //BIP 174 InputBip32Derivation = 0x06 //BIP 174 InputFinalScriptsig = 0x07 //BIP 174 InputFinalScriptwitness = 0x08 //BIP 174 InputPorCommitment = 0x09 //BIP 127 InputRipemd160 = 0x0a //BIP 174 InputSha256 = 0x0b //BIP 174 InputHash160 = 0x0c //BIP 174 InputHash256 = 0x0d //BIP 174 InputPreviousTxid = 0x0e //BIP 370 InputPreviousTxIndex = 0x0f //BIP 370 InputSequence = 0x10 //BIP 370 InputRequiredTimeLocktime = 0x11 //BIP 370 InputRequiredHeightLocktime = 0x12 //BIP 370 InputTapKeySig = 0x13 //BIP 371 InputTapScriptSig = 0x14 //BIP 371 InputTapLeafScript = 0x15 //BIP 371 InputTapBip32Derivation = 0x16 //BIP 371 InputTapInternalKey = 0x17 //BIP 371 InputTapMerkleRoot = 0x18 //BIP 371 //Elements Proprietary types InputIssuanceValue = 0x00 InputIssuanceValueCommitment = 0x01 InputIssuanceValueRangeproof = 0x02 InputIssuanceInflationKeysRangeproof = 0x03 InputPeginTx = 0x04 InputPeginTxoutProof = 0x05 InputPeginGenesis = 0x06 InputPeginClaimScript = 0x07 InputPeginValue = 0x08 InputPeginWitness = 0x09 InputIssuanceInflationKeys = 0x0a InputIssuanceInflationKeysCommitment = 0x0b InputIssuanceBlindingNonce = 0x0c InputIssuanceAssetEntropy = 0x0d InputUtxoRangeProof = 0x0e InputIssuanceBlindValueProof = 0x0f InputIssuanceBlindInflationKeysProof = 0x10 InputExplicitValue = 0x11 InputValueProof = 0x12 InputExplicitAsset = 0x13 InputAssetProof = 0x14 InputBlindedIssuanceValue = 0x15 )
const ( //Per output types: BIP 174, 370, 371 OutputRedeemScript = 0x00 //BIP 174 OutputWitnessScript = 0x01 //BIP 174 OutputBip32Derivation = 0x02 //BIP 174 OutputAmount = 0x03 //BIP 370 OutputScript = 0x04 //BIP 370 OutputTapInternalKey = 0x05 //BIP 371 OutputTapTree = 0x06 //BIP 371 OutputTapLeafScript = 0x06 //BIP 371 //TODO is duplicate key type allowed? OutputTapBip32Derivation = 0x07 //BIP 371 //Elements Proprietary types OutputValueCommitment = 0x01 OutputAsset = 0x02 OutputAssetCommitment = 0x03 OutputValueRangeproof = 0x04 OutputAssetSurjectionProof = 0x05 OutputBlindingPubkey = 0x06 OutputEcdhPubkey = 0x07 OutputBlinderIndex = 0x08 OutputBlindValueProof = 0x09 OutputBlindAssetProof = 0x0a )
const ( NonConfidentialReissuanceTokenFlag = uint(0) ConfidentialReissuanceTokenFlag = uint(1) )
const (
PsetProprietary = 0xfc
)
Variables ¶
var ( // Output errors ErrOutMissingBlindingKey = fmt.Errorf( "cannot blind an output that misses blinding pubkey", ) ErrOutMissingNonce = fmt.Errorf("missing output ecdh pubkey") ErrOutMissingNonceCommitment = fmt.Errorf("missing output nonce commitment") ErrOutMissingAssetBlinder = fmt.Errorf("missing output asset blinder") ErrOutMissingAssetCommitment = fmt.Errorf("missing output asset commitment") ErrOutMissingAssetSurjectionProof = fmt.Errorf("missing output asset surjetcion proof") ErrOutMissingAssetBlindProof = fmt.Errorf("missing output asset commitment or blind proof") ErrOutMissingValueBlinder = fmt.Errorf("missing output value blinder") ErrOutMissingValueCommitment = fmt.Errorf("missing output value commitment") ErrOutMissingValueRangeProof = fmt.Errorf("missing output value range proof") ErrOutMissingValueBlindProof = fmt.Errorf("missing output value commitment or blind proof") ErrOutInvalidNonce = fmt.Errorf("invalid output ecdh pubkey length") ErrOutInvalidNonceCommitment = fmt.Errorf("invalid output nonce commitment length") ErrOutInvalidValueBlinder = fmt.Errorf("invalid output value blinder length") ErrOutInvalidAssetBlinder = fmt.Errorf("invalid output asset blinder length") ErrOutInvalidAssetCommitment = fmt.Errorf("invalid output asset commitment length") ErrOutInvalidValueCommitment = fmt.Errorf("invalid output value commitment length") // Input issuance errors ErrInIssuanceMissingValueBlinder = fmt.Errorf("missing issuance value blinder") ErrInIssuanceMissingValueCommitment = fmt.Errorf("missing issuance value commitment") ErrInIssuanceMissingValueRangeProof = fmt.Errorf("missing issuance value range proof") ErrInIssuanceMissingValueBlindProof = fmt.Errorf("missing issuance value blind proof") ErrInIssuanceMissingTokenBlinder = fmt.Errorf("missing issuance token value blinder") ErrInIssuanceMissingTokenCommitment = fmt.Errorf("missing issuance token value commitment") ErrInIssuanceMissingTokenRangeProof = fmt.Errorf("missing issuance token value range proof") ErrInIssuanceMissingTokenBlindProof = fmt.Errorf("missing issuance token value blind proof") ErrInIssuanceInvalidValueBlinder = fmt.Errorf("invalid issuance value blinder length") ErrInIssuanceInvalidValueCommitment = fmt.Errorf("invalid issuance value commitment length") ErrInIssuanceInvalidTokenBlinder = fmt.Errorf("invalid issuance token value blinder length") ErrInIssuanceInvalidTokenCommitment = fmt.Errorf("invalid issuance token value commitment length") // Input errors ErrOwnedInMissingValue = fmt.Errorf("missing input value") ErrOwnedInMissingAsset = fmt.Errorf("missing input asset") ErrOwnedInMissingValueBlinder = fmt.Errorf("missing input value blinder") ErrOwnedInMissingAssetBlinder = fmt.Errorf("missing input asset blinder") ErrOwnedInInvalidAsset = fmt.Errorf("invalid input asset length") ErrOwnedInInvalidAssetFormat = fmt.Errorf("input asset must be a string in hex format") ErrOwnedInInvalidValueBlinder = fmt.Errorf("invalid input value blinder length") ErrOwnedInInvalidAssetBlinder = fmt.Errorf("invalid input asset blinder length") // Blinder errors ErrBlinderForbiddenBlinding = fmt.Errorf("provided pset does not need to be blinded") ErrBlinderMissingOwnedInputs = fmt.Errorf("missing list of owned inputs") ErrBlinderMissingValidator = fmt.Errorf("missing blinding validator") ErrBlinderMissingGenerator = fmt.Errorf("missing blinding generator") )
var ( // Input errors ErrInMissingTxid = fmt.Errorf("missing input txid") ErrInInvalidTxidFormat = fmt.Errorf("input txid must be in hex format") ErrInInvalidTxid = fmt.Errorf("invalid input txid length") // Output errors ErrOutMissingAsset = fmt.Errorf("missing output asset") ErrOutInvalidAssetFormat = fmt.Errorf("output asset must be in hex format") ErrOutInvalidAsset = fmt.Errorf("invalid output asset length") ErrOutInvalidAddress = fmt.Errorf("invalid output address") )
var ( ErrFinalizerInvalidSigHashFlags = fmt.Errorf("invalid sighash flags") ErrFinalizerForbiddenFinalization = fmt.Errorf("pset is not finalizable") ErrFinalizerAlreadyFinalized = fmt.Errorf( "cannot finalize pset, finalized scriptSig or scriptWitnes already exists", ) )
var ( ErrGlobalInvalidXPubLen = fmt.Errorf("invalid global xpub value length") ErrGlobalInvalidXPubDerivationPathLen = fmt.Errorf("invalid global xpub derivation path value length") ErrGlobalInvalidTxVersionLen = fmt.Errorf("invalid global tx version value length") ErrGlobalInvalidTxVersion = fmt.Errorf("invalid global tx version value") ErrGlobalInvalidFallbackLocktimeLen = fmt.Errorf("invalid global fallback locktime value length") ErrGlobalInvalidInputCountLen = fmt.Errorf("invalid global input count value length") ErrGlobalInvalidOutputCountLen = fmt.Errorf("invalid global output count value length") ErrGlobalInvalidTxModifiableLen = fmt.Errorf("invalid global tx modifiable value length") ErrGlobalInvalidTxModifiable = fmt.Errorf("invalid global tx modifiable value") ErrGlobalInvalidVersionLen = fmt.Errorf("invalid global version value length") ErrGlobalInvalidVersion = fmt.Errorf("invalid global version value") ErrGlobalInvalidScalarLen = fmt.Errorf("invalid global scalar length") ErrGlobalInvalidModifiableLen = fmt.Errorf("invalid global pset modifiable length") ErrGlobalInvalidModifiable = fmt.Errorf("invalid global pset modifiable value") ErrGlobalDuplicatedField = func(field string) error { return fmt.Errorf("duplicated global %s", field) } )
var ( ErrInInvalidPartialSignature = fmt.Errorf( "invalid input partial signature", ) ErrInInvalidSigHash = fmt.Errorf( "invalid input sighash length", ) ErrInInvalidPubKey = fmt.Errorf( "invalid input pubkey length", ) ErrInInvalidPreviousTxid = fmt.Errorf( "invalid input prev txid length", ) ErrInInvalidPreviousTxIndex = fmt.Errorf( "invalid input prev tx index length", ) ErrInInvalidSequence = fmt.Errorf( "invalid input sequence length", ) ErrInInvalidRequiredLocktime = fmt.Errorf( "invalid input required locktime length", ) ErrInInvalidRequiredHeightLocktime = fmt.Errorf( "invalid input required height locktime length", ) ErrInInvalidIssuanceValue = fmt.Errorf( "invalid input issuance value length", ) ErrInInvalidIssuanceCommitment = fmt.Errorf( "invalid input issuance value commitment length", ) ErrInInvalidPeginGenesisHash = fmt.Errorf( "invalid input pegin genesis hash length", ) ErrInInvalidPeginValue = fmt.Errorf( "invalid input pegin value length", ) ErrInInvalidIssuanceInflationKeys = fmt.Errorf( "invalid input issuance inflation keys length", ) ErrInInvalidIssuanceInflationKeysCommitment = fmt.Errorf( "invalid input issuance inflation keys commitment length", ) ErrInInvalidIssuanceBlindingNonce = fmt.Errorf( "invalid input issuance blinding nonce length", ) ErrInInvalidIssuanceAssetEntropy = fmt.Errorf( "invalid input issuance asset entropy length", ) ErrInInvalidWitnessScript = fmt.Errorf( "input witness script cannot be set if witness utxo is unset", ) ErrInInvalidFinalScriptWitness = fmt.Errorf( "input final script witness cannot be set if witness utxo is unset", ) ErrInMissingIssuanceBlindValueProof = fmt.Errorf( "missing input issuance value commitment or blind proof", ) ErrInMissingIssuanceBlindInflationKeysProof = fmt.Errorf( "missing input issuance inflation keys commitment or blind proof", ) ErrInInvalidLocktime = fmt.Errorf("invalid input locktime") ErrInInvalidNonWitnessUtxo = fmt.Errorf( "non-witness utxo hash does not match input txid", ) ErrInInvalidPeginWitness = fmt.Errorf("invalid input pegin witness") ErrInInvalidPeginTx = fmt.Errorf("invalid input pegin tx") ErrInDuplicatedField = func(field string) error { return fmt.Errorf("duplicated input %s", field) } ErrInInvalidExplicitValue = fmt.Errorf("invalid input explicit value") ErrInInvalidExplicitAsset = fmt.Errorf("invalid input explicit asset") ErrInInvalidBlindedIssuanceValue = fmt.Errorf("invalid input blinded issuance value") )
var ( ErrKeyInvalidSize = fmt.Errorf("invalid key size") ErrProprietaryInvalidKey = fmt.Errorf("invalid ProprietaryData key") ErrProprietaryInvalidIdentifier = fmt.Errorf("invalid ProprietaryData identifier") )
var ( ErrOutInvalidBlinding = fmt.Errorf( "output is partially blinded while it must be either unblinded or " + "fully blinded", ) ErrOutInvalidBlinderIndexState = fmt.Errorf( "blinder index must be unset for fully blinded output", ) ErrOutInvalidValue = fmt.Errorf("invalid output value length") ErrOutInvalidPubKey = fmt.Errorf("invalid output pubkey length") ErrOutInvalidBlindingPubKey = fmt.Errorf( "invalid output blinding pubkey length", ) ErrOutInvalidBlinderIndex = fmt.Errorf("invalid output blinder index length") ErrOutDuplicatedField = func(field string) error { return fmt.Errorf("duplicated output %s", field) } )
var ( ErrInvalidPsbtFormat = fmt.Errorf("invalid PSBT serialization format") ErrNoMoreKeyPairs = fmt.Errorf("no more key-pairs") ErrInvalidMagicBytes = fmt.Errorf("invalid magic bytes") ErrPsetMissingBlindedOutput = fmt.Errorf( "pset has blinded inputs, at least one output must be blinded", ) ErrPsetInvalidGlobablModifiableState = fmt.Errorf( "global modifiable flag must be unset for fully blinded pset", ) ErrPsetForbiddenInputsModification = fmt.Errorf( "pset locked for modifications on inputs", ) ErrPsetForbiddenOutputsModification = fmt.Errorf( "pset locked for modifications on outputs", ) ErrPartialSignatureMissingPubKey = fmt.Errorf( "input partial signature is missing pubkey", ) )
var ( ErrInputIndexOutOfRange = fmt.Errorf("provided input index is out of range") ErrOutputIndexOutOfRange = fmt.Errorf("provided output index is out of range") ErrInvalidSignatureForInput = fmt.Errorf("signature does not correspond to this input") ErrInIssuanceMissingAssetAddress = fmt.Errorf("missing destination address for asset to (re)issue") ErrInIssuanceMissingTokenAddress = fmt.Errorf("missing destination address for token to (re)issue") ErrInIssuanceAddressesMismatch = fmt.Errorf("asset and token destination addresses must both be confidential or non-confidential") ErrPsetMissingInputForIssuance = fmt.Errorf("pset must contain at least one input to add issuance to") ErrPsetMissingEmptyInputsForIssuance = fmt.Errorf("transaction does not contain any input with empty issuance") ErrInReissuanceMissingPrevout = fmt.Errorf("either WitnessUtxo or NonWitnessUtxo must be defined") ErrInReissuanceInvalidTokenBlinder = fmt.Errorf("invalid token prevout blinder length") ErrInReissuanceZeroTokenBlinder = fmt.Errorf("token prevout blinder must not be a zero blinder") ErrInReissuanceInvalidAssetAmount = fmt.Errorf("invalid reissuance asset amount") ErrInReissuanceInvalidTokenAmount = fmt.Errorf("invalid reissuance token amount") )
var (
ErrExtractorForbiddenExtraction = fmt.Errorf(
"pset must be complete to extract final transaction",
)
)
var (
ErrSignerForbiddenSigning = fmt.Errorf("pset is not fully blinded")
)
Functions ¶
func Extract ¶
func Extract(p *Pset) (*transaction.Transaction, error)
func Finalize ¶
Finalize assumes that the provided pset.Pset 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. The witness/non-witness utxo fields in the inputs (key-types 00 and 01) are left intact as they may be needed for validation (?). If there is any invalid or incomplete data, an error is returned.
func FinalizeAll ¶
FinalizeAll finalizes all inputs of a partial elements transaction by calling the Finalize function for every partial input
func MaybeFinalize ¶
MaybeFinalize attempts to finalize the input at index inIndex in the PSET p, returning true with no error if it succeeds, OR if the input has already been finalized.
func MaybeFinalizeAll ¶
MaybeFinalizeAll attempts to finalize all inputs of the pset.Pset that are not already finalized, and returns an error if it fails to do so.
func SerializeBIP32Derivation ¶
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) || ....
Types ¶
type AddInIssuanceArgs ¶
type AddInIssuanceArgs struct { Precision uint Contract *transaction.IssuanceContract AssetAmount uint64 TokenAmount uint64 AssetAddress string TokenAddress string BlindedIssuance bool }
AddInIssuanceArgs is a struct encapsulating all the issuance data that can be attached to any specific transaction of the PSBT.
type AddInReissuanceArgs ¶
type AddInReissuanceArgs struct { TokenPrevOutBlinder []byte Entropy string AssetAmount uint64 AssetAddress string TokenAmount uint64 TokenAddress string }
AddInReissuanceArgs defines the mandatory fields that one needs to pass to the AddInReissuance method of the *Updater type
PrevOutHash: the prevout hash of the token that will be added as input to the tx PrevOutIndex: the prevout index of the token that will be added as input to the tx PrevOutBlinder: the asset blinder used to blind the prevout token WitnessUtxo: the prevout token in case it is a witness one NonWitnessUtxo: the prevout tx that include the token output in case it is a non-witness one Entropy: the entropy used to generate token and asset AssetAmount: the amount of asset to re-issue TokenAmount: the same unblinded amount of the prevout token AssetAddress: the destination address of the re-issuing asset TokenAddress: the destination address of the re-issuance token
type Bip32Sorter ¶
type Bip32Sorter []*DerivationPathWithPubKey
Bip32Sorter implements sort.Interface for the DerivationPathWithPubKey struct.
func (Bip32Sorter) Len ¶
func (s Bip32Sorter) Len() int
func (Bip32Sorter) Less ¶
func (s Bip32Sorter) Less(i, j int) bool
func (Bip32Sorter) Swap ¶
func (s Bip32Sorter) Swap(i, j int)
type Blinder ¶
type Blinder struct { Pset *Pset OwnedInputs []OwnedInput // contains filtered or unexported fields }
func NewBlinder ¶
func NewBlinder( p *Pset, ownedInputs []OwnedInput, validator BlindingValidator, generator BlindingGenerator, ) (*Blinder, error)
func (*Blinder) BlindLast ¶
func (b *Blinder) BlindLast( inIssuanceBlindingArgs []InputIssuanceBlindingArgs, outBlindingArgs []OutputBlindingArgs, ) error
func (*Blinder) BlindNonLast ¶
func (b *Blinder) BlindNonLast( inIssuanceBlindingArgs []InputIssuanceBlindingArgs, outBlindingArgs []OutputBlindingArgs, ) error
type BlindingGenerator ¶
type BlindingGenerator interface { // Scalar methods ComputeAndAddToScalarOffset( scalar []byte, value uint64, assetBlinder, valueBlinder []byte, ) ([]byte, error) SubtractScalars(inputScalar, outputScalar []byte) ([]byte, error) // Last blinder methods LastValueCommitment(value uint64, asset, blinder []byte) ([]byte, error) LastBlindValueProof( value uint64, valueCommitment, assetCommitment, blinder []byte, ) ([]byte, error) LastValueRangeProof( value uint64, asset, assetBlinder, valueCommitment, valueBlinder, scriptPubkey, nonce []byte, ) ([]byte, error) }
type BlindingValidator ¶
type BlindingValidator interface { VerifyValueRangeProof( valueCommitment, assetCommitment, script, proof []byte, ) bool VerifyAssetSurjectionProof( inAssets, inAssetBlinders [][]byte, outAsset, outAssetBlinder, proof []byte, ) bool VerifyBlindValueProof( value uint64, valueCommitment, assetCommitment, proof []byte, ) bool VerifyBlindAssetProof(asset, assetCommitment, proof []byte) bool }
type DerivationPath ¶
type DerivationPath []uint32
func (DerivationPath) String ¶
func (p DerivationPath) String() string
type DerivationPathWithPubKey ¶
type DerivationPathWithPubKey struct { // PubKey is the raw pubkey serialized in compressed format. PubKey []byte // MasterKeyFingerprint is the finger print of the master pubkey. MasterKeyFingerprint uint32 // Bip32Path is the BIP 32 path with child index as a distinct integer. Bip32Path []uint32 }
DerivationPathWithPubKey encapsulates the data for the input and output DerivationPathWithPubKey key-value fields.
type Global ¶
type Global struct { Xpubs []Xpub TxVersion uint32 FallbackLocktime *uint32 InputCount uint64 OutputCount uint64 TxModifiable BitSet Version uint32 Scalars [][]byte Modifiable BitSet ProprietaryData []ProprietaryData Unknowns []KeyPair }
func (*Global) SanityCheck ¶
type Input ¶
type Input struct { NonWitnessUtxo *transaction.Transaction WitnessUtxo *transaction.TxOutput PartialSigs []PartialSig SigHashType txscript.SigHashType RedeemScript []byte WitnessScript []byte Bip32Derivation []DerivationPathWithPubKey FinalScriptSig []byte FinalScriptWitness []byte Ripemd160Preimages map[[20]byte][]byte Sha256Preimages map[[32]byte][]byte Hash160Preimages map[[20]byte][]byte Hash256Preimages map[[32]byte][]byte PreviousTxid []byte PreviousTxIndex uint32 Sequence uint32 RequiredTimeLocktime uint32 RequiredHeightLocktime uint32 IssuanceValue uint64 IssuanceValueCommitment []byte IssuanceValueRangeproof []byte IssuanceInflationKeysRangeproof []byte PeginTx *wire.MsgTx PeginTxoutProof []byte PeginGenesisHash []byte PeginClaimScript []byte PeginValue uint64 PeginWitness [][]byte IssuanceInflationKeys uint64 IssuanceInflationKeysCommitment []byte IssuanceBlindingNonce []byte IssuanceAssetEntropy []byte UtxoRangeProof []byte IssuanceBlindValueProof []byte IssuanceBlindInflationKeysProof []byte ExplicitValue uint64 ValueProof []byte ExplicitAsset []byte AssetProof []byte BlindedIssuance *bool ProprietaryData []ProprietaryData Unknowns []KeyPair }
func (*Input) GetIssuanceAssetHash ¶
func (*Input) GetIssuanceInflationKeysHash ¶
func (*Input) GetUtxo ¶
func (i *Input) GetUtxo() *transaction.TxOutput
func (*Input) HasIssuance ¶
func (*Input) HasIssuanceBlinded ¶
func (*Input) HasReissuance ¶
func (*Input) SanityCheck ¶
type InputIssuanceBlindingArgs ¶
type InputIssuanceBlindingArgs struct { Index uint32 IssuanceAsset []byte IssuanceToken []byte IssuanceValueCommitment []byte IssuanceTokenCommitment []byte IssuanceValueRangeProof []byte IssuanceTokenRangeProof []byte IssuanceValueBlindProof []byte IssuanceTokenBlindProof []byte IssuanceValueBlinder []byte IssuanceTokenBlinder []byte }
type KeyPair ¶
keyPair format: <keypair> := <key> <value> <key> := <keylen> <keytype> <keydata> <value> := <valuelen> <valuedata>
type Output ¶
type Output struct { RedeemScript []byte WitnessScript []byte Bip32Derivation []DerivationPathWithPubKey Value uint64 Script []byte ValueCommitment []byte Asset []byte AssetCommitment []byte ValueRangeproof []byte AssetSurjectionProof []byte BlindingPubkey []byte EcdhPubkey []byte BlinderIndex uint32 BlindValueProof []byte BlindAssetProof []byte ProprietaryData []ProprietaryData Unknowns []KeyPair }
func (*Output) IsFullyBlinded ¶
func (*Output) IsPartiallyBlinded ¶
func (*Output) NeedsBlinding ¶
func (*Output) SanityCheck ¶
type OutputArgs ¶
type OutputBlindingArgs ¶
type OwnedInput ¶
type PartialSig ¶
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()
type PartialSigSorter ¶
type PartialSigSorter []*PartialSig
PartialSigSorter implements sort.Interface for PartialSig.
func (PartialSigSorter) Len ¶
func (s PartialSigSorter) Len() int
func (PartialSigSorter) Less ¶
func (s PartialSigSorter) Less(i, j int) bool
func (PartialSigSorter) Swap ¶
func (s PartialSigSorter) Swap(i, j int)
type ProprietaryData ¶
type Pset ¶
Pset - Partially Signed Elements Transaction Format: <pset> := <magic> <global-map> <input-map>* <output-map>* <magic> := 0x70 0x73 0x65 0x74 0xFF -> pset starts with magic bytes, after which goes global map followed by more input-map's and output-map's <global-map> := <keypair>* 0x00 -> there is one global-map, there can be many keypair's, global map ends with separator <input-map> := <keypair>* 0x00 -> there can be many input-map's, there can be many keypair's, input map ends with separator <output-map> := <keypair>* 0x00 -> there can be many output-map's, there can be many keypair's, output map ends with separator <keypair> := <key> <value> <key> := <keylen> <keytype> <keydata> <value> := <valuelen> <valuedata> Each map can contain ProprietaryData data and unknowns keypair's Full spec: https://github.com/ElementsProject/elements/blob/master/doc/pset.mediawiki
func NewPsetFromBase64 ¶
func (*Pset) HasSighashSingle ¶
func (*Pset) InputsModifiable ¶
func (*Pset) IsComplete ¶
func (*Pset) IsFullyBlinded ¶
func (*Pset) NeedsBlinding ¶
func (*Pset) OutputsModifiable ¶
func (*Pset) SanityCheck ¶
func (*Pset) UnsignedTx ¶
func (p *Pset) UnsignedTx() (*transaction.Transaction, error)
func (*Pset) ValidateAllSignatures ¶
type Signer ¶
type Signer = Updater
func (*Signer) SignInput ¶
SignInput allows the caller to sign a PSET at a particular input; they must provide a signature and a pubkey, both as byte slices; they can also optionally provide both witnessScript and/or redeemScript, otherwise these arguments must be set as nil (and in that case, they must already be present in the PSBT if required for signing to succeed).
This serves as a wrapper around UpdaterRole.addPartialSignature; it ensures that the redeemScript and witnessScript are updated as needed (note that the UpdaterRole is allowed to add redeemScripts and witnessScripts independently, before signing), and ensures that the right form of utxo field (NonWitnessUtxo or WitnessUtxo) is included in the input so that signature insertion (and then finalization) can take place.
type Updater ¶
type Updater struct {
Pset *Pset
}
Updater encapsulates the role 'Updater' as specified in BIP174; it accepts Psbt structs and has methods to add fields to the inputs and outputs.
func NewUpdater ¶
NewUpdater returns a new instance of Updater, if the passed Psbt struct is in a valid form, else an error.a
func (*Updater) AddInBip32Derivation ¶
func (u *Updater) AddInBip32Derivation( inIndex int, bip32Derivation DerivationPathWithPubKey, ) error
AddInBip32Derivation takes a master key fingerprint as defined in BIP32, a BIP32 path as a slice of uint32 values, and a serialized pubkey as a byte slice, along with the integer index of the input, and inserts this data into that input.
NOTE: This can be called multiple times for the same input. An error is returned if addition of this key-value pair to the Psbt fails.
func (*Updater) AddInExplicitAsset ¶ added in v0.4.3
AddInExplicitAsset adds the unconfidential asset hash and related blinding proof to the given confidential input. The proof should be calculate with confidential.CreateBlindAssetProof API.
func (*Updater) AddInExplicitValue ¶ added in v0.4.3
AddInExplicitValue adds the unconfidential value and related blinding proof to the given confidential input. The proof should be calculate with confidential.CreateBlindValueProof API.
func (*Updater) AddInIssuance ¶
func (u *Updater) AddInIssuance(inputIndex int, arg AddInIssuanceArgs) error
AddInIssuance adds an unblinded issuance to the transaction
func (*Updater) AddInNonWitnessUtxo ¶
func (u *Updater) AddInNonWitnessUtxo(inIndex int, tx *transaction.Transaction) error
AddInNonWitnessUtxo adds the utxo information for an input which is non-witness. This requires provision of a full transaction (which is the source of the corresponding prevOut), and the input index. If addition of this key-value pair to the Psbt fails, an error is returned.
func (*Updater) AddInRedeemScript ¶
AddInRedeemScript adds the redeem script information for an input. The redeem script is passed serialized, as a byte slice, along with the index of the input. An error is returned if addition of this key-value pair to the Psbt fails.
func (*Updater) AddInReissuance ¶
func (u *Updater) AddInReissuance(inputIndex int, arg AddInReissuanceArgs) error
AddInReissuance takes care of adding an input (the prevout token) and 2 outputs to the partial transaction. It also creates a new (re)issuance with the provided entropy, blinder and amounts and attaches it to the new input. NOTE: This transaction must be blinded later so that a new token blinding nonce is generated for the new token output
func (*Updater) AddInSighashType ¶
func (u *Updater) AddInSighashType( inIndex int, sighashType txscript.SigHashType, ) error
AddInSighashType adds the sighash type information for an input. The sighash type is passed as a 32 bit unsigned integer, along with the index for the input. .
func (*Updater) AddInUtxoRangeProof ¶
AddInUtxoRangeProof adds the prevout rangeproof for an input.
func (*Updater) AddInWitnessScript ¶
AddInWitnessScript adds the witness script information for an input. The witness script is passed serialized, as a byte slice, along with the index of the input. An error is returned if addition of this key-value pair to the Psbt fails.
func (*Updater) AddInWitnessUtxo ¶
func (u *Updater) AddInWitnessUtxo(inIndex int, txout *transaction.TxOutput) error
AddInWitnessUtxo adds the utxo information for an input which is witness. This requires provision of a full transaction *output* (which is the source of the corresponding prevOut); not the full transaction because BIP143 means the output information is sufficient, and the input index. If addition of this key-value pair to the Psbt fails, an error is returned.
func (*Updater) AddOutBip32Derivation ¶
func (u *Updater) AddOutBip32Derivation( outIndex int, bip32Derivation DerivationPathWithPubKey, ) error
AddOutBip32Derivation takes a master key fingerprint as defined in BIP32, a BIP32 path as a slice of uint32 values, and a serialized pubkey as a byte slice, along with the integer index of the output, and inserts this data into that output.
NOTE: That this can be called multiple times for the same output. An error is returned if addition of this key-value pair to the Psbt fails.
func (*Updater) AddOutRedeemScript ¶
AddOutRedeemScript takes a redeem script as a byte slice and appends it to the output at index outIndex.
func (*Updater) AddOutWitnessScript ¶
AddOutWitnessScript takes a witness script as a byte slice and appends it to the output at index outIndex.
func (*Updater) AddOutputs ¶
func (u *Updater) AddOutputs(outputs []OutputArgs) error
AddOutput adds the provided outputs to the Pset
type Xpub ¶
type Xpub struct { ExtendedKey []byte MasterFingerprint uint32 DerivationPath DerivationPath }