Documentation
¶
Overview ¶
This package offers a storage for and basic manupulations with contracts used in the TumbleBit protocol.
Index ¶
- Constants
- type Contract
- func (con *Contract) AddEscrowScript() error
- func (con *Contract) AddOfferScript(hashes [][]byte, hashOp byte) error
- func (con *Contract) AddRedeemScript(secrets [][]byte) error
- func (con *Contract) AddRefundScript() error
- func (con *Contract) BuildRedeemTx(sigScriptAddSize int) error
- func (con *Contract) BuildRefundTx() error
- func (con *Contract) ExtractRedeemDataPushes(in uint32) ([][]byte, error)
- func (c *Contract) SetAddress(t addressRole, a, pk string) error
- func (c *Contract) String() string
- func (con *Contract) VerifyRedeemTx() error
- func (con *Contract) VerifyRefundTx() error
Constants ¶
const ( ReceiverAddress addressRole = iota RedeemAddress RefundAddress SenderAddress MaxAddressRole )
const ( PayToEdwardsPubKey addressType = 1 << iota PayToPubKey PayToPubKeyHash PayToSecSchnorrPubKey PayToScriptHash )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Contract ¶
type Contract struct {
// Generic sender and receiver of funds.
SenderAddr dcrutil.Address
SenderAddrStr string
SenderScriptAddr []byte
ReceiverAddr dcrutil.Address
ReceiverAddrStr string
ReceiverScriptAddr []byte
// Escrow set up by the tumbler or the client.
EscrowTx *wire.MsgTx
EscrowBytes []byte
EscrowAddr dcrutil.Address // P2SH address
EscrowAddrStr string
EscrowPayScript []byte
EscrowScript []byte
EscrowSig []byte // transaction signature (same for all)
EscrowHash []byte // published transaction hash (same for all)
// Refunding transaction used with an escrow that tumbler sets up.
RefundTx *wire.MsgTx
RefundBytes []byte
RefundAddr dcrutil.Address
RefundAddrStr string
RefundScript []byte
RefundScriptAddr []byte
RefundSig []byte
RefundHash []byte
// Fulfill the offer transaction and redeem escrowed funds.
RedeemTx *wire.MsgTx
RedeemBytes []byte
RedeemAddr dcrutil.Address
RedeemAddrStr string
RedeemScript []byte
RedeemScriptAddr []byte
RedeemSig []byte
RedeemHash []byte
Amount int64
LockTime int32
ChainParams *chaincfg.Params
}
Contract structure represents the contract associated with a client.
func New ¶
New creates a new contract template that can be either refunded by refundAddr or redeemed by redeemAddr for a specified amount and after the specified locktime.
func (*Contract) AddEscrowScript ¶
func (*Contract) AddOfferScript ¶
func (*Contract) AddRedeemScript ¶
AddRedeemScript creates a redeem script to complete the escrow script.
func (*Contract) AddRefundScript ¶
AddRefundScript creates a refund script to complete the escrow script.
func (*Contract) BuildRedeemTx ¶
func (*Contract) BuildRefundTx ¶
BuildRefundTx creates a refund transaction that spends escrowed funds.
func (*Contract) ExtractRedeemDataPushes ¶
func (*Contract) SetAddress ¶
SetAddress sets an address in the contract according to the role specified by the address type. It panics when called with an incorrect address type, otherwise address is decoded and verified to be valid in the selected network.
func (*Contract) VerifyRedeemTx ¶
func (*Contract) VerifyRefundTx ¶
VerifyRefundTx makes sure that resulting refund script executes correctly.