wallet

package
v0.1.20 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	P2PK = iota
	P2PKH
	P2MS
	P2SH_P2WPKH
	P2SH_P2WSH
	P2WPKH
	P2WSH
)

Variables

View Source
var (
	ErrMissingOwnedInputs       = fmt.Errorf("missing list of owned inputs")
	ErrMissingBlindingMasterKey = fmt.Errorf("missing blinding master key")
	ErrBlindInvalidInputIndex   = fmt.Errorf("input index to blind is out of range")
)
View Source
var (
	ErrInputMissingTxid = fmt.Errorf("input is missing txid")
	ErrInputInvalidTxid = fmt.Errorf("invalid input txid length: must be exactly 32 bytes")
)
View Source
var (
	ErrOutputMissingAsset       = fmt.Errorf("output is missing asset")
	ErrOutputInvalidAsset       = fmt.Errorf("invalid output asset length: must be exactly 32 bytes")
	ErrOutputInvalidScript      = fmt.Errorf("invalid output script")
	ErrOutputInvalidBlindingKey = fmt.Errorf("invalid output blinding key")
)
View Source
var (
	ErrMissingPset       = fmt.Errorf("missing pset base64")
	ErrMissingInputs     = fmt.Errorf("at least one input is mandatory to create a partial transaction with one or more confidential outputs")
	ErrInvalidSignatures = fmt.Errorf("transaction contains invalid signature(s)")

	DummyFeeAmount = uint64(700)
)

Functions

func BlindPsetWithMasterKey

func BlindPsetWithMasterKey(
	args BlindPsetWithMasterKeyArgs,
) (string, error)

func BlindPsetWithOwnedInputs

func BlindPsetWithOwnedInputs(
	args BlindPsetWithOwnedInputsArgs,
) (string, error)

func CreatePset

func CreatePset(args CreatePsetArgs) (string, error)

CreatePset creates a new partial transaction with given inputs and outputs.

func EstimateFees

func EstimateFees(
	inputs []Input, outputs []Output, millisatsPerByte uint64,
) uint64

EstimateFees estimates the virtual size of the transaciton composed of the given Inputs and Outputs and then returns the corresponding fee amount based on the given mSats/Byte ratio.

func EstimateTxSize

func EstimateTxSize(inputs []Input, outputs []Output) uint64

EstimateTxSize makes an estimation of the virtual size of a transaction for which is required to specify the type of the inputs and outputs according to those of the Bitcoin standard (P2PK, P2PKH, P2MS, P2SH(P2WPKH), P2SH(P2WSH), P2WPKH, P2WSH). The estimation might not be accurate in case of one or more P2MS inputs since the method is not able to retrieve the size of redeem script containg all pubkeys, nor it expects anyone as arg.

func FinalizeAndExtractTransaction

func FinalizeAndExtractTransaction(args FinalizeAndExtractTransactionArgs) (string, string, error)

FinalizeAndExtractTransaction attempts to finalize the provided partial transaction and eventually extracts the final raw transaction, returning it in hex string format, along with its transaction id.

func UpdatePset

func UpdatePset(args UpdatePsetArgs) (string, error)

UpdatesPset adds inputs and outputs to the given partial transaction.

Types

type BlindPsetWithMasterKeyArgs

type BlindPsetWithMasterKeyArgs struct {
	PsetBase64        string
	BlindingMasterKey []byte
	ExtraBlindingKeys map[string][]byte
	LastBlinder       bool
}

type BlindPsetWithOwnedInputsArgs

type BlindPsetWithOwnedInputsArgs struct {
	PsetBase64         string
	OwnedInputsByIndex map[uint32]Input
	LastBlinder        bool
}

type CreatePsetArgs

type CreatePsetArgs struct {
	Inputs  []Input
	Outputs []Output
}

type FinalizeAndExtractTransactionArgs

type FinalizeAndExtractTransactionArgs struct {
	PsetBase64 string
}

type Input

type Input struct {
	TxID            string
	TxIndex         uint32
	Value           uint64
	Asset           string
	Script          []byte
	ValueBlinder    []byte
	AssetBlinder    []byte
	ValueCommitment []byte
	AssetCommitment []byte
	Nonce           []byte
	RangeProof      []byte
	SurjectionProof []byte
	DerivationPath  string
	RedeemScript    []byte
	ScriptSigSize   int
	WitnessSize     int
}

Input is the data structure representing an input to be added to a partial transaction, therefore including the previous outpoint as long as all the info about the prevout itself (and the derivation path generating its script as extra info).

func (Input) Prevout

func (i Input) Prevout() *transaction.TxOutput

func (Input) ScriptType

func (i Input) ScriptType() int

func (Input) Validate

func (i Input) Validate() error

type Output

type Output psetv2.OutputArgs

Output is the data structure representing an output to be added to a partial transaction, therefore inclusing asset, amount and address.

func (Output) IsConfidential

func (o Output) IsConfidential() bool

func (Output) ScriptSize

func (o Output) ScriptSize() int

func (Output) Validate

func (o Output) Validate() error

type UpdatePsetArgs

type UpdatePsetArgs struct {
	PsetBase64 string
	Inputs     []Input
	Outputs    []Output
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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