Documentation
¶
Index ¶
- Constants
- Variables
- func Base58Decode(str string) ([]byte, error)
- func Base58DecodeCheck(str string) ([]byte, error)
- func Base58Encode(bytes []byte) string
- func Base58EncodeCheck(bytes []byte) string
- func Base58VerifyChecksum(bytes []byte, str string) error
- func ClassifyScript(script []byte) (ScriptType, ScriptHashOrData)
- func DecodeECPrivKeyWIF(str string, chain *ChainParams) (ec_priv_key ECPrivKey, out_chain *ChainParams, err error)
- func DecodeOP_N(op byte) int
- func DecodePushOP(script []byte, ofs int) (newOfs int, length uint32, ok bool)
- func ECKeyIsValid(pk ECPrivKey) bool
- func ECPrivKeyFromBip32WIF(ext_key_wif string, chain *ChainParams) (ec_privkey_wif string, err error)
- func EncodeBip32WIF(key *Bip32Key) string
- func EncodeECPrivKeyUncompressedWIF(key ECPrivKey, chain *ChainParams) string
- func EncodeECPrivKeyWIF(key ECPrivKey, chain *ChainParams) string
- func EncodeTx(tx BlockTx) ([]byte, error)
- func ExpandScript(typ ScriptType, data ScriptHashOrData) (script []byte)
- func Hash160(bytes []byte) []byte
- func HexDecode(str string) ([]byte, error)
- func HexDecodeReversed(str string) ([]byte, error)
- func HexEncode(bytes []byte) string
- func HexEncodeReversed(data []byte) string
- func IsOP_N(op byte) bool
- func IsValidHex(hex string) bool
- func P2PKHScript(pubKeyHash []byte) ([]byte, error)
- func P2PKHScriptFromAddress(address Address) ([]byte, error)
- func P2SHScript(scriptHash []byte) ([]byte, error)
- func P2SHScriptFromRedeemScript(redeemScript []byte) ([]byte, error)
- func RIPEMD160(bytes []byte) []byte
- func TxHashHex(txBytes []byte) string
- func TxHashToHex(hash []byte) string
- func ValidateP2PKH(address Address, chain *ChainParams) bool
- func ValidateP2SH(address Address, chain *ChainParams) bool
- func VerifyMessage(pubKey ECPubKeySchnorr, msg []byte, sig SchnorrSignature) bool
- type Address
- type Bip32Key
- func (key *Bip32Key) ChainParams() *ChainParams
- func (key *Bip32Key) ChildNumber() uint32
- func (key *Bip32Key) Clear()
- func (key *Bip32Key) DeriveChild(path []uint32, useSLIP10 bool) (*Bip32Key, error)
- func (key *Bip32Key) EncodeWIF() string
- func (key *Bip32Key) GetECPrivKey() (ECPrivKey, error)
- func (key *Bip32Key) GetECPubKey() ECPubKeyCompressed
- func (key *Bip32Key) IsPrivate() bool
- func (key *Bip32Key) ParentFingerprint() uint32
- func (key *Bip32Key) PrivateCKD(path []uint32, useSLIP10 bool) (*Bip32Key, error)
- func (key *Bip32Key) Public() *Bip32Key
- func (key *Bip32Key) PublicCKD(path []uint32, useSLIP10 bool) (*Bip32Key, error)
- func (key *Bip32Key) ThisKeyFingerprint() uint32
- type Block
- type BlockHeader
- type BlockTx
- type BlockTxIn
- type BlockTxOut
- type ChainParams
- func ChainFromBip32Version(version uint32, allowNonDoge bool) (bool, *ChainParams)
- func ChainFromGenesisHash(hash string) (*ChainParams, error)
- func ChainFromTestNetFlag(isTestNet bool) *ChainParams
- func ChainFromWIFPrefix(bytes []byte, allowNonDoge bool) *ChainParams
- func ChainFromWIFString(wif string) *ChainParams
- type Decoder
- func (d *Decoder) Bool() bool
- func (d *Decoder) Bytes(num int) []byte
- func (d *Decoder) Complete() bool
- func (d *Decoder) Error(to any) error
- func (d *Decoder) Has(n int) bool
- func (d *Decoder) Int64() int64
- func (d *Decoder) PadString(size int) string
- func (d *Decoder) Rest() []byte
- func (d *Decoder) Tag4CC() Tag4CC
- func (d *Decoder) UInt8() uint8
- func (d *Decoder) UInt16() uint16
- func (d *Decoder) UInt32() uint32
- func (d *Decoder) UInt64() uint64
- func (d *Decoder) Valid() bool
- func (d *Decoder) VarString() string
- func (d *Decoder) VarUInt() uint64
- type ECPrivKey
- type ECPubKeyCompressed
- type ECPubKeySchnorr
- type ECPubKeyUncompressed
- type Encoder
- func (e *Encoder) Bool(b bool)
- func (e *Encoder) Bytes(b []byte)
- func (e *Encoder) Int64(v int64)
- func (e *Encoder) PadString(size uint64, v string) bool
- func (e *Encoder) Result() []byte
- func (e *Encoder) Tag4CC(v Tag4CC)
- func (e *Encoder) UInt8(v uint8)
- func (e *Encoder) UInt16(v uint16)
- func (e *Encoder) UInt32(v uint32)
- func (e *Encoder) UInt64(v uint64)
- func (e *Encoder) VarString(v string)
- func (e *Encoder) VarUInt(val uint64)
- type Hash256
- type HashID
- type KeyType
- type MerkleBranch
- type MerkleTx
- type SchnorrSignature
- type ScriptHashOrData
- type ScriptType
- type Stream
- type Tag4CC
Constants ¶
const ( SerializedBip32KeyLength = 4 + 1 + 4 + 4 + 32 + 33 HardenedKey = 0x80000000 )
const ( VersionAuxPoW = 256 CoinbaseVOut = 0xffffffff MaxScriptSize = 10_000 // MAX_SCRIPT_SIZE from Dogecoin Core (script.h) MaxVarIntSize = 0x02000000 // MAX_SIZE from Dogecoin Core (serialize.h) )
const ( ECPrivKeyLen = 32 // bytes. ECPubKeyCompressedLen = 33 // bytes: [x02/x03][32-X] 2=even 3=odd ECPubKeyUncompressedLen = 65 // bytes: [x04][32-X][32-Y] )
const ( OP_0 = 0x00 // push empty array OP_FALSE = 0x00 // alias // 0x01..0x4b push data of `opcode` length (1-75) OP_PUSHDATA1 = 0x4c // 1-byte length, push data OP_PUSHDATA2 = 0x4d // 2-byte length, push data OP_PUSHDATA4 = 0x4e // 4-byte length, push data OP_1NEGATE = 0x4f // push #-1 OP_RESERVED = 0x50 OP_1 = 0x51 // push #1 OP_TRUE = 0x51 // alias OP_2 = 0x52 OP_3 = 0x53 OP_4 = 0x54 OP_5 = 0x55 OP_6 = 0x56 OP_7 = 0x57 OP_8 = 0x58 OP_9 = 0x59 OP_10 = 0x5a OP_11 = 0x5b OP_12 = 0x5c OP_13 = 0x5d OP_14 = 0x5e OP_15 = 0x5f OP_16 = 0x60 OP_NOP = 0x61 OP_VER = 0x62 OP_IF = 0x63 OF_NOTIF = 0x64 OP_VERIF = 0x65 OP_VERNOTIF = 0x66 OP_ELSE = 0x67 OP_ENDIF = 0x68 OP_VERIFY = 0x69 OP_RETURN = 0x6a OP_TOALTSTACK = 0x6b OP_FROMALTSTACK = 0x6c OP_IFDUP = 0x73 OP_DEPTH = 0x74 OP_DROP = 0x75 OP_DUP = 0x76 OP_NIP = 0x77 OP_OVER = 0x78 OP_PICK = 0x79 OP_ROLL = 0x7a OP_ROT = 0x7b OP_SWAP = 0x7c OP_TUCK = 0x7d OP_2DROP = 0x6d OP_2DUP = 0x6e OP_3DUP = 0x6f OP_2OVER = 0x70 OP_2ROT = 0x71 OP_2SWAP = 0x72 OP_CAT = 0x7e OP_SUBSTR = 0x7 OP_LEFT = 0x80 OP_RIGHT = 0x81 OP_SIZE = 0x82 OP_INVERT = 0x83 OP_AND = 0x84 OP_OR = 0x85 OP_XOR = 0x86 OP_EQUAL = 0x87 OP_EQUALVERIFY = 0x88 OP_RESERVED1 = 0x89 OP_RESERVED2 = 0x8a OP_1ADD = 0x8b OP_1SUB = 0x8c OP_2MUL = 0x8d OP_2DIV = 0x8e OP_NEGATE = 0x8f OP_ABS = 0x90 OP_NOT = 0x91 OP_0NOTEQUAL = 0x92 OP_ADD = 0x93 OP_SUB = 0x94 OP_MUL = 0x95 OP_DIV = 0x96 OP_MOD = 0x97 OP_LSHIFT = 0x98 OP_RSHIFT = 0x99 OP_BOOLAND = 0x9a OP_BOOLOR = 0x9b OP_NUMEQUAL = 0x9c OP_NUMEQUALVERIFY = 0x9d OP_NUMNOTEQUAL = 0x9e OP_LESSTHAN = 0x9f OP_GREATERTHAN = 0xa0 OP_LESSTHANOREQUAL = 0xa1 OP_GREATERTHANOREQUAL = 0xa2 OP_MIN = 0xa3 OP_MAX = 0xa4 OP_WITHIN = 0xa5 OP_RIPEMD160 = 0xa6 OP_SHA1 = 0xa7 OP_SHA256 = 0xa8 OP_HASH160 = 0xa9 OP_HASH256 = 0xaa OP_CODESEPARATOR = 0xab OP_CHECKSIG = 0xac OP_CHECKSIGVERIFY = 0xad OP_CHECKMULTISIG = 0xae OP_CHECKMULTISIGVERIFY = 0xaf OP_NOP1 = 0xb0 OP_CHECKLOCKTIMEVERIFY = 0xb1 OP_CHECKSEQUENCEVERIFY = 0xb2 OP_NOP4 = 0xb3 OP_NOP5 = 0xb4 OP_NOP6 = 0xb5 OP_NOP7 = 0xb6 OP_NOP8 = 0xb7 OP_NOP9 = 0xb8 OP_NOP10 = 0xb9 OP_CHECKSIGADD = 0xba )
source: https://en.bitcoin.it/wiki/Script
const MAX_OP_RETURN_RELAY = 83 // from Core IsStandard in policy.cpp
const (
OneDoge = int64(100_000_000) // in Koinu
)
Variables ¶
var CoinbaseTxID = [32]byte{}
var ErrAnotherSeed = errors.New("cannot derive a valid master key from this seed (generate another seed)")
var ErrBadSeed = errors.New("bad seed: must be 16-64 bytes")
var ErrCannotDerive = errors.New("cannot derive private key from public key")
var ErrHardened = errors.New("cannot derive a public key from a hardened parent key")
var ErrInvalidPrivateKey = errors.New("invalid private key")
var ErrNextIndex = errors.New("cannot derive a valid child key at this key index (try the next index)")
var ErrTooDeep = errors.New("key derivation path is too long (more than 255)")
Functions ¶
func Base58Decode ¶
func Base58DecodeCheck ¶
func Base58Encode ¶
func Base58EncodeCheck ¶
CAUTION: appends the Checksum to `bytes` if it has sufficient capacity (4 bytes)
func Base58VerifyChecksum ¶
func ClassifyScript ¶
func ClassifyScript(script []byte) (ScriptType, ScriptHashOrData)
ClassifyScript infers ScriptType from a script by pattern-matching the bytecode Returns the PubKeyHash/ScriptHash/PubKey/Data extracted from the script
func DecodeECPrivKeyWIF ¶
func DecodeECPrivKeyWIF(str string, chain *ChainParams) (ec_priv_key ECPrivKey, out_chain *ChainParams, err error)
chain is optional, will auto-detect if nil.
func DecodeOP_N ¶ added in v0.1.0
decodeOP_N decodes the pushed literal from OP_1 to OP_16
func DecodePushOP ¶ added in v0.1.0
DecodePushOP decodes the 'length' from OP_0, OP_1 to OP_16, OP_PUSHDATA1,2,4
func ECKeyIsValid ¶
func ECPrivKeyFromBip32WIF ¶
func ECPrivKeyFromBip32WIF(ext_key_wif string, chain *ChainParams) (ec_privkey_wif string, err error)
Given a Bip32 Extended Private Key WIF, extract the WIF-encoded EC Private Key. chain is optional, will auto-detect if nil.
func EncodeBip32WIF ¶
EncodeBip32WIF encodes a Bip32Key in WIF format (dgpv,dgub)
func EncodeECPrivKeyUncompressedWIF ¶
func EncodeECPrivKeyUncompressedWIF(key ECPrivKey, chain *ChainParams) string
func EncodeECPrivKeyWIF ¶
func EncodeECPrivKeyWIF(key ECPrivKey, chain *ChainParams) string
func EncodeTx ¶ added in v0.1.6
EncodeTx encodes a transaction to a byte slice. This function does not fail (Go panics if out of memory).
func ExpandScript ¶ added in v0.1.0
func ExpandScript(typ ScriptType, data ScriptHashOrData) (script []byte)
ExpandScript re-creates the ScriptPubKey from a ScriptType and ScriptHashOrData
func HexDecodeReversed ¶ added in v0.1.4
func HexEncodeReversed ¶
func IsValidHex ¶
func P2PKHScript ¶ added in v0.1.7
P2PKHScript creates a P2PKH script from a pubKeyHash. Returns the script or an error if the pubKeyHash length is invalid.
func P2PKHScriptFromAddress ¶ added in v0.1.7
P2PKHScriptFromAddress creates a P2PKH script from a Dogecoin address. Returns the script or an error if the address is invalid.
func P2SHScript ¶ added in v0.1.7
P2SHScript creates a P2SH script from a redeem script hash. Returns the script or an error if the hash length is invalid.
func P2SHScriptFromRedeemScript ¶ added in v0.1.7
P2SHScriptFromRedeemScript creates a P2SH script from a redeem script. Returns the script or an error if the redeem script length is invalid.
func TxHashToHex ¶ added in v0.0.15
TxHashToHex returns the hex-string of a transaction hash.
func ValidateP2PKH ¶
func ValidateP2PKH(address Address, chain *ChainParams) bool
func ValidateP2SH ¶
func ValidateP2SH(address Address, chain *ChainParams) bool
func VerifyMessage ¶ added in v0.0.10
func VerifyMessage(pubKey ECPubKeySchnorr, msg []byte, sig SchnorrSignature) bool
VerifyMessage verifies an arbitrary message with a public key and signature; the signature and public key are also validated, i.e. all parameters can be untrusted data.
Types ¶
type Address ¶
type Address string // Dogecoin address (base-58 Public Key Hash aka PKH)
func Hash160toAddress ¶
func P2PKHFromECPrivKeyWIF ¶
func PubKeyToP2PKH ¶
func PubKeyToP2PKH(key []byte, chain *ChainParams) (Address, error)
PubKeyToP2PKH converst an ECPubKeyCompressed or ECPubKeyUncompressed to a Dogecoin P2PKH Address.
func ScriptToP2SH ¶
func ScriptToP2SH(redeemScript []byte, chain *ChainParams) Address
type Bip32Key ¶
type Bip32Key struct {
// contains filtered or unexported fields
}
https://en.bitcoin.it/wiki/BIP_0032
func Bip32MasterFromSeed ¶ added in v0.0.5
func Bip32MasterFromSeed(seed []byte, chain *ChainParams) (*Bip32Key, error)
Bip32MasterFromSeed derives the Bip32 master key from an entropy seed. Note: bip39.SeedFromMnemonic generates an appropriate seed (also GenerateRandomMnemonic)
func DecodeBip32WIF ¶
func DecodeBip32WIF(extendedKey string, chain *ChainParams) (*Bip32Key, error)
DecodeBip32WIF decodes a WIF-encoded Bip32Key (dgpv,dgub) chain is optional, will auto-detect if nil.
func (*Bip32Key) ChainParams ¶ added in v0.0.5
func (key *Bip32Key) ChainParams() *ChainParams
ChainParams returns the chain this key belongs to.
func (*Bip32Key) ChildNumber ¶ added in v0.1.8
ChildNumber returns the child number of this key. ser32(i) for i in xi = xpar/i, with xi the key being serialized. (0x00000000 if master key)
func (*Bip32Key) DeriveChild ¶ added in v0.0.5
DeriveChild derives a child key according to BIP-32. Path is a list of child key indexes. If an index is >= HardenedKey, the derived key will be hardened. For a Private Bip32Key we use PrivateCKD on each path element; for a Public key we use PublicCKD.
func (*Bip32Key) EncodeWIF ¶ added in v0.0.8
EncodeWIF encodes this key in Bip32 WIF format (dgpv,dgub)
func (*Bip32Key) GetECPrivKey ¶
GetECPrivKey gets a copy of the underlying private key.
func (*Bip32Key) GetECPubKey ¶
func (key *Bip32Key) GetECPubKey() ECPubKeyCompressed
GetECPrivKey gets a copy of the underlying public key.
func (*Bip32Key) IsPrivate ¶ added in v0.0.5
IsPrivate is true if the Bip32Key holds a Private key (otherwise it holds the corresponding Public key)
func (*Bip32Key) ParentFingerprint ¶ added in v0.0.5
ParentFingerprint is the fingerprint for the parent's public key. This is the fingerprint stored in the Bip32 Serialization Format (EncodeBip32WIF)
func (*Bip32Key) PrivateCKD ¶ added in v0.0.5
func (*Bip32Key) Public ¶ added in v0.0.5
Public returns the Public Bip32Key corresponding to a Private Bip32Key. If key is already a Public Bip32Key, the same *Bip32Key is returned.
func (*Bip32Key) ThisKeyFingerprint ¶ added in v0.0.5
ThisKeyFingerprint is the fingerprint for this key's public key. NOTE: this is not the ParentFingerprint() sored in Bip23 WIF format! This is primarily included for tests.
type Block ¶
type Block struct {
Header BlockHeader
AuxPoW *MerkleTx // if IsAuxPoW()
Tx []BlockTx
}
func DecodeBlock ¶
DecodeBlock decodes a block from a byte slice (original API) If calcHash is true, the block hash is calculated and stored in the Block.BlockID field. Returns false if the serialized block data is malformed.
func DecodeBlockErr ¶ added in v0.1.9
DecodeBlockErr decodes a block from a byte slice (enhanced API) If calcHash is true, the block hash is calculated and stored in the Block.BlockID field. Returns an error if the serialized block data is malformed.
type BlockHeader ¶
type BlockHeader struct {
Version uint32
PrevBlock []byte // 32 bytes
MerkleRoot []byte // 32 bytes
Timestamp uint32
Bits uint32
Nonce uint32
BlockID HashID // Block Hash (if decoded with calcHash=True)
}
func (*BlockHeader) IsAuxPoW ¶
func (b *BlockHeader) IsAuxPoW() bool
type BlockTx ¶
type BlockTx struct {
Version uint32
VIn []BlockTxIn
VOut []BlockTxOut
LockTime uint32
TxID HashID // Transaction Hash (if decoded with calcHash=True)
}
func DecodeTx ¶
DecodeTx decodes a transaction from a byte slice (original API) If calcHash is true, the transaction hash is calculated and stored in the BlockTx.TxID field. Returns false if the serialized tx data is malformed.
func DecodeTxErr ¶ added in v0.1.9
DecodeTxErr decodes a transaction from a byte slice (enhanced API) If calcHash is true, the transaction hash is calculated and stored in the BlockTx.TxID field. Returns an error if the serialized transaction data is malformed.
type BlockTxOut ¶
type ChainParams ¶
type ChainParams struct {
ChainName string
GenesisBlock string
P2PKH_Address_Prefix byte
P2SH_Address_Prefix byte
PKey_Prefix byte
Bip32_PrivKey_Prefix uint32
Bip32_PubKey_Prefix uint32
Bip32_WIF_PrivKey_Prefix string
Bip32_WIF_PubKey_Prefix string
}
var BitcoinMainChain ChainParams = ChainParams{
ChainName: "btc_main",
GenesisBlock: "000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f",
P2PKH_Address_Prefix: 0x00,
P2SH_Address_Prefix: 0x05,
PKey_Prefix: 0x80,
Bip32_PrivKey_Prefix: 0x0488ADE4,
Bip32_PubKey_Prefix: 0x0488B21E,
Bip32_WIF_PrivKey_Prefix: "xxxx",
Bip32_WIF_PubKey_Prefix: "xxxx",
}
Used in tests only.
var BitcoinTestChain ChainParams = ChainParams{
ChainName: "btc_test",
GenesisBlock: "000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f",
P2PKH_Address_Prefix: 0x00,
P2SH_Address_Prefix: 0x05,
PKey_Prefix: 0x80,
Bip32_PrivKey_Prefix: 0x0488ADE4,
Bip32_PubKey_Prefix: 0x0488B21E,
Bip32_WIF_PrivKey_Prefix: "xxxx",
Bip32_WIF_PubKey_Prefix: "xxxx",
}
Used in tests only.
var DogeMainNetChain ChainParams = ChainParams{
ChainName: "doge_main",
GenesisBlock: "1a91e3dace36e2be3bf030a65679fe821aa1d6ef92e7c9902eb318182c355691",
P2PKH_Address_Prefix: 0x1e,
P2SH_Address_Prefix: 0x16,
PKey_Prefix: 0x9e,
Bip32_PrivKey_Prefix: 0x02fac398,
Bip32_PubKey_Prefix: 0x02facafd,
Bip32_WIF_PrivKey_Prefix: "dgpv",
Bip32_WIF_PubKey_Prefix: "dgub",
}
var DogeRegTestChain ChainParams = ChainParams{
ChainName: "doge_regtest",
GenesisBlock: "3d2160a3b5dc4a9d62e7e66a295f70313ac808440ef7400d6c0772171ce973a5",
P2PKH_Address_Prefix: 0x6f,
P2SH_Address_Prefix: 0xc4,
PKey_Prefix: 0xef,
Bip32_PrivKey_Prefix: 0x04358394,
Bip32_PubKey_Prefix: 0x043587cf,
Bip32_WIF_PrivKey_Prefix: "tprv",
Bip32_WIF_PubKey_Prefix: "tpub",
}
var DogeTestNetChain ChainParams = ChainParams{
ChainName: "doge_test",
GenesisBlock: "bb0a78264637406b6360aad926284d544d7049f45189db5664f3c4d07350559e",
P2PKH_Address_Prefix: 0x71,
P2SH_Address_Prefix: 0xc4,
PKey_Prefix: 0xf1,
Bip32_PrivKey_Prefix: 0x04358394,
Bip32_PubKey_Prefix: 0x043587cf,
Bip32_WIF_PrivKey_Prefix: "tprv",
Bip32_WIF_PubKey_Prefix: "tpub",
}
func ChainFromBip32Version ¶
func ChainFromBip32Version(version uint32, allowNonDoge bool) (bool, *ChainParams)
func ChainFromGenesisHash ¶
func ChainFromGenesisHash(hash string) (*ChainParams, error)
func ChainFromTestNetFlag ¶
func ChainFromTestNetFlag(isTestNet bool) *ChainParams
func ChainFromWIFPrefix ¶
func ChainFromWIFPrefix(bytes []byte, allowNonDoge bool) *ChainParams
CAUTION: the result is a best-guess based on the 'version byte' in the decoded WIF data. Do not rely on the returned ChainParams alone for validation: it will fall back on DogeTestNetChain for unknown version bytes (so verify the version byte or bip32-prefix as well)
func ChainFromWIFString ¶
func ChainFromWIFString(wif string) *ChainParams
CAUTION: the result is a best-guess based on the 'version byte' in the WIF string. Do not rely on the returned ChainParams alone for validation: it will fall back on DogeTestNetChain for unknown version bytes (so verify the version byte or bip32-prefix as well)
type Decoder ¶ added in v0.1.5
type Decoder struct {
// contains filtered or unexported fields
}
Decoder is a helper for decoding data from a byte slice. All numbers are assumed to be encoded little-endian.
func (*Decoder) Bytes ¶ added in v0.1.5
Bytes reads n bytes from the buffer and advances the position.
func (*Decoder) Complete ¶ added in v0.1.5
Complete returns true if all the data has been read; implies Valid()
func (*Decoder) Error ¶ added in v0.1.5
Error returns nil if Complete(), or an error describing the wrong encoded size. `to` should be the struct (or interface) being parsed into, for error reporting.
func (*Decoder) Has ¶ added in v0.1.5
Has checks if there are at least n bytes remaining in the buffer.
func (*Decoder) Int64 ¶ added in v0.1.5
Int64le reads a signed 64-bit integer from the buffer in little-endian order.
func (*Decoder) PadString ¶ added in v0.1.5
PadString reads a fixed-length padded string from the buffer, trimming trailing null bytes.
func (*Decoder) UInt16 ¶ added in v0.1.5
UInt16le reads an unsigned 16-bit integer from the buffer in little-endian order.
func (*Decoder) UInt32 ¶ added in v0.1.5
UInt32le reads an unsigned 32-bit integer from the buffer in little-endian order.
func (*Decoder) UInt64 ¶ added in v0.1.5
UInt64le reads an unsigned 64-bit integer from the buffer in little-endian order.
func (*Decoder) Valid ¶ added in v0.1.5
Valid returns true if all reads have succeeded without reading past the end of the data.
type ECPrivKey ¶
type ECPrivKey = *[32]byte // 32 byte big-endian uint256; 0 < pk < n in secp256k1.
func GenerateECPrivKey ¶
type ECPubKeyCompressed ¶
type ECPubKeyCompressed = *[33]byte // 33 bytes with 0x02 or 0x03 prefix.
func ECPubKeyFromECPrivKey ¶
func ECPubKeyFromECPrivKey(pk ECPrivKey) ECPubKeyCompressed
type ECPubKeySchnorr ¶ added in v0.0.10
type ECPubKeySchnorr = *[32]byte // 32 byte X-coordinate-only public key, encoded as a big-endian uint256
type ECPubKeyUncompressed ¶
type ECPubKeyUncompressed = *[65]byte // 65 bytes with 0x04 prefix.
type Encoder ¶ added in v0.1.5
type Encoder struct {
// contains filtered or unexported fields
}
Encoder is a helper for encoding data to a byte slice. All numbers are encoded little-endian.
func Encode ¶ added in v0.1.5
Encode creates a new Encoder for a given size. The underlying buffer will grow as necessary.
func (*Encoder) Bytes ¶ added in v0.1.5
Encode a slice of bytes. No length is encoded: use VarUInt to prefix with a (non-fixed) length.
func (*Encoder) PadString ¶ added in v0.1.5
Encodes a string padded to a fixed-size field with zero bytes. If the string is too long to fit, it is truncated. Returns true if the string fits, false if it was truncated.
func (*Encoder) Tag4CC ¶ added in v0.1.5
Tag4CC encodes a Four Character Code TAG in big-endian order, to preserve the order of the ASCII characters in the stream.
func (*Encoder) VarUInt ¶ added in v0.1.5
Encode an unsigned integer of varying length: A single byte up to 0xFC (252) 0xFD + encoded 16-bit number, up to 0xFFFF (65536) 0xFE + encoded 32-bit number, up to 0xFFFFFFFF (4294967295) 0xFF + encoded 64-bit number, up to 0xFFFFFFFFFFFFFFFF (18446744073709551615) This encoding was borrowed from Bitcoin.
type KeyType ¶ added in v0.0.5
type KeyType = int // keyECPriv,keyECPub,keyBip32Priv,keyBip32Pub,dogeMainNet,dogeTestNet
type MerkleBranch ¶
type MerkleTx ¶
type MerkleTx struct {
CoinbaseTx BlockTx
ParentHash []byte // 32 bytes
CoinbaseBranch MerkleBranch
BlockchainBranch MerkleBranch
ParentBlock BlockHeader
}
type SchnorrSignature ¶ added in v0.0.10
type SchnorrSignature = *[64]byte // 64 byte signature, encoding (R.x, s) as big-endian uint256
func SignMessage ¶ added in v0.0.10
func SignMessage(privKey ECPrivKey, msg []byte) (SchnorrSignature, error)
SignMessage signs an arbitrary message with a private key. Returns an error if the private key is invalid.
type ScriptHashOrData ¶ added in v0.1.0
type ScriptHashOrData = []byte
ScriptHashOrData is the PubKeyHash, ScriptHash, PubKey, MultiSig PubKeys, or OP_RETURN data extracted from the script by ClassifyScript
type ScriptType ¶
type ScriptType byte
ScriptType is inferred from the script by pattern-matching the bytecode
const ( ScriptTypeNone ScriptType = 0 // No Script (reserved) ScriptTypeP2PK ScriptType = 1 // TX_PUBKEY (in Core) ScriptTypeP2PKH ScriptType = 2 // TX_PUBKEYHASH ScriptTypeP2SH ScriptType = 3 // TX_SCRIPTHASH ScriptTypeMultiSig ScriptType = 4 // TX_MULTISIG ScriptTypeP2PKHW ScriptType = 5 // TX_WITNESS_V0_KEYHASH ScriptTypeP2SHW ScriptType = 6 // TX_WITNESS_V0_SCRIPTHASH ScriptTypeNullData ScriptType = 7 // TX_NULL_DATA ScriptTypeNonStandard ScriptType = 8 // TX_NONSTANDARD )
ScriptType constants (must fit in a single byte for compact storage)
type Stream ¶
type Stream struct {
// contains filtered or unexported fields
}
Stream is a stream of bytes with read methods. DEPRECATED - use `Decoder` instead.
func (*Stream) Complete ¶ added in v0.0.13
Complete returns true if all the data has been read; implies Valid()
func (*Stream) Uint16le ¶ added in v0.0.13
Uint16le reads a 16-bit unsigned integer from the stream in little-endian order.
func (*Stream) Uint32le ¶ added in v0.0.13
Uint32le reads a 32-bit unsigned integer from the stream in little-endian order.
func (*Stream) Uint64le ¶ added in v0.0.13
Uint64le reads a 64-bit unsigned integer from the stream in little-endian order.