Documentation ¶
Overview ¶
TODO: Move this package to the Go client-sdk.
Index ¶
- Constants
- Variables
- type Address
- type AddressSpec
- type AuthInfo
- type AuthProof
- type BaseUnits
- type Call
- type CallResult
- type Denomination
- type FailedCallResult
- type Fee
- type MultisigConfig
- type MultisigSigner
- type PublicKey
- type Quantity
- type RuntimeInfo
- type SignerInfo
- type Transaction
- func (t *Transaction) AppendAuthMultisig(config *MultisigConfig, nonce uint64)
- func (t *Transaction) AppendAuthSignature(pk signature.PublicKey, nonce uint64)
- func (t *Transaction) AppendSignerInfo(addressSpec AddressSpec, nonce uint64)
- func (t *Transaction) PrepareForSigning() *TransactionSigner
- func (t *Transaction) ValidateBasic() error
- type TransactionSigner
- type UnverifiedTransaction
Constants ¶
const LatestTransactionVersion = 1
LatestTransactionVersion is the latest transaction format version.
const MaxDenominationSize = 32
MaxDenominationSize is the maximum length of a denomination.
Variables ¶
var ( // AddressV0Ed25519Context is the unique context for v0 Ed25519-based addresses. // It is shared with the consensus layer addresses on purpose. AddressV0Ed25519Context = staking.AddressV0Context // AddressV0Secp256k1Context is the unique context for v0 Ed25519-based addresses. AddressV0Secp256k1Context = address.NewContext("oasis-runtime-sdk/address: secp256k1", 0) // AddressV0MultisigContext is the unique context for v0 multisig addresses. AddressV0MultisigContext = address.NewContext("oasis-runtime-sdk/address: multisig", 0) // AddressBech32HRP is the unique human readable part of Bech32 encoded // staking account addresses. AddressBech32HRP = staking.AddressBech32HRP )
var NativeDenomination = Denomination([]byte{})
NativeDenomination is the denomination in native token.
var SignatureContextBase = []byte("oasis-runtime-sdk/tx: v0")
SignatureContextBase is the transaction signature domain separation context base.
Functions ¶
This section is empty.
Types ¶
type Address ¶
Address is the account address.
func NewAddress ¶
NewAddress creates a new address from the given public key.
func NewAddressFromBech32 ¶
NewAddressFromBech32 creates a new address from the given bech-32 encoded string.
Panics in case of errors -- use UnmarshalText if you want to handle errors.
func NewAddressFromMultisig ¶
func NewAddressFromMultisig(config *MultisigConfig) Address
NewAddressFromMultisig creates a new address from the given multisig configuration.
func (Address) MarshalBinary ¶
MarshalBinary encodes an address into binary form.
func (Address) MarshalText ¶
MarshalText encodes an address into text form.
func (*Address) UnmarshalBinary ¶
UnmarshalBinary decodes a binary marshaled address.
func (*Address) UnmarshalText ¶
UnmarshalText decodes a text marshaled address.
type AddressSpec ¶
type AddressSpec struct { // Signature is for signature authentication. Signature *PublicKey `json:"signature,omitempty"` // Multisig is for multisig authentication. Multisig *MultisigConfig `json:"multisig,omitempty"` }
AddressSpec is common information that specifies an address as well as how to authenticate.
func (*AddressSpec) Address ¶
func (as *AddressSpec) Address() (Address, error)
Address derives the address.
type AuthInfo ¶
type AuthInfo struct { SignerInfo []SignerInfo `json:"si"` Fee Fee `json:"fee"` }
AuthInfo contains transaction authentication information.
type AuthProof ¶
type AuthProof struct { // Signature is for signature authentication. Signature []byte `json:"signature,omitempty"` // Multisig is for multisig authentication. Multisig [][]byte `json:"multisig,omitempty"` }
AuthProof is a container for data that authenticates a transaction.
type BaseUnits ¶
type BaseUnits struct { Amount quantity.Quantity Denomination Denomination // contains filtered or unexported fields }
BaseUnits is the token amount of given denomination in base units.
func NewBaseUnits ¶
func NewBaseUnits(amount quantity.Quantity, denomination Denomination) BaseUnits
NewBaseUnits creates a new token amount of given denomination.
type Call ¶
type Call struct { Method string `json:"method"` Body cbor.RawMessage `json:"body"` }
Call is a method call.
type CallResult ¶
type CallResult struct { Ok cbor.RawMessage `json:"ok,omitempty"` Failed *FailedCallResult `json:"fail,omitempty"` }
CallResult is the method call result.
func (*CallResult) IsSuccess ¶
func (cr *CallResult) IsSuccess() bool
IsSuccess checks whether the call result indicates success.
type Denomination ¶
type Denomination string
Denomination is the name/type of the token.
func (Denomination) IsNative ¶
func (d Denomination) IsNative() bool
IsNative checks whether the denomination represents the native token.
func (Denomination) MarshalBinary ¶
func (d Denomination) MarshalBinary() ([]byte, error)
MarshalBinary encodes a denomination into binary form.
func (Denomination) String ¶
func (d Denomination) String() string
String returns a string representation of this denomination.
func (*Denomination) UnmarshalBinary ¶
func (d *Denomination) UnmarshalBinary(data []byte) error
UnmarshalBinary decodes a binary marshaled denomination.
type FailedCallResult ¶
type FailedCallResult struct { Module string `json:"module"` Code uint32 `json:"code"` Message string `json:"message,omitempty"` }
FailedCallResult is a failed call result.
func (FailedCallResult) Error ¶
func (cr FailedCallResult) Error() string
Error is a trivial implementation of error.
func (FailedCallResult) String ¶
func (cr FailedCallResult) String() string
String returns the string representation of a failed call result.
type MultisigConfig ¶
type MultisigConfig struct { Signers []MultisigSigner `json:"signers"` Threshold uint64 `json:"threshold"` }
MultisigConfig is a multisig configuration. A set of signers with total "weight" greater than or equal to a "threshold" can authenticate for the configuration.
func (*MultisigConfig) Batch ¶
func (mc *MultisigConfig) Batch(signatureSet [][]byte) ([]PublicKey, [][]byte, error)
Batch checks that enough signers have signed and returns vectors of public keys and signatures for batch verification of those signatures. This internally calls `ValidateBasic`.
func (*MultisigConfig) ValidateBasic ¶
func (mc *MultisigConfig) ValidateBasic() error
ValidateBasic performs some sanity checks. This looks at the configuration only. There is no cryptographic verification of any signatures.
type MultisigSigner ¶
type MultisigSigner struct { PublicKey PublicKey `json:"public_key"` Weight uint64 `json:"weight"` }
MultisigSigner is one of the signers in a multisig configuration.
type PublicKey ¶
PublicKey is a serializable public key.
func (*PublicKey) MarshalCBOR ¶
MarshalCBOR encodes the public key as CBOR.
func (*PublicKey) MarshalJSON ¶
MarshalJSON encodes the public key as JSON.
func (*PublicKey) UnmarshalCBOR ¶
UnmarshalCBOR decodes the public key from CBOR.
func (*PublicKey) UnmarshalJSON ¶
UnmarshalJSON decodes the public key from JSON.
type RuntimeInfo ¶
type RuntimeInfo struct { // ID is the runtime identifier. ID common.Namespace // ChainContext is the chain domain separation context used by the runtime. ChainContext signature.Context }
RuntimeInfo is information about a runtime.
type SignerInfo ¶
type SignerInfo struct { AddressSpec AddressSpec `json:"address_spec"` Nonce uint64 `json:"nonce"` }
SignerInfo contains transaction signer information.
type Transaction ¶
Transaction is a runtime transaction.
func NewTransaction ¶
func NewTransaction(fee *Fee, method string, body interface{}) *Transaction
NewTransaction creates a new unsigned transaction.
func (*Transaction) AppendAuthMultisig ¶
func (t *Transaction) AppendAuthMultisig(config *MultisigConfig, nonce uint64)
AppendAuthMultisig appends a new transaction signer information with a multisig address specification to the transaction.
func (*Transaction) AppendAuthSignature ¶
func (t *Transaction) AppendAuthSignature(pk signature.PublicKey, nonce uint64)
AppendAuthSignature appends a new transaction signer information with a signature address specification to the transaction.
func (*Transaction) AppendSignerInfo ¶
func (t *Transaction) AppendSignerInfo(addressSpec AddressSpec, nonce uint64)
AppendSignerInfo appends a new transaction signer information to the transaction.
func (*Transaction) PrepareForSigning ¶
func (t *Transaction) PrepareForSigning() *TransactionSigner
func (*Transaction) ValidateBasic ¶
func (t *Transaction) ValidateBasic() error
ValidateBasic performs basic validation on the transaction.
type TransactionSigner ¶
type TransactionSigner struct {
// contains filtered or unexported fields
}
func (*TransactionSigner) AppendSign ¶
AppendSign signs the transaction and appends the signature.
The signer must be specified in the AuthInfo.
func (*TransactionSigner) UnverifiedTransaction ¶
func (ts *TransactionSigner) UnverifiedTransaction() *UnverifiedTransaction
UnverifiedTransaction returns the (signed) unverified transaction.
type UnverifiedTransaction ¶
type UnverifiedTransaction struct { Body []byte AuthProofs []AuthProof // contains filtered or unexported fields }
UnverifiedTransaction is an unverified transaction.
func (*UnverifiedTransaction) Verify ¶
func (ut *UnverifiedTransaction) Verify(ctx signature.Context) (*Transaction, error)
Verify verifies and deserializes the unverified transaction.