Documentation ¶
Index ¶
- Constants
- Variables
- func Bech32Decode(address string) ([]byte, error)
- func Bech32Encode(prefix, alphabet string, payload []byte) string
- func CreateEmptyAssetRawTransaction(vins []Vin, to AssetTransfer, change Vout, lockTime uint32, replaceable bool, ...) (string, error)
- func CreateEmptyRawTransaction(vins []Vin, vouts []Vout, lockTime uint32, replaceable bool, ...) (string, error)
- func CreateMultiSig(required byte, pubkeys [][]byte, SegwitON bool, addressPrefix AddressPrefix) (string, string, error)
- func Decode(input string, alphabet *Alphabet) ([]byte, error)
- func DecodeCheck(address string) ([]byte, []byte, error)
- func Encode(input []byte, alphabet *Alphabet) string
- func EncodeCheck(prefix []byte, hash []byte) string
- func InsertSignatureIntoEmptyTransaction(txHex string, txHashes []TxHash, unlockData []TxUnlock, SegwitON bool) (string, error)
- func VerifyRawTransaction(txHex string, unlockData []TxUnlock, SegwitON bool, ...) bool
- type AddressPrefix
- type Alphabet
- type AssetTransfer
- type MultiTx
- type NormalTx
- type SignaturePubkey
- type Transaction
- type TxHash
- type TxIn
- type TxOut
- type TxUnlock
- type Vin
- type Vout
Constants ¶
View Source
const ( TypeEmpty = 0 TypeP2PKH = 1 TypeP2WPKH = 2 TypeBech32 = 3 TypeMultiSig = 4 )
View Source
const ( DefaultTxVersion = uint32(1) DefaultHashType = uint32(1) MaxScriptElementSize = 520 AssetTransferSign = "spkq" )
View Source
const ( SequenceFinal = uint32(0xFFFFFFFF) SequenceMaxBip125RBF = uint32(0xFFFFFFFD) )
View Source
const ( SegWitSymbol = byte(0) SegWitVersion = byte(1) SigHashAll = byte(1) )
View Source
const ( OpCodeHash160 = byte(0xA9) OpCodeEqual = byte(0x87) OpCodeEqualVerify = byte(0x88) OpCodeCheckSig = byte(0xAC) OpCodeDup = byte(0x76) OpCode_1 = byte(0x51) OpCheckMultiSig = byte(0xAE) OpPushData1 = byte(0x4C) OpPushData2 = byte(0x4D) OpPushData3 = byte(0x4E) OpDrop = byte(0x75) )
Variables ¶
View Source
var ( ErrorInvalidAddress = errors.New("Invalid address!") BTCBech32Alphabet = "qpzry9x8gf2tvdw0s3jn54khce6mua7l" CHARSET_REV = []int8{}/* 128 elements not displayed */ )
View Source
var ( BTCMainnetAddressPrefix = AddressPrefix{[]byte{0x00}, []byte{0x05}, "bc"} BTCTestnetAddressPrefix = AddressPrefix{[]byte{0x6F}, []byte{0xC4}, "tb"} BCHMainnetAddressPrefix = AddressPrefix{[]byte{0x00}, []byte{0x05}, "bc"} BCHTestnetAddressPrefix = AddressPrefix{[]byte{0x6F}, []byte{0xC4}, "tb"} LTCMainnetAddressPrefix = AddressPrefix{[]byte{0x30}, []byte{0x05}, "ltc"} LTCTestnetAddressPrefix = AddressPrefix{[]byte{0x6F}, []byte{0xC4}, "tltc"} ZECMainnetAddressPrefix = AddressPrefix{[]byte{0x1C, 0xB8}, []byte{0x1C, 0xBD}, ""} ZECTestnetAddressPrefix = AddressPrefix{[]byte{0x1D, 0x25}, []byte{0x1C, 0xBA}, ""} )
View Source
var ( CurveOrder = []byte{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xBA, 0xAE, 0xDC, 0xE6, 0xAF, 0x48, 0xA0, 0x3B, 0xBF, 0xD2, 0x5E, 0x8C, 0xD0, 0x36, 0x41, 0x41} HalfCurveOrder = []byte{0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x5D, 0x57, 0x6E, 0x73, 0x57, 0xA4, 0x50, 0x1D, 0xDF, 0xE9, 0x2F, 0x46, 0x68, 0x1B, 0x20, 0xA0} )
View Source
var (
BitcoinAlphabet = NewAlphabet("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz")
)
Alphabet: copy from https://en.wikipedia.org/wiki/Base58
View Source
var (
ErrorInvalidBase58String = errors.New("invalid base58 string")
)
Errors
Functions ¶
func Bech32Decode ¶
func Bech32Encode ¶
func CreateEmptyAssetRawTransaction ¶ added in v1.1.13
func CreateEmptyAssetRawTransaction(vins []Vin, to AssetTransfer, change Vout, lockTime uint32, replaceable bool, addressPrefix AddressPrefix) (string, error)
func CreateMultiSig ¶
func DecodeCheck ¶
return prefix + hash + error
func EncodeCheck ¶
func VerifyRawTransaction ¶
func VerifyRawTransaction(txHex string, unlockData []TxUnlock, SegwitON bool, addressPrefix AddressPrefix) bool
Types ¶
type AddressPrefix ¶
type Alphabet ¶
type Alphabet struct {
// contains filtered or unexported fields
}
Alphabet The base58 alphabet object.
func NewAlphabet ¶
NewAlphabet create a custom alphabet from 58-length string. Note: len(rune(alphabet)) must be 58.
type AssetTransfer ¶ added in v1.1.13
type MultiTx ¶
type MultiTx struct { Pubkey string SigType byte SigPub SignaturePubkey }
type NormalTx ¶
type NormalTx struct { Address string SigType byte SigPub SignaturePubkey }
type SignaturePubkey ¶
func SignRawTransactionHash ¶
func SignRawTransactionHash(txHash string, prikey []byte) (*SignaturePubkey, error)
type Transaction ¶
func DecodeRawTransaction ¶
func DecodeRawTransaction(txBytes []byte, SegwitON bool) (*Transaction, error)
type TxHash ¶
func (TxHash) GetMultiTxPubkeys ¶
func (TxHash) GetNormalTxAddress ¶
func (TxHash) GetTxHashHex ¶
func (TxHash) IsMultisig ¶
type TxIn ¶
func (TxIn) GetUTXOType ¶
Click to show internal directories.
Click to hide internal directories.