Documentation ¶
Index ¶
- Constants
- Variables
- func Bech32Decode(address string) ([]byte, error)
- func Bech32Encode(prefix, alphabet string, payload []byte) string
- func BuildInvocation(signBytes []byte) []byte
- func BuildVerification(pubKey string) ([]byte, error)
- func CreateEmptyRawTransaction(txType TransactionType, vins []Vin, vouts []Vout, attrs []Attribute) (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(rawTx string, txHashes []TxHash) ([]byte, error)
- func VerifyRawTransaction(signedRawTx string) bool
- type AddressPrefix
- type Alphabet
- type Attribute
- type AttributeType
- type MultiTx
- type NormalTx
- type Script
- type SignaturePubkey
- type Transaction
- type TransactionType
- type TxAttribute
- type TxHash
- type TxIn
- type TxOut
- type TxScript
- type Vin
- type Vout
Constants ¶
View Source
const ( Attribute_Usage_ContractHash = 0 // 合约脚本哈希 length 32 Attribute_Usage_ECDH02 = 2 // 用于ECDH密钥交换的公钥 length 32 Attribute_Usage_ECDH03 = 3 // 用于ECDH密钥交换的公钥 length 32 Attribute_Usage_Script = 32 // 交易额外的验证 length 20 Attribute_Usage_Vote = 48 // 投票payload length 需要指定 最大255个字节 Attribute_Usage_DescriptionUrl = 129 // 描述说明的URL length 需要指定 最大255个字节 Attribute_Usage_Description = 144 // 说明 length 需要指定 最大255个字节 )
View Source
const ( PublicKeySize = 33 DefaultTxVersion = uint32(0) MaxScriptElementSize = 520 )
View Source
const ( NeoAssetId = "c56f33fc6ecfcd0c225c4ab356fee59390af8560be0e930faebe74a6daff7c9b" // NEO 的 asset id NeoGasAssetId = "602c79718b16e442de58778e148d0b1084e3b2dffd5de6b7b16cee7969282de7" // NEOGAS 的 asset id )
View Source
const ( SequenceFinal = uint32(0xFFFFFFFF) SequenceMaxBip125RBF = uint32(0xFFFFFFFD) )
Variables ¶
View Source
var ( ErrorInvalidAddress = errors.New("Invalid address!") BTCBech32Alphabet = "qpzry9x8gf2tvdw0s3jn54khce6mua7l" CHARSET_REV = []int8{}/* 128 elements not displayed */ )
View Source
var ( MinerTransaction = TransactionType{"MinerTransaction", 0x00, 0} IssueTransaction = TransactionType{"IssueTransaction", 0x02, 0} ClaimTransaction = TransactionType{"ClaimTransaction", 0x03, 0} DataFile = TransactionType{"DataFile", 0x12, 0} EnrollmentTransaction = TransactionType{"EnrollmentTransaction", 0x20, 0} RegisterTransaction = TransactionType{"RegisterTransaction", 0x40, 0} ContractTransaction = TransactionType{"ContractTransaction", 0x80, 0} RecordTransaction = TransactionType{"RecordTransaction", 0x81, 0} StateTransaction = TransactionType{"StateTransaction", 0x90, 0} StateUpdateTransaction = TransactionType{"StateUpdateTransaction", 0x90, 0} StateUpdaterTransaction = TransactionType{"StateUpdaterTransaction", 0x91, 0} DestroyTransaction = TransactionType{"DestroyTransaction", 0x18, 0} PublishTransaction = TransactionType{"PublishTransaction", 0xd0, 0} InvocationTransaction = TransactionType{"InvocationTransaction", 0xd1, 1} )
View Source
var ( AttrContractHash = AttributeType{"ContractHash", 0x00, 32, 32} AttrECDH02 = AttributeType{"ECDH02", 0x02, 32, 32} AttrECDH03 = AttributeType{"ECDH03", 0x03, 32, 32} AttrScript = AttributeType{"Script", 0x20, 20, 20} AttrVote = AttributeType{"Vote", 0x30, 0, 0} AttrDescriptionUrl = AttributeType{"DescriptionUrl", 0x81, 255, 0} AttrDescription = AttributeType{"Description", 0x90, 65535, 0} AttrHash1 = AttributeType{"Hash1", 0xa1, 32, 32} AttrHash2 = AttributeType{"Hash2", 0xa2, 32, 32} AttrHash3 = AttributeType{"Hash3", 0xa3, 32, 32} AttrHash4 = AttributeType{"Hash4", 0xa4, 32, 32} AttrHash5 = AttributeType{"Hash5", 0xa5, 32, 32} AttrHash6 = AttributeType{"Hash6", 0xa6, 32, 32} AttrHash7 = AttributeType{"Hash7", 0xa7, 32, 32} AttrHash8 = AttributeType{"Hash8", 0xa8, 32, 32} AttrHash9 = AttributeType{"Hash9", 0xa9, 32, 32} AttrHash10 = AttributeType{"Hash10", 0xaa, 32, 32} AttrHash11 = AttributeType{"Hash11", 0xab, 32, 32} AttrHash12 = AttributeType{"Hash12", 0xac, 32, 32} AttrHash13 = AttributeType{"Hash13", 0xad, 32, 32} AttrHash14 = AttributeType{"Hash14", 0xae, 32, 32} AttrHash15 = AttributeType{"Hash15", 0xaf, 32, 32} AttrRemark = AttributeType{"Remark", 0xf0, 65535, 0} AttrRemark1 = AttributeType{"Remark1", 0xf1, 65535, 0} AttrRemark2 = AttributeType{"Remark2", 0xf2, 65535, 0} AttrRemark3 = AttributeType{"Remark3", 0xf3, 65535, 0} AttrRemark4 = AttributeType{"Remark4", 0xf4, 65535, 0} AttrRemark5 = AttributeType{"Remark5", 0xf5, 65535, 0} AttrRemark6 = AttributeType{"Remark6", 0xf6, 65535, 0} AttrRemark7 = AttributeType{"Remark7", 0xf7, 65535, 0} AttrRemark8 = AttributeType{"Remark8", 0xf8, 65535, 0} AttrRemark9 = AttributeType{"Remark9", 0xf9, 65535, 0} AttrRemark10 = AttributeType{"Remark10", 0xfa, 65535, 0} AttrRemark11 = AttributeType{"Remark11", 0xfb, 65535, 0} AttrRemark12 = AttributeType{"Remark12", 0xfc, 65535, 0} AttrRemark13 = AttributeType{"Remark13", 0xfd, 65535, 0} AttrRemark14 = AttributeType{"Remark14", 0xfe, 65535, 0} AttrRemark15 = AttributeType{"Remark15", 0xff, 65535, 0} )
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 (
ErrorInvalidBase58String = errors.New("invalid base58 string")
)
Errors
View Source
var (
NeocoinAlphabet = NewAlphabet("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz")
)
Alphabet: copy from https://en.wikipedia.org/wiki/Base58
Functions ¶
func Bech32Decode ¶
func Bech32Encode ¶
func BuildInvocation ¶
构建参数脚本 PushBytes64(0x40) + 签名,多签重复添加 0x40+签名 signBytes : 签名内容
func BuildVerification ¶
构建验证脚本 = PushByte33(0x21) + 签名对应的公钥 + CheckSig(0xac) pubKey : 签名对应的公钥
func CreateEmptyRawTransaction ¶
func CreateEmptyRawTransaction(txType TransactionType, vins []Vin, vouts []Vout, attrs []Attribute) (string, error)
创建未签名的空交易 txType : 交易类型 vins : 交易输入 vouts : 交易输出 attrs : 交易附加属性
func CreateMultiSig ¶
func DecodeCheck ¶
return prefix + hash + error
func EncodeCheck ¶
func InsertSignatureIntoEmptyTransaction ¶
合并签名数据到空交易 rawTx : 原始空交易 txHashes : 签名信息
func VerifyRawTransaction ¶
验证交易签名 signedRawTx : 添加签名信息的原始交易
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 Attribute ¶
type Attribute struct { Attr AttributeType Data string }
type AttributeType ¶
type AttributeType struct {
// contains filtered or unexported fields
}
交易附加参数类型
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 SignRawTransaction ¶
func SignRawTransaction(rawTx string, prikey []byte) (*SignaturePubkey, error)
签名原始交易 rawTx : 组装获得的原始交易 priKey : 签名的私钥
type Transaction ¶
type Transaction struct { Type byte Version byte Attributes []TxAttribute Vouts []TxOut Vins []TxIn Scripts []TxScript }
func (*Transaction) String ¶
func (t *Transaction) String() string
type TransactionType ¶
type TransactionType struct {
// contains filtered or unexported fields
}
交易类型
type TxAttribute ¶
type TxAttribute struct {
// contains filtered or unexported fields
}
func (*TxAttribute) String ¶
func (tx *TxAttribute) String() string
type TxHash ¶
func (TxHash) GetMultiTxPubkeys ¶
func (TxHash) GetNormalTxAddress ¶
func (TxHash) GetTxHashHex ¶
func (TxHash) IsMultisig ¶
type TxScript ¶
type TxScript struct {
// contains filtered or unexported fields
}
交易脚本
func NewEmptyTxScript ¶
func (*TxScript) GetPubKeyByVerificationScript ¶
获取验证脚本中的公钥
func (*TxScript) GetSignatureByInvocationScript ¶
获取调用参数中的签名内容
Click to show internal directories.
Click to hide internal directories.