intent

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: 11 Imported by: 0

Documentation

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")
	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")
	ErrMissingArkFields          = fmt.Errorf("expected at least 1 ark field, revealed taptree is required")
)

Functions

func Verify

func Verify(proofB64, message string) error

Verify takes an encoded b64 proof tx and a message to validate the proof

Types

type BaseMessage

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

type DeleteMessage

type DeleteMessage struct {
	BaseMessage
	// 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 (*DeleteMessage) Decode

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

func (DeleteMessage) Encode

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

type Input

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

Input embeds data of the UTXO to prove ownership

type IntentMessageType

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

type Proof

type Proof struct {
	psbt.Packet
}

an intent proof is a special psbt containing the inputs to prove ownership, embeds a message and may include optional outputs to register in ark batches.

func New

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

New creates the proof psbt from the message, inputs and (optional) outputs list the psbt creation is greatly inspired by BIP322 (https://bips.xyz/322) it is composed of 2 transactions: toSpend and toSign * toSpend embeds the message and make the proof "invalid" from the chain point of view * toSign is the regular transaction that will be signed to prove ownership of the inputs and may include the specified outputs toSign spends toSpend input as first input, making the tx unusable onchain

func (Proof) ContainsOutputs

func (p Proof) ContainsOutputs() bool

ContainsOutputs returns true if the proof specifies outputs to register in ark batches

func (Proof) GetOutpoints

func (p Proof) GetOutpoints() []wire.OutPoint

GetOutpoints returns the list of inputs proving ownership of coins the first input is the toSpend tx, we ignore it

type RegisterMessage

type RegisterMessage struct {
	BaseMessage
	// 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 (*RegisterMessage) Decode

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

func (RegisterMessage) Encode

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

Jump to

Keyboard shortcuts

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