bip322

package
v0.0.0-...-241d3e1 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2025 License: MIT Imports: 7 Imported by: 1

Documentation

Overview

https://bips.xyz/322

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMissingInputs             = fmt.Errorf("missing inputs")
	ErrMissingData               = fmt.Errorf("missing data")
	ErrMissingWitnessUtxo        = fmt.Errorf("missing witness utxo")
	ErrInvalidSighashType        = fmt.Errorf("invalid sighash type, expected SIGHASH_ALL")
	ErrIncompletePSBT            = fmt.Errorf("incomplete psbt, missing signatures on inputs")
	ErrInvalidTxNumberOfInputs   = fmt.Errorf("invalid tx, expected at least 2 inputs")
	ErrInvalidTxNumberOfOutputs  = fmt.Errorf("invalid tx, expected at least 1 output")
	ErrInvalidTxWrongTxHash      = fmt.Errorf("invalid tx, wrong tx hash in first input")
	ErrInvalidTxWrongOutputIndex = fmt.Errorf("invalid tx, wrong output index in first input")
	ErrPrevoutNotFound           = fmt.Errorf("prevout not found")
)

Functions

This section is empty.

Types

type FullProof

type FullProof psbt.Packet

BIP0322 full proof of funds is a special invalid psbt containing the inputs to prove ownership signing the proof means signing the psbt as a regular transaction

func New

func New(message string, inputs []Input, outputs []*wire.TxOut) (*FullProof, error)

New creates the proof psbt from the message and inputs

func (*FullProof) Signature

func (p *FullProof) Signature(finalize ...func(*psbt.Packet) error) (*Signature, error)

Signature extracts the BIP322 signature, fails if the psbt is not fully signed if the inputs contains custom finalization logic, use the finalize function if nil, finalize will use the default finalizer

type Input

type Input struct {
	OutPoint    *wire.OutPoint
	Sequence    uint32
	WitnessUtxo *wire.TxOut
}

Input embeds data of the UTXO to prove ownership

type Signature

type Signature wire.MsgTx

Signature is the signed and extracted toSign transaction

func DecodeSignature

func DecodeSignature(b64 string) (*Signature, error)

func (*Signature) ContainsOutputs

func (s *Signature) ContainsOutputs() bool

func (Signature) Encode

func (s Signature) Encode() (string, error)

Encode encodes the tx to a base64 string

func (*Signature) GetOutpoints

func (s *Signature) GetOutpoints() []wire.OutPoint

func (Signature) Verify

func (s Signature) Verify(message string, prevoutFetcher txscript.PrevOutputFetcher) error

Verify validates the BIP0322 full proof of funds our version does not check the input sequences in order to be compatible with offchain transactions

Jump to

Keyboard shortcuts

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