Documentation
¶
Index ¶
- Constants
- Variables
- func DecodeResponse(resp *http.Response) ([]byte, error)
- func GenerateEd25519Key() ed25519.PrivateKey
- func HashMembers(ids []string) string
- func HashScalar(txVer uint8, k *edwards25519.Point, outputIndex uint8) *edwards25519.Scalar
- func IsErrorCodes(err error, codes ...int) bool
- func KeyMultPubPriv(pub, priv *Key) *edwards25519.Point
- func UnmarshalResponse(resp *http.Response, v interface{}) error
- type Address
- type AggregatedSignature
- type Client
- func (c *Client) CallMixinNetRPC(ctx context.Context, resp interface{}, method string, params ...interface{}) error
- func (c *Client) GetTransaction(ctx context.Context, hash Hash) (*Transaction, error)
- func (c *Client) GetUTXO(ctx context.Context, hash Hash, outputIndex uint8) (*UTXO, error)
- func (c *Client) HostFromContext(ctx context.Context) string
- func (c *Client) RandomHost() string
- func (c *Client) ReadConsensusInfo(ctx context.Context) (*ConsensusInfo, error)
- func (c *Client) SendRawTransaction(ctx context.Context, raw string) (*Transaction, error)
- func (c *Client) VerifyTransaction(ctx context.Context, addr *Address, txHash Hash) (bool, error)
- func (c *Client) WithHost(ctx context.Context, host string) context.Context
- type Config
- type ConsensusInfo
- type ConsensusNode
- type Decoder
- func (dec *Decoder) DecodeTransaction() (*Transaction, error)
- func (dec *Decoder) Read(b []byte) error
- func (dec *Decoder) ReadAggregatedSignature() (*AggregatedSignature, error)
- func (dec *Decoder) ReadByte() (byte, error)
- func (dec *Decoder) ReadBytes() ([]byte, error)
- func (dec *Decoder) ReadInput() (*Input, error)
- func (dec *Decoder) ReadInt() (int, error)
- func (dec *Decoder) ReadInteger() (Integer, error)
- func (dec *Decoder) ReadMagic() (bool, error)
- func (dec *Decoder) ReadOutput(ver uint8) (*Output, error)
- func (dec *Decoder) ReadSignatures() (map[uint16]*Signature, error)
- func (dec *Decoder) ReadUint16() (uint16, error)
- func (dec *Decoder) ReadUint32() (uint32, error)
- func (dec *Decoder) ReadUint64() (uint64, error)
- type DepositData
- type Encoder
- func (enc *Encoder) EncodeAggregatedSignature(js *AggregatedSignature)
- func (enc *Encoder) EncodeInput(in *Input)
- func (enc *Encoder) EncodeOutput(o *Output, ver uint8)
- func (enc *Encoder) EncodeSignatures(sm map[uint16]*Signature)
- func (enc *Encoder) EncodeTransaction(signed *Transaction) []byte
- func (enc *Encoder) Write(b []byte)
- func (enc *Encoder) WriteByte(b byte) error
- func (enc *Encoder) WriteInt(d int)
- func (enc *Encoder) WriteInteger(d Integer)
- func (enc *Encoder) WriteUint16(d uint16)
- func (enc *Encoder) WriteUint32(d uint32)
- func (enc *Encoder) WriteUint64(d uint64)
- type Error
- type Graph
- type GraphCache
- type GraphFinal
- type GraphReferences
- type GraphSnapshot
- type Hash
- type Input
- type InputUTXO
- type Integer
- func (x Integer) Add(y Integer) (v Integer)
- func (x Integer) Cmp(y Integer) int
- func (x Integer) Count(y Integer) uint64
- func (x Integer) Div(y int) (v Integer)
- func (x Integer) MarshalJSON() ([]byte, error)
- func (x Integer) MarshalMsgpack() ([]byte, error)
- func (x Integer) Mul(y int) (v Integer)
- func (x Integer) Sign() int
- func (x Integer) String() string
- func (x Integer) Sub(y Integer) (v Integer)
- func (x *Integer) UnmarshalJSON(b []byte) error
- func (x *Integer) UnmarshalMsgpack(data []byte) error
- type Key
- func DeriveGhostPrivateKey(txVer uint8, R, a, b *Key, outputIndex uint8) *Key
- func DeriveGhostPublicKey(txVer uint8, r, A, B *Key, outputIndex uint8) *Key
- func GenerateKey(randReader io.Reader) Key
- func KeyFromBytes(bts []byte) Key
- func KeyFromSeed(seed string) (Key, error)
- func KeyFromString(s string) (Key, error)
- func ParseKeyWithPub(s, pub string) (Key, error)
- func ViewGhostOutputKey(txVer uint8, P, a, R *Key, outputIndex uint8) *Key
- func (k Key) CheckKey() bool
- func (k Key) DeterministicHashDerive() Key
- func (k Key) HasValue() bool
- func (k Key) MarshalJSON() ([]byte, error)
- func (k Key) Public() Key
- func (privateKey *Key) Sign(message []byte) Signature
- func (privateKey *Key) SignHash(h Hash) Signature
- func (k Key) String() string
- func (k Key) ToPoint() (*edwards25519.Point, error)
- func (k Key) ToScalar() (*edwards25519.Scalar, error)
- func (k *Key) UnmarshalJSON(b []byte) error
- func (publicKey *Key) Verify(message []byte, sig Signature) bool
- func (publicKey *Key) VerifyHash(message Hash, sig Signature) bool
- func (publicKey *Key) VerifyWithChallenge(sig Signature, a *edwards25519.Scalar) bool
- type Mint
- type MintData
- type Output
- type Queue
- type Script
- type Signature
- type Transaction
- type TransactionExtra
- type TransactionInput
- type TransactionV1
- type UTXO
- type WithdrawalData
Constants ¶
View Source
const ( MinimumEncodingVersion = 0x1 MaximumEncodingInt = 0xFFFF AggregatedSignaturePrefix = 0xFF01 AggregatedSignatureSparseMask = byte(0x01) AggregatedSignatureOrdinayMask = byte(0x00) )
View Source
const ( InvalidOutputKey = 2000001 InputLocked = 2000002 InvalidSignature = 2000003 )
mixin error codes https://developers.mixin.one/api/alpha-mixin-network/errors/
View Source
const ( TxMethodSend = "sendrawtransaction" TxMethodGet = "gettransaction" TxMethodGetUtxo = "getutxo" )
View Source
const ( TxVersionCommonEncoding = 0x02 TxVersionBlake3Hash = 0x03 TxVersionReferences = 0x04 TxVersionHashSignature = 0x05 TxVersionLegacy = TxVersionReferences TxVersion = TxVersionHashSignature )
View Source
const ( OutputTypeScript = 0x00 OutputTypeWithdrawalSubmit = 0xa1 OutputTypeWithdrawalFuel = 0xa2 OutputTypeNodePledge = 0xa3 OutputTypeNodeAccept = 0xa4 OutputTypeNodeRemove = 0xa6 OutputTypeDomainAccept = 0xa7 OutputTypeDomainRemove = 0xa8 OutputTypeWithdrawalClaim = 0xa9 OutputTypeNodeCancel = 0xaa OutputTypeCustodianEvolution = 0xb1 OutputTypeCustodianMigration = 0xb2 OutputTypeCustodianDeposit = 0xb3 OutputTypeCustodianWithdrawal = 0xb4 )
View Source
const ( TransactionTypeScript = 0x00 TransactionTypeMint = 0x01 TransactionTypeDeposit = 0x02 TransactionTypeWithdrawalSubmit = 0x03 TransactionTypeWithdrawalFuel = 0x04 TransactionTypeWithdrawalClaim = 0x05 TransactionTypeNodePledge = 0x06 TransactionTypeNodeAccept = 0x07 TransactionTypeNodeRemove = 0x09 TransactionTypeDomainAccept = 0x10 TransactionTypeDomainRemove = 0x11 TransactionTypeNodeCancel = 0x12 TransactionTypeCustodianUpdateNodes = 0x13 TransactionTypeCustodianSlashNodes = 0x14 TransactionTypeUnknown = 0xff )
View Source
const ( Operator0 = 0x00 Operator64 = 0x40 OperatorSum = 0xfe OperatorCmp = 0xff )
View Source
const ( ExtraSizeGeneralLimit = 256 ExtraSizeStorageStep = 1024 ExtraSizeStorageCapacity = 1024 * 1024 * 4 ExtraStoragePriceStep = "0.001" SliceCountLimit = 256 ReferencesCountLimit = 2 )
View Source
const MainNetworkID = "XIN"
View Source
const Precision = 8
Variables ¶
View Source
var ( DefaultLegacyConfig = Config{ Safe: false, Hosts: legacyHosts, } DefaultSafeConfig = Config{ Safe: true, Hosts: safeHosts, } )
Functions ¶
func GenerateEd25519Key ¶
func GenerateEd25519Key() ed25519.PrivateKey
func HashMembers ¶
func HashScalar ¶
func HashScalar(txVer uint8, k *edwards25519.Point, outputIndex uint8) *edwards25519.Scalar
func IsErrorCodes ¶
func KeyMultPubPriv ¶
func KeyMultPubPriv(pub, priv *Key) *edwards25519.Point
func UnmarshalResponse ¶
Types ¶
type Address ¶
type Address struct { PrivateSpendKey Key `json:"private_spend_key"` PrivateViewKey Key `json:"private_view_key"` PublicSpendKey Key `json:"public_spend_key"` PublicViewKey Key `json:"public_view_key"` }
func AddressFromPublicSpend ¶
func AddressFromString ¶
func (Address) CreateUTXO ¶
func (Address) MarshalJSON ¶
func (*Address) UnmarshalJSON ¶
type AggregatedSignature ¶
type Client ¶
func (*Client) CallMixinNetRPC ¶
func (*Client) GetTransaction ¶
func (*Client) RandomHost ¶
func (*Client) ReadConsensusInfo ¶
func (c *Client) ReadConsensusInfo(ctx context.Context) (*ConsensusInfo, error)
func (*Client) SendRawTransaction ¶
func (*Client) VerifyTransaction ¶
检查 transaction 是否是由该主网地址签发。满足以下所有条件则返回 true:
- 所有 input 对应的 utxo 只有一个 keys, 即 不是多签地址 转出
- 该 input 的 mask & keys 可以使用该地址的 private view 和 public spend 碰撞通过
type ConsensusInfo ¶
type ConsensusNode ¶
type Decoder ¶
type Decoder struct {
// contains filtered or unexported fields
}
func NewDecoder ¶
func NewMinimumDecoder ¶
func (*Decoder) DecodeTransaction ¶
func (dec *Decoder) DecodeTransaction() (*Transaction, error)
func (*Decoder) ReadAggregatedSignature ¶
func (dec *Decoder) ReadAggregatedSignature() (*AggregatedSignature, error)
func (*Decoder) ReadInteger ¶
func (*Decoder) ReadSignatures ¶
func (*Decoder) ReadUint16 ¶
func (*Decoder) ReadUint32 ¶
func (*Decoder) ReadUint64 ¶
type DepositData ¶
type Encoder ¶
type Encoder struct {
// contains filtered or unexported fields
}
func NewEncoder ¶
func NewEncoder() *Encoder
func NewMinimumEncoder ¶
func NewMinimumEncoder() *Encoder
func (*Encoder) EncodeAggregatedSignature ¶
func (enc *Encoder) EncodeAggregatedSignature(js *AggregatedSignature)
func (*Encoder) EncodeInput ¶
func (*Encoder) EncodeOutput ¶
func (*Encoder) EncodeSignatures ¶
func (*Encoder) EncodeTransaction ¶
func (enc *Encoder) EncodeTransaction(signed *Transaction) []byte
func (*Encoder) WriteInteger ¶
func (*Encoder) WriteUint16 ¶
func (*Encoder) WriteUint32 ¶
func (*Encoder) WriteUint64 ¶
type Error ¶
type Graph ¶
type Graph struct { SPS float64 `json:"sps"` Topology uint64 `json:"topology"` Consensus []*ConsensusNode `json:"consensus"` Final map[string]*GraphFinal `json:"final"` Cache map[string]*GraphCache `json:"cache"` }
type GraphCache ¶
type GraphCache struct { Node Hash `json:"node"` References GraphReferences `json:"references"` Timestamp int64 `json:"timestamp"` Round uint64 `json:"round"` Snapshots []*GraphSnapshot `json:"snapshots"` }
type GraphFinal ¶
type GraphReferences ¶
type GraphSnapshot ¶
type GraphSnapshot struct { Node Hash `json:"node"` Hash Hash `json:"hash"` References GraphReferences `json:"references"` Round uint64 `json:"round"` Timestamp int64 `json:"timestamp"` Transaction Hash `json:"transaction"` Signature string `json:"signature"` // CosiSignature Version int `json:"version"` }
type Hash ¶
type Hash [32]byte
var (
XINAssetId Hash
)
func HashFromString ¶
func NewBlake3Hash ¶
func (Hash) MarshalJSON ¶
func (*Hash) UnmarshalJSON ¶
type Input ¶
type Input struct { Hash *Hash `json:"hash,omitempty"` Index uint8 `json:"index,omitempty"` Genesis []byte `json:"genesis,omitempty"` Deposit *DepositData `json:"deposit,omitempty"` Mint *MintData `json:"mint,omitempty"` }
type Integer ¶
type Integer struct {
// contains filtered or unexported fields
}
var Zero Integer
func IntegerFromDecimal ¶
func IntegerFromString ¶
func NewInteger ¶
func (Integer) MarshalJSON ¶
func (Integer) MarshalMsgpack ¶
func (*Integer) UnmarshalJSON ¶
func (*Integer) UnmarshalMsgpack ¶
type Key ¶
type Key [32]byte
func DeriveGhostPrivateKey ¶
func DeriveGhostPublicKey ¶
func GenerateKey ¶
func KeyFromBytes ¶ added in v2.0.4
func KeyFromSeed ¶
func KeyFromString ¶
func ParseKeyWithPub ¶ added in v2.0.4
func ViewGhostOutputKey ¶
func (Key) DeterministicHashDerive ¶
func (Key) MarshalJSON ¶
func (*Key) UnmarshalJSON ¶
func (*Key) VerifyWithChallenge ¶
func (publicKey *Key) VerifyWithChallenge(sig Signature, a *edwards25519.Scalar) bool
type Script ¶
type Script []uint8
func NewThresholdScript ¶
func (Script) MarshalJSON ¶
func (*Script) UnmarshalJSON ¶
func (Script) VerifyFormat ¶
type Signature ¶
type Signature [64]byte
func (Signature) MarshalJSON ¶
func (*Signature) UnmarshalJSON ¶
type Transaction ¶
type Transaction struct { Hash *Hash `json:"hash,omitempty" msgpack:"-"` Snapshot *Hash `json:"snapshot,omitempty" msgpack:"-"` Signatures []map[uint16]*Signature `json:"signatures,omitempty" msgpack:"-"` AggregatedSignature *AggregatedSignature `json:"aggregated_signature,omitempty" msgpack:"-"` Version uint8 `json:"version"` Asset Hash `json:"asset"` Inputs []*Input `json:"inputs"` Outputs []*Output `json:"outputs"` References []Hash `msgpack:"-"` Extra TransactionExtra `json:"extra,omitempty"` }
func TransactionFromData ¶
func TransactionFromData(data []byte) (*Transaction, error)
func TransactionFromRaw ¶
func TransactionFromRaw(raw string) (*Transaction, error)
func (*Transaction) Dump ¶
func (t *Transaction) Dump() (string, error)
func (*Transaction) DumpData ¶
func (t *Transaction) DumpData() ([]byte, error)
func (Transaction) DumpPayload ¶
func (t Transaction) DumpPayload() ([]byte, error)
func (*Transaction) ExtraLimit ¶
func (tx *Transaction) ExtraLimit() int
func (*Transaction) TransactionHash ¶
func (t *Transaction) TransactionHash() (Hash, error)
type TransactionExtra ¶
type TransactionExtra []byte
func (TransactionExtra) MarshalJSON ¶
func (e TransactionExtra) MarshalJSON() ([]byte, error)
func (TransactionExtra) String ¶
func (e TransactionExtra) String() string
func (*TransactionExtra) UnmarshalJSON ¶
func (e *TransactionExtra) UnmarshalJSON(b []byte) error
type TransactionInput ¶
type TransactionInput struct { TxVersion uint8 Memo string Inputs []*InputUTXO Outputs []*Output References []Hash Hint string }
func (*TransactionInput) Asset ¶
func (input *TransactionInput) Asset() Hash
func (*TransactionInput) Build ¶
func (input *TransactionInput) Build() (*Transaction, error)
func (*TransactionInput) TotalInputAmount ¶
func (input *TransactionInput) TotalInputAmount() decimal.Decimal
func (*TransactionInput) Validate ¶
func (input *TransactionInput) Validate() error
type TransactionV1 ¶
type TransactionV1 struct { Transaction Signatures [][]*Signature `json:"signatures,omitempty" msgpack:",omitempty"` }
func (*TransactionV1) Dump ¶
func (t *TransactionV1) Dump() (string, error)
Source Files
¶
Click to show internal directories.
Click to hide internal directories.