bip322

package
v0.0.0-...-e1a327a Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2025 License: MIT Imports: 8 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")
	ErrIncompletePSBT     = fmt.Errorf("incomplete psbt, missing signatures on inputs")
)
View Source
var (
	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 BaseIntentMessage

type BaseIntentMessage struct {
	Type IntentMessageType `json:"type"`
}

type DeleteIntentMessage

type DeleteIntentMessage struct {
	BaseIntentMessage
	// ExpireAt is the timestamp (in seconds) at which the proof should be considered invalid
	// if set to 0, the proof will be considered valid indefinitely
	ExpireAt int64 `json:"expire_at"`
}

func (*DeleteIntentMessage) Decode

func (m *DeleteIntentMessage) Decode(data string) error

func (DeleteIntentMessage) Encode

func (m DeleteIntentMessage) Encode() (string, error)

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 BIP-0322 signature, fails if the tx is not fully signed. If the inputs contains custom witness, you may want to specify a finalization function, if otherwise the default finalizer is used.

type Input

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

Input embeds data of the UTXO to prove ownership

type IntentMessage

type IntentMessage struct {
	BaseIntentMessage
	// InputTapTrees is the list of taproot trees associated with the spent inputs
	// the index of the taproot tree in the list corresponds to the index of the input + 1
	// (we ignore the first bip322 input, as it is duplicate of the second one)
	InputTapTrees []string `json:"input_tap_trees"`
	// OnchainOutputIndexes specifies what are the outputs in the proof tx
	// that should be considered as onchain by the Ark operator
	OnchainOutputIndexes []int `json:"onchain_output_indexes"`
	// ValidAt is the timestamp (in seconds) at which the proof should be considered valid
	// if set to 0, the proof will be considered valid indefinitely or until ExpireAt is reached
	ValidAt int64 `json:"valid_at"`
	// ExpireAt is the timestamp (in seconds) at which the proof should be considered invalid
	// if set to 0, the proof will be considered valid indefinitely
	ExpireAt int64 `json:"expire_at"`
	// CosignersPublicKeys contains the public keys of the cosigners
	// if the outputs are not registered in the proof or all the outputs are onchain, this field is not required
	// it is required only if one of the outputs is offchain
	CosignersPublicKeys []string `json:"cosigners_public_keys"`
}

func (*IntentMessage) Decode

func (m *IntentMessage) Decode(data string) error

func (IntentMessage) Encode

func (m IntentMessage) Encode() (string, error)

type IntentMessageType

type IntentMessageType string
const (
	IntentMessageTypeRegister IntentMessageType = "register"
	IntentMessageTypeDelete   IntentMessageType = "delete"
)

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 BIP-0322 full proof of funds Our version does not check the input sequences to be compatible with offchain txs.

Jump to

Keyboard shortcuts

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