Documentation
¶
Index ¶
- Constants
- Variables
- func CalculateHash(verifiable IVerifiable) *helper.UInt256
- func CreateInvocationScript(msg []byte, pairs []keys.KeyPair) ([]byte, error)
- func GetSignData(verifiable IVerifiable, magic uint32) []byte
- func VerifyMultiSignatureWitness(msg []byte, witness *Witness) bool
- func VerifySignatureWitness(msg []byte, witness *Witness) bool
- type HighPriorityAttribute
- func (h *HighPriorityAttribute) AllowMultiple() bool
- func (h *HighPriorityAttribute) Deserialize(br *io.BinaryReader)
- func (h *HighPriorityAttribute) DeserializeWithoutType(br *io.BinaryReader)
- func (h *HighPriorityAttribute) GetAttributeSize() int
- func (h *HighPriorityAttribute) GetAttributeType() TransactionAttributeType
- func (h *HighPriorityAttribute) Serialize(bw *io.BinaryWriter)
- func (h *HighPriorityAttribute) SerializeWithoutType(bw *io.BinaryWriter)
- type ITransactionAttribute
- type IVerifiable
- type OracleResponseAttribute
- func (o *OracleResponseAttribute) AllowMultiple() bool
- func (o *OracleResponseAttribute) Deserialize(br *io.BinaryReader)
- func (o *OracleResponseAttribute) DeserializeWithoutType(br *io.BinaryReader)
- func (o *OracleResponseAttribute) GetAttributeSize() int
- func (o *OracleResponseAttribute) GetAttributeType() TransactionAttributeType
- func (o *OracleResponseAttribute) GetMaxResultSize() int
- func (o *OracleResponseAttribute) Serialize(bw *io.BinaryWriter)
- func (o *OracleResponseAttribute) SerializeWithoutType(bw *io.BinaryWriter)
- type OracleResponseCode
- type Signer
- type SignerSlice
- type Transaction
- func (tx *Transaction) Deserialize(br *io.BinaryReader)
- func (tx *Transaction) DeserializeUnsigned(br *io.BinaryReader)
- func (tx *Transaction) DeserializeWitnesses(br *io.BinaryReader)
- func (tx *Transaction) FeePerByte() int64
- func (tx *Transaction) GetAttributes() []ITransactionAttribute
- func (tx *Transaction) GetHash() *helper.UInt256
- func (tx *Transaction) GetNetworkFee() int64
- func (tx *Transaction) GetNonce() uint32
- func (tx *Transaction) GetScript() []byte
- func (tx *Transaction) GetScriptHashesForVerifying() []helper.UInt160
- func (tx *Transaction) GetSender() *helper.UInt160
- func (tx *Transaction) GetSigners() []Signer
- func (tx *Transaction) GetSize() int
- func (tx *Transaction) GetSystemFee() int64
- func (tx *Transaction) GetValidUntilBlock() uint32
- func (tx *Transaction) GetVersion() uint8
- func (tx *Transaction) GetWitnesses() []Witness
- func (tx *Transaction) HeaderSize() int
- func (tx *Transaction) Serialize(bw *io.BinaryWriter)
- func (tx *Transaction) SerializeUnsigned(bw *io.BinaryWriter)
- func (tx *Transaction) SerializeWitnesses(bw *io.BinaryWriter)
- func (tx *Transaction) SetAttributes(value []ITransactionAttribute)
- func (tx *Transaction) SetNetworkFee(value int64)
- func (tx *Transaction) SetNonce(value uint32)
- func (tx *Transaction) SetScript(value []byte)
- func (tx *Transaction) SetSigners(value []Signer)
- func (tx *Transaction) SetSystemFee(value int64)
- func (tx *Transaction) SetValidUntilBlock(value uint32)
- func (tx *Transaction) SetVersion(value uint8)
- func (tx *Transaction) SetWitnesses(value []Witness)
- func (tx *Transaction) ToByteArray() []byte
- type TransactionAttributeSlice
- type TransactionAttributeType
- type Witness
- func CreateContractWitness(msg []byte, pairs []keys.KeyPair, contract *sc.Contract) (*Witness, error)
- func CreateMultiSignatureWitness(msg []byte, pairs []keys.KeyPair, least int, publicKeys []crypto.ECPoint) (*Witness, error)
- func CreateSignatureWitness(msg []byte, pair *keys.KeyPair) (*Witness, error)
- func CreateWitness(invocationScript []byte, verificationScript []byte) (*Witness, error)
- func CreateWitnessWithScriptHash(scriptHash *helper.UInt160, invocationScript []byte) (witness *Witness)
- type WitnessScope
- type WitnessSlice
Constants ¶
const ( Success OracleResponseCode = 0x00 ProtocolNotSupported = 0x10 ConsensusUnreachable = 0x12 NotFound = 0x14 Timeout = 0x16 Forbidden = 0x18 ResponseTooLarge = 0x1a InsufficientFunds = 0x1c Error = 0xff )
const ( TransactionVersion uint8 = 0 MaxTransactionSize = 102400 MaxValidUntilBlockIncrement uint32 = 5760 // 24 hours MaxTransactionAttributes = 16 // Maximum number of attributes that can be contained within a transaction MaxSigners = 16 // Maximum number of cosigners that can be contained within a transaction )
const ECDsaVerifyPrice = 1 << 15
const ExecFeeFactor = 30
const FeePerByte = 1000
const GasFactor = 100000000
const GasTokenId = "0xd2a4cff31913016155e38e474a2c06d08be276cf"
const MaxInvocationScript = 1024
MaxInvocationScript This is designed to allow a MultiSig 21/11 (committee) Invocation = 11 * (64 + 2) = 726
const (
MaxSubitems = 16 // This limits maximum number of AllowedContracts or AllowedGroups here.
)
const MaxVerificationScript = 1024
MaxVerificationScript Verification = m + (PUSH_PubKey * 21) + length + null + syscall = 1 + ((2 + 33) * 21) + 2 + 1 + 5 = 744
const NeoTokenId = "0xef4073a0f2b305a38ec4050e4d3d28bc40ea63f5"
Variables ¶
var GasToken, _ = helper.UInt160FromString(GasTokenId)
var NeoToken, _ = helper.UInt160FromString(NeoTokenId)
Functions ¶
func CalculateHash ¶
func CalculateHash(verifiable IVerifiable) *helper.UInt256
func CreateInvocationScript ¶
CreateInvocationScript pushes signature
func GetSignData ¶
func GetSignData(verifiable IVerifiable, magic uint32) []byte
func VerifySignatureWitness ¶
Types ¶
type HighPriorityAttribute ¶
type HighPriorityAttribute struct { }
only committee can use this attribute
func (*HighPriorityAttribute) AllowMultiple ¶
func (h *HighPriorityAttribute) AllowMultiple() bool
func (*HighPriorityAttribute) Deserialize ¶
func (h *HighPriorityAttribute) Deserialize(br *io.BinaryReader)
func (*HighPriorityAttribute) DeserializeWithoutType ¶
func (h *HighPriorityAttribute) DeserializeWithoutType(br *io.BinaryReader)
func (*HighPriorityAttribute) GetAttributeSize ¶
func (h *HighPriorityAttribute) GetAttributeSize() int
func (*HighPriorityAttribute) GetAttributeType ¶
func (h *HighPriorityAttribute) GetAttributeType() TransactionAttributeType
func (*HighPriorityAttribute) Serialize ¶
func (h *HighPriorityAttribute) Serialize(bw *io.BinaryWriter)
func (*HighPriorityAttribute) SerializeWithoutType ¶
func (h *HighPriorityAttribute) SerializeWithoutType(bw *io.BinaryWriter)
type ITransactionAttribute ¶
type ITransactionAttribute interface { GetAttributeType() TransactionAttributeType AllowMultiple() bool GetAttributeSize() int Deserialize(br *io.BinaryReader) Serialize(bw *io.BinaryWriter) DeserializeWithoutType(br *io.BinaryReader) SerializeWithoutType(bw *io.BinaryWriter) }
func CreateTransactionAttribute ¶
func CreateTransactionAttribute(attributeType TransactionAttributeType) ITransactionAttribute
func DeserializeFrom ¶
func DeserializeFrom(br *io.BinaryReader) ITransactionAttribute
type IVerifiable ¶
type IVerifiable interface { GetHash() *helper.UInt256 GetSize() int Deserialize(br *io.BinaryReader) Serialize(bw *io.BinaryWriter) DeserializeUnsigned(br *io.BinaryReader) SerializeUnsigned(bw *io.BinaryWriter) GetWitnesses() []Witness SetWitnesses(data []Witness) GetScriptHashesForVerifying() []helper.UInt160 }
type OracleResponseAttribute ¶
type OracleResponseAttribute struct { FixedScript []byte Id uint64 Code OracleResponseCode Result []byte }
only oracle can use this attribute
func NewOracleResponseAttribute ¶
func NewOracleResponseAttribute() (*OracleResponseAttribute, error)
func (*OracleResponseAttribute) AllowMultiple ¶
func (o *OracleResponseAttribute) AllowMultiple() bool
func (*OracleResponseAttribute) Deserialize ¶
func (o *OracleResponseAttribute) Deserialize(br *io.BinaryReader)
func (*OracleResponseAttribute) DeserializeWithoutType ¶
func (o *OracleResponseAttribute) DeserializeWithoutType(br *io.BinaryReader)
func (*OracleResponseAttribute) GetAttributeSize ¶
func (o *OracleResponseAttribute) GetAttributeSize() int
func (*OracleResponseAttribute) GetAttributeType ¶
func (o *OracleResponseAttribute) GetAttributeType() TransactionAttributeType
func (*OracleResponseAttribute) GetMaxResultSize ¶
func (o *OracleResponseAttribute) GetMaxResultSize() int
func (*OracleResponseAttribute) Serialize ¶
func (o *OracleResponseAttribute) Serialize(bw *io.BinaryWriter)
func (*OracleResponseAttribute) SerializeWithoutType ¶
func (o *OracleResponseAttribute) SerializeWithoutType(bw *io.BinaryWriter)
type OracleResponseCode ¶
type OracleResponseCode byte
func (OracleResponseCode) IsDefined ¶
func (code OracleResponseCode) IsDefined() bool
type Signer ¶
type Signer struct { Account *helper.UInt160 Scopes WitnessScope AllowedContracts []helper.UInt160 AllowedGroups []crypto.ECPoint }
func NewDefaultSigner ¶
func NewDefaultSigner() *Signer
func (*Signer) Deserialize ¶
func (c *Signer) Deserialize(br *io.BinaryReader)
Deserialize implements Serializable interface.
func (*Signer) Serialize ¶
func (c *Signer) Serialize(bw *io.BinaryWriter)
type SignerSlice ¶
type SignerSlice []Signer
func (SignerSlice) GetVarSize ¶
func (cs SignerSlice) GetVarSize() int
type Transaction ¶
type Transaction struct {
// contains filtered or unexported fields
}
func NewTransaction ¶
func NewTransaction() *Transaction
func (*Transaction) Deserialize ¶
func (tx *Transaction) Deserialize(br *io.BinaryReader)
Deserialize implements Serializable interface.
func (*Transaction) DeserializeUnsigned ¶
func (tx *Transaction) DeserializeUnsigned(br *io.BinaryReader)
func (*Transaction) DeserializeWitnesses ¶
func (tx *Transaction) DeserializeWitnesses(br *io.BinaryReader)
func (*Transaction) FeePerByte ¶
func (tx *Transaction) FeePerByte() int64
/ The <c>NetworkFee</c> for the transaction divided by its <c>Size</c>. / <para>Note that this property must be used with care. Getting the value of this property multiple times will return the same result. The value of this property can only be obtained after the transaction has been completely built (no longer modified).</para>
func (*Transaction) GetAttributes ¶
func (tx *Transaction) GetAttributes() []ITransactionAttribute
GetAttributes is the getter of tx.attributes
func (*Transaction) GetHash ¶
func (tx *Transaction) GetHash() *helper.UInt256
GetHash is the getter of tx._hash, using default magic
func (*Transaction) GetNetworkFee ¶
func (tx *Transaction) GetNetworkFee() int64
GetNetworkFee is the getter of tx.netfee
func (*Transaction) GetNonce ¶
func (tx *Transaction) GetNonce() uint32
GetNonce is the getter of tx.nonce
func (*Transaction) GetScript ¶
func (tx *Transaction) GetScript() []byte
GetScript is the getter of tx.script
func (*Transaction) GetScriptHashesForVerifying ¶
func (tx *Transaction) GetScriptHashesForVerifying() []helper.UInt160
func (*Transaction) GetSigners ¶
func (tx *Transaction) GetSigners() []Signer
GetSigners is the getter of tx.signers
func (*Transaction) GetSize ¶
func (tx *Transaction) GetSize() int
GetSize is the getter of tx._size
func (*Transaction) GetSystemFee ¶
func (tx *Transaction) GetSystemFee() int64
GetSystemFee is the getter of tx.sysfee
func (*Transaction) GetValidUntilBlock ¶
func (tx *Transaction) GetValidUntilBlock() uint32
GetValidUntilBlock is the getter of tx.validUntilBlock
func (*Transaction) GetVersion ¶
func (tx *Transaction) GetVersion() uint8
GetVersion is the getter of tx.version
func (*Transaction) GetWitnesses ¶
func (tx *Transaction) GetWitnesses() []Witness
GetWitnesses is the getter of tx.witnesses
func (*Transaction) HeaderSize ¶
func (tx *Transaction) HeaderSize() int
func (*Transaction) Serialize ¶
func (tx *Transaction) Serialize(bw *io.BinaryWriter)
Serialize implements Serializable interface.
func (*Transaction) SerializeUnsigned ¶
func (tx *Transaction) SerializeUnsigned(bw *io.BinaryWriter)
func (*Transaction) SerializeWitnesses ¶
func (tx *Transaction) SerializeWitnesses(bw *io.BinaryWriter)
func (*Transaction) SetAttributes ¶
func (tx *Transaction) SetAttributes(value []ITransactionAttribute)
SetAttributes is the setter of tx.attributes
func (*Transaction) SetNetworkFee ¶
func (tx *Transaction) SetNetworkFee(value int64)
SetNetworkFee is the setter of tx.netfee
func (*Transaction) SetNonce ¶
func (tx *Transaction) SetNonce(value uint32)
SetNonce is the setter of tx.nonce
func (*Transaction) SetScript ¶
func (tx *Transaction) SetScript(value []byte)
SetScript is the setter of tx.script
func (*Transaction) SetSigners ¶
func (tx *Transaction) SetSigners(value []Signer)
SetSigners is the setter of tx.signers
func (*Transaction) SetSystemFee ¶
func (tx *Transaction) SetSystemFee(value int64)
SetSystemFee is the setter of tx.sysfee
func (*Transaction) SetValidUntilBlock ¶
func (tx *Transaction) SetValidUntilBlock(value uint32)
SetValidUntilBlock is the setter of tx.validUntilBlock
func (*Transaction) SetVersion ¶
func (tx *Transaction) SetVersion(value uint8)
SetVersion is the setter of tx.version
func (*Transaction) SetWitnesses ¶
func (tx *Transaction) SetWitnesses(value []Witness)
SetWitnesses is the setter of tx.witnesses
func (*Transaction) ToByteArray ¶
func (tx *Transaction) ToByteArray() []byte
ToByteArray returns signed tx data
type TransactionAttributeSlice ¶
type TransactionAttributeSlice []ITransactionAttribute
func (TransactionAttributeSlice) GetVarSize ¶
func (ts TransactionAttributeSlice) GetVarSize() int
type TransactionAttributeType ¶
type TransactionAttributeType byte
Transaction attribute type
const ( HighPriority TransactionAttributeType = 0x01 // OracleResponse TransactionAttributeType = 0x11 )
func (TransactionAttributeType) IsDefined ¶
func (u TransactionAttributeType) IsDefined() bool
func (TransactionAttributeType) String ¶
func (u TransactionAttributeType) String() string
type Witness ¶
type Witness struct { InvocationScript []byte // signature VerificationScript []byte // pub key // contains filtered or unexported fields }
func CreateContractWitness ¶
func CreateContractWitness(msg []byte, pairs []keys.KeyPair, contract *sc.Contract) (*Witness, error)
create single signature witness
func CreateMultiSignatureWitness ¶
func CreateMultiSignatureWitness(msg []byte, pairs []keys.KeyPair, least int, publicKeys []crypto.ECPoint) (*Witness, error)
create multi-signature witness
func CreateSignatureWitness ¶
func CreateWitness ¶
CreateWitness with invocationScript and verificationScript
func CreateWitnessWithScriptHash ¶
func CreateWitnessWithScriptHash(scriptHash *helper.UInt160, invocationScript []byte) (witness *Witness)
this is only used for empty VerificationScript, neo block chain will search the contract script with scriptHash
func (*Witness) Deserialize ¶
func (w *Witness) Deserialize(br *io.BinaryReader)
Deserialize implements Serializable interface.
func (*Witness) GetScriptHash ¶
func (*Witness) MarshalJSON ¶
MarshalJSON implements the json marshaller interface.
func (*Witness) Serialize ¶
func (w *Witness) Serialize(bw *io.BinaryWriter)
Serialize implements Serializable interface.
type WitnessScope ¶
type WitnessScope byte
const ( /// No contract was witnessed. Only sign the transaction. None WitnessScope = 0x00 /// CalledByEntry means that this condition must hold: EntryScriptHash == CallingScriptHash /// No params is needed, as the witness/permission/signature given on first invocation will automatically expire if entering deeper internal invokes /// This can be default safe choice for native NEO/GAS (previously used on Neo 2 as "attach" mode) CalledByEntry WitnessScope = 0x01 /// Custom hash for contract-specific CustomContracts WitnessScope = 0x10 /// Custom pubkey for group members CustomGroups WitnessScope = 0x20 /// Global allows this witness in all contexts (default Neo2 behavior) /// This cannot be combined with other flags Global WitnessScope = 0x80 )
func (WitnessScope) CompareTo ¶
func (w WitnessScope) CompareTo(other WitnessScope) int
func (WitnessScope) String ¶
func (w WitnessScope) String() string
type WitnessSlice ¶
type WitnessSlice []Witness
func (WitnessSlice) Len ¶
func (ws WitnessSlice) Len() int
func (WitnessSlice) Less ¶
func (ws WitnessSlice) Less(i, j int) bool
func (WitnessSlice) Swap ¶
func (ws WitnessSlice) Swap(i, j int)