Documentation ¶
Index ¶
- Constants
- func Add(a, b int) int
- func AesDecrypt(cipherText, key []byte) ([]byte, error)
- func AesEncrypt(data, key []byte) ([]byte, error)
- func DecodeVarInt(bytes []byte) (uint64, []byte)
- func DeriveAddress(seed []byte, index uint32, curve Curve, hashAlgo HashAlgo) ([]byte, error)
- func DeriveArchethicKeypair(seed []byte, derivationPath string, index uint8, curve Curve) ([]byte, []byte, error)
- func DeriveArchethicKeypairWithSuffix(seed []byte, derivationPath string, index uint8, curve Curve, ...) ([]byte, []byte, error)
- func DeriveKeypair(seed []byte, index uint32, curve Curve) ([]byte, []byte, error)
- func DeserializeTypedData(bin []byte) (any, []byte, error)
- func EcDecrypt(cipherText []byte, privateKey []byte) ([]byte, error)
- func EcEncrypt(data []byte, publicKey []byte) ([]byte, error)
- func EncodeInt32(number uint32) []byte
- func EncodeInt64(number uint64) []byte
- func EncodeVarInt(number uint64) []byte
- func FormatBigInt(b *big.Int, formatDecimals uint8) string
- func FromBigInt(number uint64) float64
- func GenerateDeterministicKeypair(pvKey []byte, curve Curve, originID OriginID) ([]byte, []byte, error)
- func Hash(content []byte, hashAlgo HashAlgo) ([]byte, error)
- func KeyToJWK(publicKey []byte, keyId string) (map[string]string, error)
- func MaybeConvertToHex(inputString string) ([]byte, error)
- func OriginPrivateKey() []byte
- func ParseBigInt(number string, formatDecimals uint) (*big.Int, error)
- func SerializeTypedData(val interface{}) ([]byte, error)
- func Sign(privateKey []byte, data []byte) ([]byte, error)
- func ToBigInt(number float64) uint64
- func ToUint64(number float64, decimals int) (uint64, error)
- func Verify(sig []byte, data []byte, publicKey []byte) (bool, error)
- type APIClient
- func (c *APIClient) AddOriginKey(originPublicKey, certificate string) (SendTransactionResponse, error)
- func (c *APIClient) GetBalance(address string) (Balance, error)
- func (c *APIClient) GetLastTransactionIndex(address string) uint
- func (c *APIClient) GetLastTransactionOwnerships(address string) ([]Ownership, error)
- func (c *APIClient) GetNearestEndpoints() (*NearestEndpointsGQL, error)
- func (c *APIClient) GetOracleData(timestamp ...int64) (OracleData, error)
- func (c *APIClient) GetStorageNoncePublicKey() (string, error)
- func (c *APIClient) GetToken(address string) (Token, error)
- func (c *APIClient) GetTransactionFee(tx *TransactionBuilder) (Fee, error)
- func (c *APIClient) GetTransactionOwnerships(address string) ([]Ownership, error)
- func (c *APIClient) InjectHTTPClient(httpClient *http.Client)
- func (c *APIClient) SendTransaction(tx *TransactionBuilder) (SendTransactionResponse, error)
- func (c *APIClient) SimulateContractExecution(tx *TransactionBuilder) ([]SimulateResponse, error)
- func (c *APIClient) SubscribeToOracleUpdates(handler func(OracleData))
- type AbsintheSubscription
- type Address
- type AuthorizedKey
- type Balance
- type BalanceGQL
- type Curve
- type DID
- type DIDKeyMaterial
- type EncodedType
- type ErrorContext
- type ErrorDetails
- type Fee
- type HashAlgo
- type Hex
- type Keychain
- func (k *Keychain) AddAuthorizedPublicKey(publicKey []byte)
- func (k *Keychain) AddService(name string, derivationPath string, curve Curve, hashAlgo HashAlgo)
- func (k Keychain) BuildTransaction(transaction *TransactionBuilder, serviceName string, index uint8) error
- func (k Keychain) DeriveAddress(serviceName string, index uint8) ([]byte, error)
- func (k Keychain) DeriveKeypair(serviceName string, index uint8) ([]byte, []byte, error)
- func (k Keychain) DeriveKeypairWithSuffix(serviceName string, index uint8, pathSuffix string) ([]byte, []byte, error)
- func (k *Keychain) RemoveAuthorizedPublicKey(publicKey []byte)
- func (k *Keychain) RemoveService(name string)
- func (k Keychain) ToDID() (*DID, error)
- type LastTransactionOwnershipsGQL
- type Ledger
- type NearestEndpointsGQL
- type OracleData
- type OriginID
- type Ownership
- type OwnershipGQL
- type PublicKey
- type Recipient
- type SendTransactionResponse
- type Service
- type SimulateResponse
- type SimulateResponseError
- type Timeout
- type Timestamp
- type Token
- type TokenGQL
- type TokenLedger
- type TokenProperties
- type TokenTransfer
- type TransactionBuilder
- func (t *TransactionBuilder) AddOwnership(secret []byte, authorizedKeys []AuthorizedKey)
- func (t *TransactionBuilder) AddRecipient(address []byte)
- func (t *TransactionBuilder) AddRecipientWithNamedAction(address []byte, action []byte, args []interface{})
- func (t *TransactionBuilder) AddTokenTransfer(to []byte, tokenAddress []byte, amount *big.Int, tokenId uint)
- func (t *TransactionBuilder) AddUcoTransfer(to []byte, amount *big.Int)
- func (t *TransactionBuilder) Build(seed []byte, index uint32, curve Curve, hashAlgo HashAlgo) error
- func (t *TransactionBuilder) OriginSign(originPrivateKey []byte) error
- func (t TransactionBuilder) OriginSignaturePayload() []byte
- func (t *TransactionBuilder) SetAddress(address []byte)
- func (t *TransactionBuilder) SetCode(code string)
- func (t *TransactionBuilder) SetContent(content []byte)
- func (tx *TransactionBuilder) SetPreviousSignatureAndPreviousPublicKey(prevSign []byte, prevPubKey []byte)
- func (t *TransactionBuilder) SetType(txType TransactionType)
- func (t *TransactionBuilder) ToJSONMap() (map[string]interface{}, error)
- type TransactionConfirmedGQL
- type TransactionData
- type TransactionErrorGQL
- type TransactionOwnershipsGQL
- type TransactionSender
- func (ts *TransactionSender) AddOnConfirmation(handler func(nbConfirmations, maxConfirmations uint))
- func (ts *TransactionSender) AddOnError(handler func(senderContext string, error ErrorDetails))
- func (ts *TransactionSender) AddOnFullConfirmation(handler func(maxConfirmations uint))
- func (ts *TransactionSender) AddOnRequiredConfirmation(handler func(nbConfirmations uint))
- func (ts *TransactionSender) AddOnSent(handler func())
- func (ts *TransactionSender) AddOnTimeout(handler func(nbConfirmationReceived uint))
- func (ts *TransactionSender) SendTransaction(tx *TransactionBuilder, confirmationThreshold, timeout uint) error
- func (ts *TransactionSender) SubscribeTransactionConfirmed(transactionAddress string, readyHandler func(), ...)
- func (ts *TransactionSender) SubscribeTransactionError(transactionAddress string, readyHandler func(), ...)
- func (ts *TransactionSender) Unsubscribe(event string) error
- type TransactionType
- type UcoLedger
- type UcoTransfer
Constants ¶
const ( INVALID_TRANSACTION = "INVALID_TRANSACTION" NETWORK_ISSUE = "NETWORK_ISSUE" )
const ( Version uint32 = 3 KeychainType TransactionType = 255 KeychainAccessType TransactionType = 254 TransferType TransactionType = 253 HostingType TransactionType = 252 TokenType TransactionType = 251 DataType TransactionType = 250 ContractType TransactionType = 249 CodeProposalType TransactionType = 5 CodeApprovalType TransactionType = 6 )
Variables ¶
This section is empty.
Functions ¶
func AesDecrypt ¶
func AesEncrypt ¶
func DecodeVarInt ¶ added in v1.0.8
DecodeVarInt convert a VarInt binary into a integer
func DeriveAddress ¶
func DeriveArchethicKeypair ¶
func DeriveArchethicKeypairWithSuffix ¶ added in v1.0.10
func DeriveKeypair ¶
DeriveKeypair generate a keypair using a derivation function with a seed and an index. Each keys is prepending with a curve identification.
func DeserializeTypedData ¶ added in v1.0.8
func EncodeInt32 ¶
func EncodeInt64 ¶
func EncodeVarInt ¶ added in v1.0.8
EncodeVarInt converts a number into a VarInt binary
func FromBigInt ¶ added in v1.0.8
func GenerateDeterministicKeypair ¶
func GenerateDeterministicKeypair(pvKey []byte, curve Curve, originID OriginID) ([]byte, []byte, error)
GenerateDeterministicKeypair generate a new keypair deterministically with a given private key, curve and origin id
func Hash ¶
Hash create a hash digest from the data with an hash algorithm identification prepending the digest
func MaybeConvertToHex ¶
MaybeConvertToHex converts a string to a byte array if it is a hex string, otherwise it returns the string as a byte array
func OriginPrivateKey ¶ added in v1.0.9
func OriginPrivateKey() []byte
func ParseBigInt ¶ added in v1.0.11
func SerializeTypedData ¶ added in v1.0.8
Types ¶
type APIClient ¶
type APIClient struct {
// contains filtered or unexported fields
}
func NewAPIClient ¶
func (*APIClient) AddOriginKey ¶
func (c *APIClient) AddOriginKey(originPublicKey, certificate string) (SendTransactionResponse, error)
func (*APIClient) GetLastTransactionIndex ¶
func (*APIClient) GetLastTransactionOwnerships ¶
func (*APIClient) GetNearestEndpoints ¶
func (c *APIClient) GetNearestEndpoints() (*NearestEndpointsGQL, error)
func (*APIClient) GetOracleData ¶
func (c *APIClient) GetOracleData(timestamp ...int64) (OracleData, error)
func (*APIClient) GetStorageNoncePublicKey ¶
func (*APIClient) GetTransactionFee ¶
func (c *APIClient) GetTransactionFee(tx *TransactionBuilder) (Fee, error)
func (*APIClient) GetTransactionOwnerships ¶
func (*APIClient) InjectHTTPClient ¶
func (*APIClient) SendTransaction ¶ added in v1.0.4
func (c *APIClient) SendTransaction(tx *TransactionBuilder) (SendTransactionResponse, error)
func (*APIClient) SimulateContractExecution ¶ added in v1.0.4
func (c *APIClient) SimulateContractExecution(tx *TransactionBuilder) ([]SimulateResponse, error)
func (*APIClient) SubscribeToOracleUpdates ¶
func (c *APIClient) SubscribeToOracleUpdates(handler func(OracleData))
type AbsintheSubscription ¶
type AbsintheSubscription struct {
// contains filtered or unexported fields
}
func (*AbsintheSubscription) CancelSubscription ¶
func (a *AbsintheSubscription) CancelSubscription()
func (*AbsintheSubscription) GraphqlSubscription ¶
type AuthorizedKey ¶
type BalanceGQL ¶
type DID ¶
type DID struct { Context []string `json:"@context"` Id string `json:"id"` Authentication []string `json:"authentication"` VerificationMethod []DIDKeyMaterial `json:"verificationMethod"` }
type DIDKeyMaterial ¶
type EncodedType ¶ added in v1.0.8
type EncodedType uint8
const ( IntegerType EncodedType = 0 FloatType EncodedType = 1 StringType EncodedType = 2 ListType EncodedType = 3 MapType EncodedType = 4 BoolType EncodedType = 5 NilType EncodedType = 6 )
type ErrorContext ¶
type ErrorContext string
type ErrorDetails ¶ added in v1.0.10
type ErrorDetails struct { Code int `json:"code"` Data any `json:"data"` Message string `json:"message"` }
func (ErrorDetails) Error ¶ added in v1.0.10
func (e ErrorDetails) Error() string
ErrorDetails implements error interface.
type Keychain ¶
type Keychain struct { Seed []byte Version uint8 Services map[string]Service AuthorizedPublicKeys [][]byte }
func DecodeKeychain ¶
func NewKeychain ¶
NewKeychain instanciates a new Keychain struct
func (*Keychain) AddAuthorizedPublicKey ¶
func (*Keychain) AddService ¶
func (Keychain) BuildTransaction ¶
func (k Keychain) BuildTransaction(transaction *TransactionBuilder, serviceName string, index uint8) error
func (Keychain) DeriveAddress ¶
func (Keychain) DeriveKeypair ¶
func (Keychain) DeriveKeypairWithSuffix ¶ added in v1.0.10
func (*Keychain) RemoveAuthorizedPublicKey ¶
func (*Keychain) RemoveService ¶
type LastTransactionOwnershipsGQL ¶
type LastTransactionOwnershipsGQL struct { LastTransaction struct { Data struct { Ownerships []OwnershipGQL } } `graphql:"lastTransaction(address: $address)"` }
type Ledger ¶
type Ledger struct { Uco UcoLedger Token TokenLedger }
type NearestEndpointsGQL ¶
type OracleData ¶
type Ownership ¶
type Ownership struct { Secret []byte AuthorizedKeys []AuthorizedKey }
type OwnershipGQL ¶
type SendTransactionResponse ¶ added in v1.0.4
type SimulateResponse ¶ added in v1.0.4
type SimulateResponse struct { RecipientAddress string `json:"recipient_address"` Valid bool Error SimulateResponseError }
type SimulateResponseError ¶ added in v1.0.4
type TokenLedger ¶
type TokenLedger struct {
Transfers []TokenTransfer
}
type TokenProperties ¶
type TokenProperties map[string]interface{}
type TokenTransfer ¶
type TransactionBuilder ¶
type TransactionBuilder struct { Version uint32 Address []byte TxType TransactionType Data TransactionData PreviousPublicKey []byte PreviousSignature []byte OriginSignature []byte }
func NewAccessTransaction ¶
func NewAccessTransaction(seed []byte, keychainAddress []byte) (*TransactionBuilder, error)
func NewKeychainTransaction ¶
func NewKeychainTransaction(keychain *Keychain, transactionChainIndex uint32) (*TransactionBuilder, error)
func NewTransaction ¶
func NewTransaction(txType TransactionType) *TransactionBuilder
New transaction builder instance
func (*TransactionBuilder) AddOwnership ¶
func (t *TransactionBuilder) AddOwnership(secret []byte, authorizedKeys []AuthorizedKey)
func (*TransactionBuilder) AddRecipient ¶
func (t *TransactionBuilder) AddRecipient(address []byte)
func (*TransactionBuilder) AddRecipientWithNamedAction ¶ added in v1.0.5
func (t *TransactionBuilder) AddRecipientWithNamedAction(address []byte, action []byte, args []interface{})
func (*TransactionBuilder) AddTokenTransfer ¶
func (*TransactionBuilder) AddUcoTransfer ¶
func (t *TransactionBuilder) AddUcoTransfer(to []byte, amount *big.Int)
func (*TransactionBuilder) OriginSign ¶
func (t *TransactionBuilder) OriginSign(originPrivateKey []byte) error
func (TransactionBuilder) OriginSignaturePayload ¶
func (t TransactionBuilder) OriginSignaturePayload() []byte
func (*TransactionBuilder) SetAddress ¶
func (t *TransactionBuilder) SetAddress(address []byte)
func (*TransactionBuilder) SetCode ¶
func (t *TransactionBuilder) SetCode(code string)
func (*TransactionBuilder) SetContent ¶
func (t *TransactionBuilder) SetContent(content []byte)
func (*TransactionBuilder) SetPreviousSignatureAndPreviousPublicKey ¶
func (tx *TransactionBuilder) SetPreviousSignatureAndPreviousPublicKey(prevSign []byte, prevPubKey []byte)
func (*TransactionBuilder) SetType ¶
func (t *TransactionBuilder) SetType(txType TransactionType)
func (*TransactionBuilder) ToJSONMap ¶ added in v1.0.4
func (t *TransactionBuilder) ToJSONMap() (map[string]interface{}, error)
type TransactionConfirmedGQL ¶
type TransactionData ¶
type TransactionErrorGQL ¶
type TransactionErrorGQL struct { Context ErrorContext Error ErrorDetails }
type TransactionOwnershipsGQL ¶
type TransactionOwnershipsGQL struct { Transaction struct { Data struct { Ownerships []OwnershipGQL } } `graphql:"transaction(address: $address)"` }
type TransactionSender ¶
type TransactionSender struct {
// contains filtered or unexported fields
}
func NewTransactionSender ¶
func NewTransactionSender(client *APIClient) *TransactionSender
func (*TransactionSender) AddOnConfirmation ¶
func (ts *TransactionSender) AddOnConfirmation(handler func(nbConfirmations, maxConfirmations uint))
func (*TransactionSender) AddOnError ¶
func (ts *TransactionSender) AddOnError(handler func(senderContext string, error ErrorDetails))
func (*TransactionSender) AddOnFullConfirmation ¶
func (ts *TransactionSender) AddOnFullConfirmation(handler func(maxConfirmations uint))
func (*TransactionSender) AddOnRequiredConfirmation ¶
func (ts *TransactionSender) AddOnRequiredConfirmation(handler func(nbConfirmations uint))
func (*TransactionSender) AddOnSent ¶
func (ts *TransactionSender) AddOnSent(handler func())
func (*TransactionSender) AddOnTimeout ¶
func (ts *TransactionSender) AddOnTimeout(handler func(nbConfirmationReceived uint))
func (*TransactionSender) SendTransaction ¶
func (ts *TransactionSender) SendTransaction(tx *TransactionBuilder, confirmationThreshold, timeout uint) error
func (*TransactionSender) SubscribeTransactionConfirmed ¶
func (ts *TransactionSender) SubscribeTransactionConfirmed(transactionAddress string, readyHandler func(), handler func(TransactionConfirmedGQL))
func (*TransactionSender) SubscribeTransactionError ¶
func (ts *TransactionSender) SubscribeTransactionError(transactionAddress string, readyHandler func(), handler func(TransactionErrorGQL))
func (*TransactionSender) Unsubscribe ¶
func (ts *TransactionSender) Unsubscribe(event string) error
type TransactionType ¶
type TransactionType uint8
func (TransactionType) String ¶
func (t TransactionType) String() (string, error)
type UcoLedger ¶
type UcoLedger struct {
Transfers []UcoTransfer
}