Documentation ¶
Overview ¶
TODO: Move this package to the Go client-sdk.
Index ¶
- Constants
- Variables
- type Address
- func NewAddress(spec SignatureAddressSpec) (a Address)
- func NewAddressForModule(module string, kind []byte) Address
- func NewAddressFromBech32(data string) (a Address)
- func NewAddressFromConsensus(addr staking.Address) Address
- func NewAddressFromConsensusPublicKey(pk signature.PublicKey) Address
- func NewAddressFromMultisig(config *MultisigConfig) Address
- func NewAddressRaw(ctx address.Context, data []byte) Address
- func (a Address) ConsensusAddress() staking.Address
- func (a Address) Equal(cmp Address) bool
- func (a Address) MarshalBinary() ([]byte, error)
- func (a Address) MarshalText() ([]byte, error)
- func (a Address) String() string
- func (a *Address) UnmarshalBinary(data []byte) error
- func (a *Address) UnmarshalText(text []byte) error
- type AddressSpec
- type AuthInfo
- type AuthProof
- type BaseUnits
- type Call
- type CallEnvelopeX25519DeoxysII
- type CallFormat
- type CallResult
- type CallerAddress
- type Denomination
- type Event
- type EventKey
- type FailedCallResult
- type Fee
- type MultisigConfig
- type MultisigSigner
- type PrettyCall
- type PrettyTransaction
- type PublicKey
- type Quantity
- type ResultEnvelopeX25519DeoxysII
- type RuntimeInfo
- type SignatureAddressSpec
- type SignedPublicKey
- type SignerInfo
- type Transaction
- func (t *Transaction) AppendAuthMultisig(config *MultisigConfig, nonce uint64)
- func (t *Transaction) AppendAuthSignature(spec SignatureAddressSpec, nonce uint64)
- func (t *Transaction) AppendSignerInfo(addressSpec AddressSpec, nonce uint64)
- func (t *Transaction) PrepareForSigning() *TransactionSigner
- func (t *Transaction) PrettyType(txBody interface{}) (*PrettyTransaction, error)
- func (t *Transaction) ValidateBasic() error
- type TransactionSigner
- type UnverifiedTransaction
Constants ¶
const ( // CallFormatPlain is the plain text call format. CallFormatPlain = CallFormat(0) // CallFormatEncryptedX25519DeoxysII is the encrypted call format using X25519 for key exchange // and Deoxys-II for symmetric encryption. CallFormatEncryptedX25519DeoxysII = CallFormat(1) )
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 // AddressV0Secp256k1EthContext is the unique context for v0 secp256k1-based addresses. AddressV0Secp256k1EthContext = address.NewContext("oasis-runtime-sdk/address: secp256k1eth", 0) // AddressV0Sr25519Context is the unique context for v0 Sr25519-based addresses. AddressV0Sr25519Context = address.NewContext("oasis-runtime-sdk/address: sr25519", 0) // AddressV0MultisigContext is the unique context for v0 multisig addresses. AddressV0MultisigContext = address.NewContext("oasis-runtime-sdk/address: multisig", 0) // AddressV0ModuleContext is the unique context for v0 module addresses. AddressV0ModuleContext = address.NewContext("oasis-runtime-sdk/address: module", 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 ¶
func NewAddress(spec SignatureAddressSpec) (a Address)
NewAddress creates a new address from the given signature address specification.
func NewAddressForModule ¶ added in v0.2.0
NewAddressForModule creates a new address for a specific module and raw kind.
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 NewAddressFromConsensus ¶ added in v0.2.0
NewAddressFromConsensus converts a consensus layer address into an address.
func NewAddressFromConsensusPublicKey ¶ added in v0.3.0
NewAddressFromConsensusPublicKey converts a consensus layer public key into an address.
func NewAddressFromMultisig ¶
func NewAddressFromMultisig(config *MultisigConfig) Address
NewAddressFromMultisig creates a new address from the given multisig configuration.
func NewAddressRaw ¶ added in v0.2.0
NewAddressRaw creates a new address from passed address context and data.
func (Address) ConsensusAddress ¶ added in v0.2.0
ConsensusAddress converts this address into a consensus-layer address type.
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 *SignatureAddressSpec `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"` NotBefore *uint64 `json:"not_before,omitempty"` NotAfter *uint64 `json:"not_after,omitempty"` }
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"` // Module is a flag to use module-controlled decoding. The string is an encoding scheme name // that a module must handle. When using this variant, the scheme name must not be empty. Module string `json:"module,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 { Format CallFormat `json:"format,omitempty"` Method string `json:"method,omitempty"` Body cbor.RawMessage `json:"body"` ReadOnly bool `json:"ro,omitempty"` }
Call is a method call.
type CallEnvelopeX25519DeoxysII ¶ added in v0.2.0
type CallEnvelopeX25519DeoxysII struct { // Pk is the caller's ephemeral public key used for X25519. Pk [32]byte `json:"pk"` // Nonce. Nonce [deoxysii.NonceSize]byte `json:"nonce"` // Data is the encrypted call data. Data []byte `json:"data"` }
CallEnvelopeX25519DeoxysII is a call envelope when using the EncryptedX25519DeoxysII format.
type CallFormat ¶ added in v0.2.0
type CallFormat uint8
CallFormat is the format used for encoding the call (and output) information.
func (CallFormat) String ¶ added in v0.3.0
func (cf CallFormat) String() string
String returns a string representation of the call format.
type CallResult ¶
type CallResult struct { Ok cbor.RawMessage `json:"ok,omitempty"` Failed *FailedCallResult `json:"fail,omitempty"` Unknown cbor.RawMessage `json:"unknown,omitempty"` }
CallResult is the method call result.
func (*CallResult) IsSuccess ¶
func (cr *CallResult) IsSuccess() bool
IsSuccess checks whether the call result indicates success.
func (*CallResult) IsUnknown ¶ added in v0.2.0
func (cr *CallResult) IsUnknown() bool
IsUnknown checks whether the call result is unknown.
type CallerAddress ¶ added in v0.2.0
type CallerAddress struct { // Address is an oasis address. Address *Address `json:"address,omitempty"` // EthAddress is an ethereum address. EthAddress *[20]byte `json:"eth_address,omitempty"` }
CallerAddress is a caller address.
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 Event ¶ added in v0.2.0
Event is an event emitted by a runtime in the form of a runtime transaction tag.
Key and value semantics are runtime-dependent.
type EventKey ¶ added in v0.2.0
type EventKey []byte
EventKey is an event tag key.
func NewEventKey ¶ added in v0.2.0
NewEventKey generates an event tag key from a module name and event code.
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 Fee ¶
type Fee struct { Amount BaseUnits `json:"amount"` Gas uint64 `json:"gas,omitempty"` ConsensusMessages uint32 `json:"consensus_messages,omitempty"` }
Fee contains the transaction fee information.
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 PrettyCall ¶ added in v0.3.0
type PrettyCall struct { Format CallFormat `json:"format,omitempty"` Method string `json:"method,omitempty"` Body interface{} `json:"body"` }
PrettyCall returns a representation of the type that can be used for pretty printing.
type PrettyTransaction ¶ added in v0.3.0
type PrettyTransaction struct { cbor.Versioned Call PrettyCall `json:"call"` AuthInfo AuthInfo `json:"ai"` }
PrettyTransaction returns a representation of the type that can be used for pretty printing.
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 ResultEnvelopeX25519DeoxysII ¶ added in v0.2.0
type ResultEnvelopeX25519DeoxysII struct { // Nonce. Nonce [deoxysii.NonceSize]byte `json:"nonce"` // Data is the encrypted result data. Data []byte `json:"data"` }
ResultEnvelopeX25519DeoxysII is a result envelope when using the EncryptedX25519DeoxysII format.
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 SignatureAddressSpec ¶ added in v0.2.0
type SignatureAddressSpec struct { // Ed25519 address derivation compatible with the consensus layer. Ed25519 *ed25519.PublicKey `json:"ed25519,omitempty"` // Secp256k1Eth is ethereum-compatible address derivation from Secp256k1 public keys. Secp256k1Eth *secp256k1.PublicKey `json:"secp256k1eth,omitempty"` // Sr25519 address derivation. Sr25519 *sr25519.PublicKey `json:"sr25519,omitempty"` }
SignatureAddressSpec is information for signature-based authentication and public key-based address derivation.
func NewSignatureAddressSpecEd25519 ¶ added in v0.2.0
func NewSignatureAddressSpecEd25519(pk ed25519.PublicKey) SignatureAddressSpec
NewSignatureAddressSpecEd25519 creates a new address specification for an Ed25519 public key.
func NewSignatureAddressSpecSecp256k1Eth ¶ added in v0.2.0
func NewSignatureAddressSpecSecp256k1Eth(pk secp256k1.PublicKey) SignatureAddressSpec
NewSignatureAddressSpecSecp256k1Eth creates a new Ethereum-compatible address specification for an Secp256k1 public key.
func NewSignatureAddressSpecSr25519 ¶ added in v0.2.0
func NewSignatureAddressSpecSr25519(pk sr25519.PublicKey) SignatureAddressSpec
NewSignatureAddressSpecSr25519 creates a new address specification for an Sr25519 public key.
func (*SignatureAddressSpec) PublicKey ¶ added in v0.2.0
func (as *SignatureAddressSpec) PublicKey() PublicKey
PublicKey returns the public key of the authentication/address derivation specification.
type SignedPublicKey ¶ added in v0.2.0
type SignedPublicKey struct { // PublicKey is the requested public key. PublicKey [32]byte `json:"key"` // Checksum is the checksum of the key manager state. Checksum []byte `json:"checksum"` // Signature is the Sign(sk, (key || checksum)) from the key manager. Signature signature.RawSignature `json:"signature"` }
SignedPublicKey is the public key signed by the key manager.
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 NewEncryptedTransaction ¶ added in v0.3.0
func NewEncryptedTransaction(fee *Fee, body interface{}) *Transaction
NewEncryptedTransaction creates a new unsigned 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(spec SignatureAddressSpec, 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) PrettyType ¶ added in v0.3.0
func (t *Transaction) PrettyType(txBody interface{}) (*PrettyTransaction, error)
PrettyType returns a representation of the Transaction that can be used for pretty printing.
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) Hash ¶ added in v0.2.0
func (ut *UnverifiedTransaction) Hash() hash.Hash
Hash returns the cryptographic hash of the encoded transaction.
func (*UnverifiedTransaction) Verify ¶
func (ut *UnverifiedTransaction) Verify(ctx signature.Context) (*Transaction, error)
Verify verifies and deserializes the unverified transaction.