tx

package
v0.0.0-...-0ddd650 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Key

type Key struct {
	PubKey *btcec.PublicKey
	Net    *chaincfg.Params
	// contains filtered or unexported fields
}

func NewKey

func NewKey(privKeyBytes []byte, net *chaincfg.Params) *Key

func (*Key) CreateP2TR

func (k *Key) CreateP2TR() (string, error)

P2TR privkey -> pubkey -> shnorr-pubkey => witness program

func (*Key) CreateP2wpkh

func (k *Key) CreateP2wpkh() (string, error)

P2WPKH privkey -> pubkey hash160(pubkey) => witness program

func (*Key) CreateRawTxP2TR

func (k *Key) CreateRawTxP2TR(
	prevHash *chainhash.Hash,
	prevIndex uint32,
	prevAmountSat int64,
	sendAddrStr string,
	feeSat int64,
) ([]byte, string, error)

func (*Key) RedeemP2wpkhTx

func (k *Key) RedeemP2wpkhTx(
	prevHash *chainhash.Hash,
	prevIndex uint32,
	prevAmountSat int64,
	sendAddrStr string,
	feeSat int64,
) ([]byte, string, error)

func (*Key) SerializeSchnorrPubKey

func (k *Key) SerializeSchnorrPubKey() []byte

type RedeemType

type RedeemType = int
const (
	RedeemP2wpkh         RedeemType = 1
	RedeemP2trKeyPath    RedeemType = 2
	RedeemP2wsh          RedeemType = 3
	RedeemP2trScriptPath RedeemType = 4
)

type Script

type Script struct {
	Script []byte
	Net    *chaincfg.Params
}

func NewScript

func NewScript(script []byte, net *chaincfg.Params) *Script

func (*Script) CreateP2wsh

func (s *Script) CreateP2wsh() (string, error)

P2WSH sha256(witness script) => witness program

func (*Script) RedeemP2wshTx

func (s *Script) RedeemP2wshTx(
	prevHash *chainhash.Hash,
	prevIndex uint32,
	prevAmountSat int64,
	sendAddrStr string,
	feeSat int64,
	preimage []byte,
	key *Key,
) ([]byte, string, error)

type TapScript

type TapScript struct {
	Key     *Key
	Scripts []txscript.TapLeaf
	Net     *chaincfg.Params
}

func NewTapScript

func NewTapScript(internalKey *Key, scripts [][]byte, net *chaincfg.Params) *TapScript

func (*TapScript) CreateP2tr

func (s *TapScript) CreateP2tr() (string, error)

P2TR script

func (*TapScript) CreateRawTxP2TR

func (s *TapScript) CreateRawTxP2TR(
	prevHash *chainhash.Hash,
	prevIndex uint32,
	prevAmountSat int64,
	sendAddrStr string,
	feeSat int64,
	scriptIdx int,
	witnessStack [][]byte,
	key *Key,
) ([]byte, string, error)

Jump to

Keyboard shortcuts

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