Documentation
¶
Index ¶
- Variables
- type BtcTx
- func (tx *BtcTx) Bytes() []byte
- func (tx *BtcTx) ClearInputs()
- func (tx *BtcTx) Dup() *BtcTx
- func (tx *BtcTx) HasWitness() bool
- func (tx *BtcTx) Hash() ([]byte, error)
- func (tx *BtcTx) MarshalBinary() ([]byte, error)
- func (tx *BtcTx) ReadFrom(r io.Reader) (int64, error)
- func (tx *BtcTx) Sign(keys ...*BtcTxSign) error
- func (tx *BtcTx) UnmarshalBinary(buf []byte) error
- type BtcTxInput
- type BtcTxOutput
- type BtcTxSign
- type BtcVarInt
- type Bytes
- type EvmTx
- func (tx *EvmTx) Hash() ([]byte, error)
- func (tx *EvmTx) MarshalBinary() ([]byte, error)
- func (tx *EvmTx) MarshalJSON() ([]byte, error)
- func (tx *EvmTx) ParseTransaction(buf []byte) error
- func (tx *EvmTx) RlpFields() []any
- func (tx *EvmTx) SenderAddress() (string, error)
- func (tx *EvmTx) SenderPubkey() (*secp256k1.PublicKey, error)
- func (tx *EvmTx) Sign(key crypto.Signer) error
- func (tx *EvmTx) SignBytes() ([]byte, error)
- func (tx *EvmTx) Signature() (*secp256k1.Signature, error)
- func (tx *EvmTx) UnmarshalBinary(buf []byte) error
- type EvmTxType
- type Format
- type IHashInfo
- type IPushBytes
- type Insertable
- type Lookup
- type Out
- type PubKeyInsert
- type PublicKeyIntf
- type Script
- type Transaction
Constants ¶
This section is empty.
Variables ¶
var ( Formats = map[string]Format{ "p2pkh": Format{Bytes{0x76, 0xa9}, IPushBytes{IHash160(IPubKeyComp)}, Bytes{0x88, 0xac}}, "p2pukh": Format{Bytes{0x76, 0xa9}, IPushBytes{IHash160(IPubKey)}, Bytes{0x88, 0xac}}, "p2pk": Format{IPushBytes{IPubKeyComp}, Bytes{0xac}}, "p2puk": Format{IPushBytes{IPubKey}, Bytes{0xac}}, "p2wpkh": Format{Bytes{0}, IPushBytes{IHash160(IPubKeyComp)}}, "p2sh:p2pkh": Format{Bytes{0xa9}, IPushBytes{IHash160(Lookup("p2pkh"))}, Bytes{0x87}}, "p2sh:p2pukh": Format{Bytes{0xa9}, IPushBytes{IHash160(Lookup("p2pukh"))}, Bytes{0x87}}, "p2sh:p2pk": Format{Bytes{0xa9}, IPushBytes{IHash160(Lookup("p2pk"))}, Bytes{0x87}}, "p2sh:p2puk": Format{Bytes{0xa9}, IPushBytes{IHash160(Lookup("p2puk"))}, Bytes{0x87}}, "p2sh:p2wpkh": Format{Bytes{0xa9}, IPushBytes{IHash160(Lookup("p2wpkh"))}, Bytes{0x87}}, "p2wsh:p2pkh": Format{Bytes{0}, IPushBytes{IHash(Lookup("p2pkh"), sha256.New)}}, "p2wsh:p2pukh": Format{Bytes{0}, IPushBytes{IHash(Lookup("p2pukh"), sha256.New)}}, "p2wsh:p2pk": Format{Bytes{0}, IPushBytes{IHash(Lookup("p2pk"), sha256.New)}}, "p2wsh:p2puk": Format{Bytes{0}, IPushBytes{IHash(Lookup("p2puk"), sha256.New)}}, "p2wsh:p2wpkh": Format{Bytes{0}, IPushBytes{IHash(Lookup("p2wpkh"), sha256.New)}}, "eth": Format{IHash(IPubKey, newEtherHash)}, } )
Functions ¶
This section is empty.
Types ¶
type BtcTx ¶ added in v0.2.1
type BtcTx struct {
Version uint32
In []*BtcTxInput
Out []*BtcTxOutput
Locktime uint32
}
func (*BtcTx) ClearInputs ¶ added in v0.2.1
func (tx *BtcTx) ClearInputs()
ClearInputs removes all the input scripts and witnesses from the transaction. Used during signing.
func (*BtcTx) HasWitness ¶ added in v0.2.1
func (*BtcTx) MarshalBinary ¶ added in v0.2.4
func (*BtcTx) UnmarshalBinary ¶ added in v0.2.4
type BtcTxInput ¶ added in v0.2.1
type BtcTxInput struct {
TXID [32]byte
Vout uint32
Script []byte
Sequence uint32
Witnesses [][]byte
}
func (*BtcTxInput) Bytes ¶ added in v0.2.1
func (in *BtcTxInput) Bytes() []byte
func (*BtcTxInput) Dup ¶ added in v0.2.1
func (in *BtcTxInput) Dup() *BtcTxInput
type BtcTxOutput ¶ added in v0.2.1
func (*BtcTxOutput) Bytes ¶ added in v0.2.1
func (out *BtcTxOutput) Bytes() []byte
func (*BtcTxOutput) Dup ¶ added in v0.2.1
func (out *BtcTxOutput) Dup() *BtcTxOutput
Dup returns a copy of the BtcTxOutput object; used for transaction signing.
type EvmTx ¶ added in v0.2.0
type EvmTx struct {
Nonce uint64
GasTipCap *big.Int // a.k.a. maxPriorityFeePerGas
GasFeeCap *big.Int // a.k.a. maxFeePerGas, correspond to GasFee if tx type is legacy or eip2930
Gas uint64 // gas of tx, can be obtained with eth_estimateGas, 21000 if Data is empty
To string
Value *big.Int
Data []byte
ChainId uint64 // in legacy tx, chainId is encoded in v before signature
Type EvmTxType // type of transaction: legacy, eip2930 or eip1559
AccessList []any // TODO
Signed bool
Y, R, S *big.Int
}
func (*EvmTx) MarshalBinary ¶ added in v0.2.4
MarshalBinary transforms the transaction into its binary representation
func (*EvmTx) MarshalJSON ¶ added in v0.2.4
func (*EvmTx) ParseTransaction ¶ added in v0.2.0
ParseTransaction will parse an incoming transaction and return an error in case of failure. In case of error, the state of tx is undefined.
func (*EvmTx) RlpFields ¶ added in v0.2.0
RlpFields returns the Rlp fields for the given transaction, less the signature fields
func (*EvmTx) SenderAddress ¶ added in v0.2.0
func (*EvmTx) SenderPubkey ¶ added in v0.2.0
func (*EvmTx) UnmarshalBinary ¶ added in v0.2.4
UnmarshalBinary implements encoding.BinaryUnmarshaler
type Format ¶ added in v0.2.0
type Format []Insertable
type IHashInfo ¶ added in v0.2.0
type IHashInfo struct {
// contains filtered or unexported fields
}
func IHash160 ¶ added in v0.2.0
func IHash160(v Insertable) IHashInfo
type IPushBytes ¶ added in v0.2.0
type IPushBytes struct {
// contains filtered or unexported fields
}
func (IPushBytes) Bytes ¶ added in v0.2.0
func (i IPushBytes) Bytes(s *Script) []byte
func (IPushBytes) String ¶ added in v0.2.0
func (i IPushBytes) String() string
type Insertable ¶ added in v0.2.0
type Out ¶ added in v0.1.2
type Out struct {
Name string `json:"name"` // p2sh, etc
Script string `json:"script"` // out script
Flags []string `json:"flags,omitempty"` // flags
// contains filtered or unexported fields
}
func GetOuts ¶ added in v0.1.2
GetOuts returns the potential outputs that can be opened in theory with the given pubkey. p2w* values are "pay to segwit" and can only be used on segwit-enabled chains.
func ParseBitcoinAddress ¶ added in v0.2.6
ParseBitcoinAddress parses an address in bitcoin format and returns the matching script, accepting also other networks addresses (in which cash a flag will be set)
func ParseEvmAddress ¶ added in v0.2.6
ParseEvmAddress parses an address to return an Out, supporting various networks.
type PubKeyInsert ¶ added in v0.2.0
type PubKeyInsert int
const ( IPubKeyComp PubKeyInsert = iota IPubKey )
func (PubKeyInsert) Bytes ¶ added in v0.2.0
func (pk PubKeyInsert) Bytes(s *Script) []byte
func (PubKeyInsert) String ¶ added in v0.2.0
func (pk PubKeyInsert) String() string
type PublicKeyIntf ¶ added in v0.2.1
PublicKeyIntf is the interface we need public keys to implement in order to work. Using an interface type allows us to work with many different implementations of secp256k1.
type Script ¶ added in v0.2.0
type Script struct {
// contains filtered or unexported fields
}
func New ¶ added in v0.2.0
func New(pubkey PublicKeyIntf) *Script
New returns a new Script object for the given public key, which can be used to generate output scripts
type Transaction ¶ added in v0.2.4
type Transaction interface {
encoding.BinaryMarshaler
encoding.BinaryUnmarshaler
Hash() ([]byte, error)
}