htlcbch

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// cashc --hex ../atomic-swap-covenants/covenants/HTLC4.cash
	RedeemScriptWithoutConstructorArgsHex = "" /* 260-byte string literal not displayed */
)

Variables

This section is empty.

Functions

func MsgTxFromBytes

func MsgTxFromBytes(data []byte) (*wire.MsgTx, error)

func MsgTxToBytes

func MsgTxToBytes(tx *wire.MsgTx) []byte

func MsgTxToHex

func MsgTxToHex(tx *wire.MsgTx) string

Types

type HtlcCovenant

type HtlcCovenant struct {
	// contains filtered or unexported fields
}

func NewCovenant

func NewCovenant(
	senderPkh, recipientPkh, hashLock []byte, expiration, penaltyBPS uint16,
	net *chaincfg.Params,
) (*HtlcCovenant, error)

func NewMainnetCovenant

func NewMainnetCovenant(
	senderPkh, recipientPkh, hashLock []byte, expiration, penaltyBPS uint16,
) (*HtlcCovenant, error)

func NewTestnet3Covenant

func NewTestnet3Covenant(
	senderPkh, recipientPkh, hashLock []byte, expiration, penaltyBPS uint16,
) (*HtlcCovenant, error)

func (*HtlcCovenant) BuildFullRedeemScript

func (c *HtlcCovenant) BuildFullRedeemScript() ([]byte, error)

func (*HtlcCovenant) BuildOpRetPkScript added in v0.1.0

func (c *HtlcCovenant) BuildOpRetPkScript(sbchUserAddr []byte) ([]byte, error)

OP_RETURN "SBAS" <recipient pkh> <sender pkh> <hash lock> <expiration> <penalty bps> <sbch user address>

func (*HtlcCovenant) BuildReceiveSigScript

func (c *HtlcCovenant) BuildReceiveSigScript(secret []byte) ([]byte, error)

func (*HtlcCovenant) BuildRefundSigScript

func (c *HtlcCovenant) BuildRefundSigScript() ([]byte, error)

func (*HtlcCovenant) GetP2SHAddress

func (c *HtlcCovenant) GetP2SHAddress() (string, error)

func (*HtlcCovenant) GetRedeemScriptHash

func (c *HtlcCovenant) GetRedeemScriptHash() ([]byte, error)

func (*HtlcCovenant) MakeLockTx

func (c *HtlcCovenant) MakeLockTx(
	fromKey *bchec.PrivateKey,
	inputs []InputInfo,
	outAmt int64,
	minerFeeRate uint64,
) (*wire.MsgTx, error)

func (*HtlcCovenant) MakeReceiveTx

func (c *HtlcCovenant) MakeReceiveTx(
	txid []byte, vout uint32, inAmt int64,
	minerFeeRate uint64,
	secret []byte,
) (*wire.MsgTx, error)

func (*HtlcCovenant) MakeRefundTx

func (c *HtlcCovenant) MakeRefundTx(
	txid []byte, vout uint32, inAmt int64,
	minerFeeRate uint64,
) (*wire.MsgTx, error)

func (*HtlcCovenant) String

func (c *HtlcCovenant) String() string

type HtlcLockInfo added in v0.1.0

type HtlcLockInfo struct {
	//BlockNum      uint64
	TxHash        string        // 32 bytes, hex
	RecipientPkh  hexutil.Bytes // 20 bytes
	SenderPkh     hexutil.Bytes // 20 bytes
	HashLock      hexutil.Bytes // 32 bytes, sha256
	Expiration    uint16        //  2 bytes, big endian
	PenaltyBPS    uint16        //  2 bytes, big endian
	SenderEvmAddr hexutil.Bytes // 20 bytes
	ScriptHash    hexutil.Bytes // 20 bytes, hash160
	Value         uint64        // in sats
}

func GetHtlcLocksInfo added in v0.1.0

func GetHtlcLocksInfo(block *wire.MsgBlock) (deposits []*HtlcLockInfo)

type HtlcUnlockInfo added in v0.1.0

type HtlcUnlockInfo struct {
	PrevTxHash string // 32 bytes, hex
	TxHash     string // 32 bytes, hex
	Secret     string // 32 bytes, hex
}

func GetHtlcUnlocksInfo added in v0.1.0

func GetHtlcUnlocksInfo(block *wire.MsgBlock) (receipts []*HtlcUnlockInfo)

type InputInfo

type InputInfo struct {
	TxID   []byte
	Vout   uint32
	Amount int64
}

Jump to

Keyboard shortcuts

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