txutils

package
v0.8.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 20, 2025 License: MIT Imports: 10 Imported by: 6

Documentation

Index

Constants

View Source
const ArkPsbtFieldKeyType = 222

Variables

View Source
var (
	ANCHOR_PKSCRIPT = []byte{
		0x51, 0x02, 0x4e, 0x73,
	}
	ANCHOR_VALUE = int64(0)
)
View Source
var (
	// ArkPsbtFieldTaprootTree reveals the taproot tree associated with an input
	ArkFieldTaprootTree = []byte("taptree")
	// ArkFieldTreeExpiry attach the CSV locktime expiring a tx input
	ArkFieldTreeExpiry = []byte("expiry")
	// ArkFieldCosigner attach a musig2 cosigner public key to an unsigned tx input
	ArkFieldCosigner = []byte("cosigner")
	// ArkFieldConditionWitness allows to set extra witness elements used to sign custom script inputs
	ArkFieldConditionWitness = []byte("condition")
)

Functions

func AnchorOutput

func AnchorOutput() *wire.TxOut

func ExtractWithAnchors

func ExtractWithAnchors(p *psbt.Packet) (*wire.MsgTx, error)

ExtractWithAnchors extracts the final witness and scriptSig from psbt fields and ignores anchor inputs without failing.

func FindAnchorOutpoint

func FindAnchorOutpoint(tx *wire.MsgTx) (*wire.OutPoint, error)

func GetArkPsbtFields added in v0.8.0

func GetArkPsbtFields[T any](ptx *psbt.Packet, inputIndex int, coder ArkPsbtFieldCoder[T]) ([]T, error)

GetArkPsbtFields gets all ark psbt fields of the given type from the given psbt at the given input index

func ParseCosignerKeysFromArkPsbt added in v0.8.0

func ParseCosignerKeysFromArkPsbt(ptx *psbt.Packet, inIndex int) ([]*btcec.PublicKey, error)

func ParseCosignersToECPubKeys added in v0.8.0

func ParseCosignersToECPubKeys(fields []IndexedCosignerPublicKey) []*btcec.PublicKey

func ReadTxWitness

func ReadTxWitness(witnessSerialized []byte) (wire.TxWitness, error)

func SetArkPsbtField added in v0.8.0

func SetArkPsbtField[T any](ptx *psbt.Packet, inputIndex int, coder ArkPsbtFieldCoder[T], value T) error

SetArkPsbtField sets an ark psbt field on the given psbt at the given input index

Types

type ArkPsbtFieldCoder added in v0.8.0

type ArkPsbtFieldCoder[T any] interface {
	Encode(T) (*psbt.Unknown, error)
	Decode(*psbt.Unknown) (*T, error) // nil means not found
}
var ConditionWitnessField ArkPsbtFieldCoder[wire.TxWitness] = arkPsbtFieldCoderConditionWitness{}
var CosignerPublicKeyField ArkPsbtFieldCoder[IndexedCosignerPublicKey] = arkPsbtFieldCoderCosignerPublicKey{}
var VtxoTaprootTreeField ArkPsbtFieldCoder[TapTree] = arkPsbtFieldCoderTaprootTree{}

Singletons instances for each field type

var VtxoTreeExpiryField ArkPsbtFieldCoder[arklib.RelativeLocktime] = arkPsbtFieldCoderTreeExpiry{}

type IndexedCosignerPublicKey added in v0.8.0

type IndexedCosignerPublicKey struct {
	Index     int
	PublicKey *btcec.PublicKey
}

IndexedCosignerPublicKey is a public key with its associated index. it is needed in ark cosigner public key field because we need to keep track of the order of the keys.

type TapTree

type TapTree []string

TapTree is a wrapper around a list of tapscripts it is used to encode and decode the taproot tree in a way that is compatible with the PSBT_OUT_TAP_TREE field / BIP-371

func DecodeTapTree

func DecodeTapTree(data []byte) (TapTree, error)

func (TapTree) Encode

func (t TapTree) Encode() ([]byte, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL