Documentation
¶
Overview ¶
Package janzeer is the official Go SDK of the Janzeer blockchain: keys and addresses, exact amounts, transaction builders and signing. The network clients live in the sub-packages client (REST), rpc (JSON-RPC over HTTP and WebSocket) and vault (a secret at rest).
Non-custodial by construction: keys never leave your process; the node only verifies.
me, _ := janzeer.AccountFromMnemonic("abandon … about", "")
c := client.New("https://onion.janzeer.org")
nonce, _ := c.Nonce(ctx, me.Address())
tx, _ := janzeer.NewTransfer(janzeer.Transfer{From: me.Address(), To: "0x…", Amount: "1.25", Nonce: nonce})
signed, _ := me.SignTx(tx)
_, err := c.Submit(ctx, signed)
Index ¶
- Constants
- func AddAmounts(a, b string) (string, error)
- func CompareAmounts(a, b string) (int, error)
- func DoubleSHA256(data []byte) []byte
- func FormatJNZ(amount string, o FormatOptions) (string, error)
- func FromScaled(scaled *big.Int) string
- func GenerateMnemonic(strength int) (string, error)
- func HashPreimage(preimage []byte) string
- func HexToBytes(s string) ([]byte, error)
- func IsRPCCode(err error, code int) bool
- func IsValidAddress(address string) bool
- func IsValidAmount(s string) bool
- func IsValidPrivateKey(privateKeyHex string) bool
- func Keccak256(data []byte) []byte
- func MnemonicFromEntropy(entropy []byte) (string, error)
- func MnemonicToEntropy(mnemonic string) ([]byte, error)
- func MnemonicToSeed(mnemonic, passphrase string) []byte
- func NormalizeAddress(address string) (string, error)
- func NormalizeAmount(s string) (string, error)
- func NormalizeMnemonic(mnemonic string) string
- func ParseJNZ(input string) (string, error)
- func PrivateToPublic(privateKeyHex string) (string, error)
- func PublicKeyToAddress(compressedPublicKey []byte) (string, error)
- func RESTErrorFrom(status int, body []byte, retryAfter string) error
- func RPCErrorFrom(code int, message string, data json.RawMessage, transport string) error
- func SignHash(hashHex, privateKeyHex string) (string, error)
- func SubAmounts(a, b string) (string, error)
- func ToChecksumAddress(address string) string
- func ToScaled(amount string) (*big.Int, error)
- func ValidateMnemonic(mnemonic string) bool
- func VerifyHash(hashHex, signatureBase64, publicKeyHex string) bool
- func Wordlist() []string
- type APIError
- type Account
- func (a *Account) Address() string
- func (a *Account) ChecksumAddress() string
- func (a *Account) GoString() string
- func (a *Account) PrivateKeyHex() string
- func (a *Account) PublicKeyHex() string
- func (a *Account) Sign(hashHex string) (string, error)
- func (a *Account) SignTx(tx *UnsignedTx) (*SignedTx, error)
- func (a *Account) String() string
- func (a *Account) Verify(hashHex, signatureBase64 string) bool
- type AccountView
- type AddressTransactions
- type Amount
- type BlockView
- type Common
- type ExitValidator
- type FeeEstimate
- type FinalityTimeoutError
- type FormatOptions
- type HDNode
- type NetworkError
- type NodeInfo
- type NonceMismatchError
- type NotFoundError
- type NotSynchronizedError
- type Page
- type RPCError
- type RPCMethodSpec
- type RateLimitedError
- type Receipt
- type RegisterValidator
- type SendResult
- type SignedTx
- type Token
- type TokenBalance
- type TokenOp
- type TokenView
- type Transaction
- type Transfer
- type TxRejectedError
- type TxType
- type TxView
- type UnsignedTx
- func NewExitValidator(o ExitValidator) (*UnsignedTx, error)
- func NewRegisterValidator(o RegisterValidator) (*UnsignedTx, error)
- func NewTokenBurn(o Token) (*UnsignedTx, error)
- func NewTokenCreate(o Token) (*UnsignedTx, error)
- func NewTokenMint(o Token) (*UnsignedTx, error)
- func NewTokenSetCap(o Token) (*UnsignedTx, error)
- func NewTokenTransfer(o Token) (*UnsignedTx, error)
- func NewTransfer(o Transfer) (*UnsignedTx, error)
- type ValidationError
- type Validator
- type ValidatorInfo
Constants ¶
const ( // HDSalt is used BOTH as the PBKDF2 salt base (instead of BIP39's "mnemonic") AND as the root HMAC key. HDSalt = "@_Janzeer_Blockchain_@" // DefaultPath is the only derivation path wallets use; all three levels are non-hardened. DefaultPath = "m/0/0/0" )
const ( RPCParseError = -32700 RPCInvalidRequest = -32600 RPCMethodNotFound = -32601 RPCInvalidParams = -32602 RPCInternal = -32603 RPCNotFound = -32000 RPCRejected = -32001 RPCNotSynchronized = -32002 RPCLimit = -32003 RPCRateLimited = -32004 )
JSON-RPC error codes of the node.
const ( // NetworkID is consensus.network-id, bound into every signed transaction (cross-network replay protection). NetworkID = "janzeer" // Decimals of the native coin: amounts are scaled x10^8 into an int64 on the wire. Decimals = 8 // Ticker is the display ticker of the native coin. Ticker = "JNZ" // MinFee is the minimum fee of every transaction, in JNZ. MinFee = "0.01" // MinTransfer is the minimum transfer amount in JNZ unless the transfer carries a memo. MinTransfer = "0.1" // MaxMemoBytes is the maximum memo length in UTF-8 bytes. MaxMemoBytes = 256 // ValidatorFee is the exact fee of a validator registration. ValidatorFee = "3" // ValidatorDeposit is the exact, NON-REFUNDABLE deposit of a validator registration. ValidatorDeposit = "2000" // TokenCreateFee is the exact fee of a token CREATE; every other token operation pays MinFee. TokenCreateFee = "5" )
Chain constants. Every value mirrors the node and is pinned by the conformance vectors or the e2e flow.
const ( SpecNode = "0.1.14" SpecAPI = "1.1.0" SpecProtocol = "3.4.0" SpecVectors = 2 )
The node, API and wire-protocol versions this SDK release was built and tested against.
const ( LimitPageSize = 100 LimitBlockRange = 100 LimitWaitForFinalityMs = 60_000 LimitSubscriptions = 16 LimitWatchedAddresses = 1000 LimitRPCBatch = 50 LimitRPCBodyBytes = 524_288 )
Server-side limits (informational; the node enforces them).
const NoDecimals = -1
NoDecimals asks FormatJNZ for whole coins only.
Variables ¶
This section is empty.
Functions ¶
func AddAmounts ¶
AddAmounts returns a + b exactly, as a canonical 8-decimal string.
func CompareAmounts ¶
CompareAmounts compares two amounts exactly: -1, 0 or 1.
func DoubleSHA256 ¶
DoubleSHA256 is the transaction hash function.
func FormatJNZ ¶
func FormatJNZ(amount string, o FormatOptions) (string, error)
FormatJNZ renders an amount for people: FormatJNZ("1.50000000", FormatOptions{}) == "1.5 JNZ".
func FromScaled ¶
FromScaled is the inverse of ToScaled: base units -> a decimal string with exactly 8 fractional digits.
func GenerateMnemonic ¶
GenerateMnemonic returns a fresh mnemonic from the OS random source: strength 128 (12 words) … 256 (24 words).
func HashPreimage ¶
HashPreimage is double-SHA256 as lowercase hex: what the node calls the transaction hash.
func HexToBytes ¶
HexToBytes decodes hex with an optional 0x prefix, either case.
func IsValidAddress ¶
IsValidAddress checks shape and checksum the way the node does: all-lowercase, all-uppercase, or correct EIP-55.
func IsValidAmount ¶
IsValidAmount reports whether s is a plain decimal with at most 8 fractional digits (what the node accepts).
func IsValidPrivateKey ¶
IsValidPrivateKey reports whether the hex string is a valid secp256k1 scalar (32 bytes, 0 < k < n).
func Keccak256 ¶
Keccak256 is the Ethereum variant of Keccak, NOT NIST SHA3-256 (the padding differs).
func MnemonicFromEntropy ¶
MnemonicFromEntropy turns 16, 20, 24, 28 or 32 bytes of entropy into a mnemonic.
func MnemonicToEntropy ¶
MnemonicToEntropy returns the entropy of a mnemonic, or an error for an unknown word, a bad length or a bad checksum.
func MnemonicToSeed ¶
MnemonicToSeed is PBKDF2-HMAC-SHA512, 2048 rounds, 64 bytes, salt HDSalt + passphrase (NFKD inputs).
func NormalizeAddress ¶
NormalizeAddress returns the canonical lowercase form, or an error for an invalid address.
func NormalizeAmount ¶
NormalizeAmount checks that s is a plain decimal (no exponent, no "+") and returns it trimmed.
func NormalizeMnemonic ¶
NormalizeMnemonic normalizes whitespace and case so equivalent phrases derive the same seed.
func ParseJNZ ¶
ParseJNZ turns user input like "1,234.5 JNZ" into a canonical amount string ("1234.5").
func PrivateToPublic ¶
PrivateToPublic returns the compressed (33-byte) public key, hex.
func PublicKeyToAddress ¶
PublicKeyToAddress is the CANONICAL address: "0x" + lowercase hex of the first 20 bytes of keccak256(compressed key).
func RESTErrorFrom ¶
RESTErrorFrom maps a non-2xx REST response to the SDK error types. Rule: a body with "payload" -> use it (the envelope wraps errors too); otherwise the body itself (the rate limiter answers before the envelope layer).
func RPCErrorFrom ¶
RPCErrorFrom maps a JSON-RPC error object to the SDK error types. transport is "rpc" or "ws".
func SignHash ¶
SignHash signs a 32-byte digest (hex): RFC-6979 deterministic, low-S, DER, Base64. The digest is signed as-is.
func SubAmounts ¶
SubAmounts returns a - b exactly, as a canonical 8-decimal string.
func ToChecksumAddress ¶
ToChecksumAddress is the EIP-55 mixed-case display form. Presentation only: never sign or store it.
func ToScaled ¶
ToScaled is the node's toScaledLong: BigDecimal(amount).setScale(8, HALF_UP) x 10^8 as an integer of base units. Pinned by the "scaled" table of the conformance vectors.
func ValidateMnemonic ¶
ValidateMnemonic checks word-list membership and the checksum. Client-side only: the node never sees a mnemonic.
func VerifyHash ¶
VerifyHash verifies a Base64 DER signature over a digest (hex) with a compressed public key (hex). High-S is refused.
Types ¶
type APIError ¶
type APIError struct {
Status int
Message string
Type string
Body json.RawMessage
}
APIError: any other REST error ({status, message, type?} payload).
type Account ¶
type Account struct {
// contains filtered or unexported fields
}
Account is a signing identity: private key -> public key -> address. The node never sees the private key. Printing an Account shows the address only.
func AccountFromMnemonic ¶
AccountFromMnemonic derives the wallet account of a BIP39 mnemonic (Janzeer seed, path m/0/0/0).
func AccountFromPrivateKey ¶
AccountFromPrivateKey imports a raw private key (hex, optional 0x).
func AccountFromSeed ¶
AccountFromSeed derives an account from a 64-byte seed and a non-hardened path.
func NewRandomAccount ¶
NewRandomAccount creates a fresh random key (not mnemonic-backed; prefer GenerateMnemonic for user wallets).
func (*Account) ChecksumAddress ¶
ChecksumAddress is the EIP-55 display form of the address.
func (*Account) PrivateKeyHex ¶
PrivateKeyHex returns the private key as hex. Handle with care: never log or send it.
func (*Account) PublicKeyHex ¶
PublicKeyHex is the compressed secp256k1 public key, hex (66 chars).
func (*Account) Sign ¶
Sign returns the RFC-6979 low-S DER signature (Base64) over a 32-byte digest given as hex.
type AccountView ¶
type AccountView struct {
Address string `json:"address"`
Balance Amount `json:"balance"`
CommittedBalance Amount `json:"committedBalance"`
NextNonce int64 `json:"nextNonce"`
CommittedNonce int64 `json:"committedNonce"`
PendingCount int `json:"pendingCount"`
IsValidatorWallet bool `json:"isValidatorWallet"`
}
AccountView is janzeer_getAccount.
type AddressTransactions ¶ added in v0.1.6
type AddressTransactions struct {
Total int64 `json:"total"`
List []TxView `json:"list"`
Page int `json:"page"`
PageSize int `json:"pageSize"`
TotalPages int `json:"totalPages"`
Pending []TxView `json:"pending"`
}
AddressTransactions is janzeer_getTransactionsByAddress (paged historical transactions + pending mempool list).
type Amount ¶
type Amount string
Amount is a decimal number exactly as the node wrote it ("1.25000000", "77499900.002"). The node serializes coin amounts as bare JSON numbers; decoding them into a float64 would round. Amount keeps the source text.
func (Amount) MarshalJSON ¶
MarshalJSON writes the amount as a JSON string.
func (*Amount) UnmarshalJSON ¶
UnmarshalJSON accepts a JSON number or a JSON string and keeps its exact text (an exponent is expanded).
type BlockView ¶
type BlockView struct {
Type string `json:"type"`
Height int64 `json:"height"`
Hash string `json:"hash"`
PreviousHash string `json:"previousHash"`
Timestamp int64 `json:"timestamp"`
Producer string `json:"producer"`
Signature string `json:"signature"`
EpochIndex *int64 `json:"epochIndex"`
TransactionsCount int `json:"transactionsCount"`
Validators []string `json:"validators"`
Transactions []TxView `json:"transactions"`
}
BlockView is a block as the JSON-RPC methods and the newBlocks feed return it.
type Common ¶
type Common struct {
// From is the sender address (an EIP-55 address is normalized).
From string
// Nonce is the sender's next nonce (committed nonce + pending count).
Nonce int64
// Fee defaults to the type's required or minimum fee.
Fee string
// Timestamp in ms since epoch; defaults to now.
Timestamp int64
// NetworkID defaults to NetworkID ("janzeer"); pass the node's id when working on a private test network.
NetworkID string
}
Common holds the fields every builder takes. Nonce comes from the node (client.Nonce).
type ExitValidator ¶
ExitValidator describes a validator exit.
type FeeEstimate ¶
type FeeEstimate struct {
Kind string `json:"kind"`
Fee Amount `json:"fee"`
Rule string `json:"rule"`
FeeMarket bool `json:"feeMarket"`
}
FeeEstimate is janzeer_estimateFee.
type FinalityTimeoutError ¶
FinalityTimeoutError: the wait deadline passed; Last is the most recent view (possibly nil).
func (*FinalityTimeoutError) Error ¶
func (e *FinalityTimeoutError) Error() string
type FormatOptions ¶
type FormatOptions struct {
// Decimals to keep (0 means the default 8; use NoDecimals for none). Digits beyond are truncated, never rounded.
Decimals int
// KeepZeros keeps trailing zeros instead of trimming them.
KeepZeros bool
// NoTicker omits the " JNZ" suffix.
NoTicker bool
// Group separates thousands with ",".
Group bool
}
FormatOptions controls FormatJNZ. The zero value means: 8 decimals, trimmed, with the ticker, ungrouped.
type HDNode ¶
HDNode is an extended private key: a 32-byte private key and a 32-byte chain code.
func DeriveChild ¶
DeriveChild is the standard BIP32 non-hardened private derivation (index < 2^31).
func DerivePath ¶
DerivePath derives a path like "m/0/0/0" (non-hardened segments only).
func SeedToMasterKey ¶
SeedToMasterKey is I = HMAC-SHA512(key = HDSalt, msg = seed): the left half is the key, the right the chain code.
type NetworkError ¶
NetworkError: the node could not be reached, the response was not JSON, or the socket died.
func (*NetworkError) Error ¶
func (e *NetworkError) Error() string
func (*NetworkError) Unwrap ¶
func (e *NetworkError) Unwrap() error
type NodeInfo ¶
type NodeInfo struct {
NodeKey string `json:"nodeKey"`
Host string `json:"host"`
Port int `json:"port"`
NetworkID string `json:"networkId"`
GenesisHash string `json:"genesisHash"`
ChainSpecDigest string `json:"chainSpecDigest"`
Version string `json:"version"`
APIVersion string `json:"apiVersion"`
ProtocolVersion string `json:"protocolVersion"`
SyncStatus string `json:"syncStatus"`
Faucet bool `json:"faucet"`
}
NodeInfo is GET info.
type NonceMismatchError ¶
type NonceMismatchError struct {
TxRejectedError
Address string
// Expected and Got are valid when Known is true (the node's message carried them).
Expected, Got int64
Known bool
}
NonceMismatchError: the nonce is not the sender's next nonce. Refresh it (client.Nonce) and rebuild.
func (*NonceMismatchError) Unwrap ¶
func (e *NonceMismatchError) Unwrap() error
Unwrap lets errors.As(err, **TxRejectedError) match a nonce mismatch too.
type NotFoundError ¶
type NotFoundError struct{ APIError }
NotFoundError: HTTP 404.
func (*NotFoundError) Unwrap ¶
func (e *NotFoundError) Unwrap() error
type NotSynchronizedError ¶
type NotSynchronizedError struct{ Message, Transport string }
NotSynchronizedError: the node is still syncing (REST 400 / RPC -32002). Retry shortly.
func (*NotSynchronizedError) Error ¶
func (e *NotSynchronizedError) Error() string
type Page ¶
type Page[T any] struct { Total int64 `json:"total"` List []T `json:"list"` Page int `json:"page"` PageSize int `json:"pageSize"` TotalPages int `json:"totalPages"` }
Page is one page of a REST or RPC list.
type RPCError ¶
type RPCError struct {
Code int
Message string
Data json.RawMessage
}
RPCError: a JSON-RPC error that is not a transaction rejection. Compare Code with the RPC* constants.
type RPCMethodSpec ¶ added in v0.1.6
type RPCMethodSpec struct {
Name string `json:"name"`
Params []string `json:"params"`
Description string `json:"description"`
}
RPCMethodSpec is one method described by janzeer_methods.
type RateLimitedError ¶
RateLimitedError: HTTP 429 / RPC -32004.
func (*RateLimitedError) Error ¶
func (e *RateLimitedError) Error() string
type Receipt ¶
type Receipt struct {
Successful bool `json:"successful"`
Results json.RawMessage `json:"results"`
}
Receipt is the execution receipt of a committed transaction.
type RegisterValidator ¶
type RegisterValidator struct {
Common
// ValidatorKey is the NODE's public key (GET info -> nodeKey), never the wallet's own key.
ValidatorKey string
// Amount must equal ValidatorDeposit; it defaults to it.
Amount string
}
RegisterValidator describes a validator registration.
type SendResult ¶
SendResult is the answer of the janzeer_send* methods.
type SignedTx ¶
type SignedTx struct {
Unsigned *UnsignedTx
Hash string
// Signature is the Base64 DER ECDSA signature over Hash.
Signature string
// SenderPublicKey is the compressed secp256k1 public key, hex.
SenderPublicKey string
}
SignedTx is a signed transaction ready for client.Submit or rpc.Send.
func (*SignedTx) Body ¶
Body is the JSON body the node's REST endpoints and janzeer_send* methods accept. Amounts are strings.
type Token ¶
type Token struct {
Common
TokenID string // every operation except create
Symbol string // create
Name string // create
Decimals int // create, 0-18
Cap string // create (optional), set-cap
Amount string // create (optional initial mint), mint, burn, transfer
Recipient string // mint (optional, defaults to the sender), transfer
}
Token describes a JZT-1 token operation. Token amounts (Cap, Amount) are integer base units as digit strings, never scaled; Decimals is display-only. Which fields are used depends on the operation.
type TokenBalance ¶ added in v0.1.6
type TokenBalance struct {
TokenID string `json:"tokenId"`
Holder string `json:"holder"`
Balance *big.Int `json:"balance"`
}
TokenBalance is a token holding of an address.
type TokenOp ¶
type TokenOp byte
TokenOp is a JZT-1 token operation code (the op byte).
Token operations.
type TokenView ¶ added in v0.1.6
type TokenView struct {
TokenID string `json:"tokenId"`
Symbol string `json:"symbol"`
Name string `json:"name"`
Decimals int `json:"decimals"`
Cap *big.Int `json:"cap"`
TotalSupply *big.Int `json:"totalSupply"`
Issuer string `json:"issuer"`
}
TokenView is an asset token on the chain.
type Transaction ¶
type Transaction struct {
Hash string `json:"hash"`
Timestamp int64 `json:"timestamp"`
Fee Amount `json:"fee"`
Nonce *int64 `json:"nonce"`
SenderAddress string `json:"senderAddress"`
SenderPublicKey string `json:"senderPublicKey"`
SenderSignature string `json:"senderSignature"`
BlockHash *string `json:"blockHash"`
Amount *Amount `json:"amount"`
RecipientAddress *string `json:"recipientAddress"`
Data *string `json:"data"`
ValidatorKey *string `json:"validatorKey"`
TokenID *string `json:"tokenId"`
// Raw is the complete JSON object, for fields this struct does not name.
Raw json.RawMessage `json:"-"`
}
Transaction is a transaction as the REST lists and lookups return it. Fields that a type does not have are nil.
func (*Transaction) Final ¶
func (t *Transaction) Final() bool
Final reports whether the transaction is in a committed block.
func (*Transaction) UnmarshalJSON ¶
func (t *Transaction) UnmarshalJSON(b []byte) error
UnmarshalJSON keeps the raw object next to the named fields.
type Transfer ¶
type Transfer struct {
Common
To string
Amount string
// Data is an optional memo, at most 256 UTF-8 bytes; with a memo the amount may be below MinTransfer (even "0").
Data string
}
Transfer describes a native-coin transfer.
type TxRejectedError ¶
type TxRejectedError struct {
Message string
// Type is the node's exception type (INCORRECT_SIGNATURE, INSUFFICIENT_BALANCE, …) or UNKNOWN.
Type string
// Transport is "rest", "rpc" or "ws".
Transport string
HTTPStatus int
RPCCode int
}
TxRejectedError: the node refused a transaction at intake (validation or mempool rule).
func (*TxRejectedError) Error ¶
func (e *TxRejectedError) Error() string
type TxView ¶
type TxView struct {
Hash string `json:"hash"`
Type *string `json:"type"`
// Status is FINAL, PENDING or UNKNOWN.
Status string `json:"status"`
Timestamp *int64 `json:"timestamp"`
Fee *Amount `json:"fee"`
Nonce *int64 `json:"nonce"`
SenderAddress *string `json:"senderAddress"`
SenderPublicKey *string `json:"senderPublicKey"`
SenderSignature *string `json:"senderSignature"`
BlockHash *string `json:"blockHash"`
BlockHeight *int64 `json:"blockHeight"`
Receipt *Receipt `json:"receipt"`
Amount *Amount `json:"amount"`
RecipientAddress *string `json:"recipientAddress"`
Data *string `json:"data"`
ValidatorKey *string `json:"validatorKey"`
Op *string `json:"op"`
TokenID *string `json:"tokenId"`
Symbol *string `json:"symbol"`
Name *string `json:"name"`
Decimals *int `json:"decimals"`
Cap *Amount `json:"cap"`
TokenAmount *Amount `json:"tokenAmount"`
Recipient *string `json:"recipient"`
TimedOut bool `json:"timedOut"`
}
TxView is the unified view of any transaction (janzeer_getTransactionByHash, waitForFinality, subscriptions).
type UnsignedTx ¶
type UnsignedTx struct {
Type TxType
NetworkID string
Timestamp int64 // ms since epoch
Fee string
Nonce int64
SenderAddress string
// Fields are the type-specific fields exactly as they go into the request body.
Fields map[string]any
// Payload is the type-specific part of the signed bytes.
Payload []byte
}
UnsignedTx is a transaction that is fully specified but not yet signed. Sign it with Account.SignTx.
func NewExitValidator ¶
func NewExitValidator(o ExitValidator) (*UnsignedTx, error)
NewExitValidator builds a graceful validator exit (removed at the next epoch; the deposit stays locked).
func NewRegisterValidator ¶
func NewRegisterValidator(o RegisterValidator) (*UnsignedTx, error)
NewRegisterValidator builds a validator registration: the exact ValidatorFee and the NON-REFUNDABLE ValidatorDeposit.
func NewTokenBurn ¶
func NewTokenBurn(o Token) (*UnsignedTx, error)
NewTokenBurn builds a BURN (issuer only).
func NewTokenCreate ¶
func NewTokenCreate(o Token) (*UnsignedTx, error)
NewTokenCreate builds a token CREATE; the new token id is the transaction hash. The fee is exactly TokenCreateFee.
func NewTokenMint ¶
func NewTokenMint(o Token) (*UnsignedTx, error)
NewTokenMint builds a MINT (issuer only); Recipient defaults to the sender.
func NewTokenSetCap ¶
func NewTokenSetCap(o Token) (*UnsignedTx, error)
NewTokenSetCap builds a SETCAP (issuer only).
func NewTokenTransfer ¶
func NewTokenTransfer(o Token) (*UnsignedTx, error)
NewTokenTransfer builds a token TRANSFER.
func NewTransfer ¶
func NewTransfer(o Transfer) (*UnsignedTx, error)
NewTransfer builds a native-coin transfer. The fee defaults to MinFee.
func (*UnsignedTx) Hash ¶
func (t *UnsignedTx) Hash() string
Hash is double-SHA256 of the preimage, lowercase hex: the transaction id.
func (*UnsignedTx) Preimage ¶
func (t *UnsignedTx) Preimage() []byte
Preimage returns the exact bytes that are hashed and signed: networkId || timestamp(8) || scaled(fee)(8) || nonce(8) || senderAddress || payload.
func (*UnsignedTx) WithSignature ¶
func (t *UnsignedTx) WithSignature(signatureBase64, senderPublicKeyHex string) *SignedTx
WithSignature attaches a signature made elsewhere (hardware wallet, KMS). Prefer Account.SignTx.
type ValidationError ¶
ValidationError: request-body validation failed (HTTP 400 with a list of messages).
func (*ValidationError) Unwrap ¶
func (e *ValidationError) Unwrap() error
type ValidatorInfo ¶
type ValidatorInfo struct {
Key string `json:"key"`
WalletAddress *string `json:"walletAddress"`
RegisteredAt *int64 `json:"registeredAt"`
Active *bool `json:"active"`
Banned *bool `json:"banned"`
Exited *bool `json:"exited"`
}
ValidatorInfo is an entry of the JSON-RPC validator methods.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package client is the client of the node's REST API (/api/v1/).
|
Package client is the client of the node's REST API (/api/v1/). |
|
examples
|
|
|
offline
command
Sign a transfer offline and broadcast it later, in three separated steps: read the network id and the sender's nonce online (no key), sign on the offline machine (with the key, no network), then broadcast the signed body online (no key).
|
Sign a transfer offline and broadcast it later, in three separated steps: read the network id and the sender's nonce online (no key), sign on the offline machine (with the key, no network), then broadcast the signed body online (no key). |
|
quickstart
command
Send a transfer and wait until it is final.
|
Send a transfer and wait until it is final. |
|
subscribe
command
Watch an address over the WebSocket, send it a transfer, and print the notification.
|
Watch an address over the WebSocket, send it a transfer, and print the notification. |
|
token
command
Create a JZT-1 token, then move some units.
|
Create a JZT-1 token, then move some units. |
|
validator
command
Register (and later exit) a validator node.
|
Register (and later exit) a validator node. |
|
vault
command
Seal a recovery phrase under a password and open it again.
|
Seal a recovery phrase under a password and open it again. |
|
watchblocks
command
Watch newly finalized blocks over the WebSocket and print their height, hash and transaction count.
|
Watch newly finalized blocks over the WebSocket and print their height, hash and transaction count. |
|
internal
|
|
|
vectors
Package vectors embeds the vendored conformance vectors (a copy of janzeer-sdk-conformance/vectors, checked by SHA256SUMS) for the tests of this module.
|
Package vectors embeds the vendored conformance vectors (a copy of janzeer-sdk-conformance/vectors, checked by SHA256SUMS) for the tests of this module. |
|
Package rpc is the JSON-RPC 2.0 client of the node: over HTTP (Client, POST /rpc) and over WebSocket (WS, /rpc/ws) with live subscriptions.
|
Package rpc is the JSON-RPC 2.0 client of the node: over HTTP (Client, POST /rpc) and over WebSocket (WS, /rpc/ws) with live subscriptions. |
|
Package vault seals a secret under a password: PBKDF2-HMAC-SHA256 (250,000 rounds) -> AES-256-GCM.
|
Package vault seals a secret under a password: PBKDF2-HMAC-SHA256 (250,000 rounds) -> AES-256-GCM. |