Documentation ¶
Index ¶
- Constants
- func AddressToScript(addr string, p2pkhPrefix, p2shPrefix []byte, segwitEnabled bool) ([]byte, error)
- func CalculateTxID(tx string) string
- func CompileCoinbaseScript(blockHeight int32, extraNonce uint64) []byte
- func CompileP2PK(serializedPubKey []byte) []byte
- func CompileP2PKH(pubKeyHash []byte) []byte
- func CompileP2SH(scriptHash []byte) []byte
- func CompileP2TR(scriptHash []byte) []byte
- func CompileP2WPKH(pubKeyHash []byte) []byte
- func CompileP2WSH(scriptHash []byte) []byte
- func EncodeOpCode(opCode int) []byte
- func EncodeScriptData(data []byte) []byte
- func GenerateScriptSig(sig []byte, pub []byte) []byte
- func GenerateTx(privKey *secp256k1.PrivateKey, baseTx *Transaction, inputs []*types.TxInput, ...) ([]byte, error)
- func PrivKeyToAddress(privKey *secp256k1.PrivateKey, version []byte) string
- type Transaction
- func GenerateRawTx(baseTx *Transaction, inputs []*types.TxInput, outputs []*types.TxOutput, ...) (*Transaction, error)
- func GenerateSignedTx(privKey *secp256k1.PrivateKey, baseTx *Transaction, inputs []*types.TxInput, ...) (*Transaction, error)
- func NewTransaction(version, lockTime uint32, prefixP2PKH, prefixP2SH []byte, segwitEnabled bool) *Transaction
- func (tx *Transaction) AddInput(hash string, index, sequence uint32, script []byte) error
- func (tx *Transaction) AddOutput(script []byte, value uint64)
- func (tx *Transaction) CalculateScriptSig(index uint32, script []byte) ([]byte, error)
- func (tx *Transaction) Serialize(extraPayload []byte) ([]byte, error)
- func (tx *Transaction) SetExpiryHeight(expiryHeight uint32)
- func (tx *Transaction) SetVersionGroupID(versionGroupID uint32)
- func (tx *Transaction) SetVersionMask(versionMask uint32)
- func (tx *Transaction) ShallowCopy() *Transaction
Constants ¶
View Source
const ( // opcodes OP_0 = 0x00 OP_DATA_1 = 0x01 OP_DATA_20 = 0x14 OP_DATA_21 = 0x15 OP_DATA_32 = 0x20 OP_DATA_33 = 0x21 OP_PUSHDATA1 = 0x4c OP_PUSHDATA2 = 0x4d OP_PUSHDATA4 = 0x4e OP_1 = 0x51 OP_DUP = 0x76 OP_EQUAL = 0x87 OP_EQUALVERIFY = 0x88 OP_HASH160 = 0xa9 OP_CHECKSIG = 0xac // tx flags TxFlagMarker = 0x00 WitnessFlag = 0x01 SIGHASH_ALL = 0x1 SIGHASH_NONE = 0x2 SIGHASH_SINGLE = 0x3 SIGHASH_ANYONECANPAY = 0x80 )
Variables ¶
This section is empty.
Functions ¶
func AddressToScript ¶
func CalculateTxID ¶
func CompileCoinbaseScript ¶
func CompileP2PK ¶
func CompileP2PKH ¶
func CompileP2SH ¶
func CompileP2TR ¶
func CompileP2WPKH ¶
func CompileP2WSH ¶
func EncodeOpCode ¶
func EncodeScriptData ¶
func GenerateScriptSig ¶
func GenerateTx ¶
func PrivKeyToAddress ¶
Types ¶
type Transaction ¶
type Transaction struct { PrefixP2PKH []byte PrefixP2SH []byte SegwitEnabled bool Version uint32 VersionGroupID *uint32 LockTime uint32 ExpiryHeight *uint32 Inputs []*input Outputs []*output }
func GenerateRawTx ¶
func GenerateRawTx( baseTx *Transaction, inputs []*types.TxInput, outputs []*types.TxOutput, fee uint64, ) (*Transaction, error)
func GenerateSignedTx ¶
func GenerateSignedTx( privKey *secp256k1.PrivateKey, baseTx *Transaction, inputs []*types.TxInput, outputs []*types.TxOutput, fee uint64, ) (*Transaction, error)
func NewTransaction ¶
func NewTransaction( version, lockTime uint32, prefixP2PKH, prefixP2SH []byte, segwitEnabled bool, ) *Transaction
func (*Transaction) AddInput ¶
func (tx *Transaction) AddInput(hash string, index, sequence uint32, script []byte) error
func (*Transaction) AddOutput ¶
func (tx *Transaction) AddOutput(script []byte, value uint64)
func (*Transaction) CalculateScriptSig ¶
func (tx *Transaction) CalculateScriptSig(index uint32, script []byte) ([]byte, error)
func (*Transaction) Serialize ¶
func (tx *Transaction) Serialize(extraPayload []byte) ([]byte, error)
func (*Transaction) SetExpiryHeight ¶
func (tx *Transaction) SetExpiryHeight(expiryHeight uint32)
func (*Transaction) SetVersionGroupID ¶
func (tx *Transaction) SetVersionGroupID(versionGroupID uint32)
func (*Transaction) SetVersionMask ¶
func (tx *Transaction) SetVersionMask(versionMask uint32)
func (*Transaction) ShallowCopy ¶
func (tx *Transaction) ShallowCopy() *Transaction
Click to show internal directories.
Click to hide internal directories.