wallet

package
v0.0.0-...-3f4333e Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PrivateKeyConverter

type PrivateKeyConverter func(*btcec.PrivateKey) (*btcec.PrivateKey, error)

PrivateKeyConverter is a callback func applied to private key before creating witness signature

type Utxo

Utxo is an unspent transaction output

type Wallet

type Wallet interface {
	NewPubkey() (*btcec.PublicKey, error)

	// NewAddress creates a new address
	NewAddress() (btcutil.Address, error)

	// ImportAddress imports address
	ImportAddress(btcutil.Address) error

	// WitnessSignature returns witness signature for a given txin and pubkey
	WitnessSignature(
		tx *wire.MsgTx, idx int, amt btcutil.Amount, sc []byte, pub *btcec.PublicKey,
	) (sign []byte, err error)

	// WitnessSignatureWithCallback does the same with WitnessSignature do
	// applying a given func to private key before calculating signature
	WitnessSignatureWithCallback(
		tx *wire.MsgTx, idx int, amt btcutil.Amount, sc []byte, pub *btcec.PublicKey,
		privkeyConverter PrivateKeyConverter,
	) (sign []byte, err error)

	// WitnessSignTxByIdxs returns witness signatures for txins specified by idxs
	WitnessSignTxByIdxs(tx *wire.MsgTx, idxs []int) ([]wire.TxWitness, error)

	// SelectUtxos selects utxos for requested amount
	// by considering additional fee per txin and txout
	SelectUnspent(
		amt, feePerTxIn, feePerTxOut btcutil.Amount,
	) (utxos []Utxo, change btcutil.Amount, err error)
	// Unlock unlocks address manager
	Unlock(privPass []byte) error

	// TODO: remove this interface after fixing wallet.Open
	// SetRPCClient sets rpcclient
	SetRPCClient(rpc.Client)

	// methods delegating to RPC Client
	ListUnspent() (utxos []Utxo, err error)
	SendRawTransaction(tx *wire.MsgTx) (*chainhash.Hash, error)

	Close() error
}

Wallet is an interface that provides access to manage pubkey addresses and sign scripts of managed addressesc using private key. It also manags utxos.

Jump to

Keyboard shortcuts

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