Documentation
¶
Overview ¶
Package nimiqrpc provides a Nimiq RPC client library in GO.
This client library uses the JSON-RPC protocol and implements the Nimiq RPC specification Which can be found here: https://github.com/nimiq/core-js/wiki/JSON-RPC-API#remotejs-client This package provides a Client and all the necessary types to interact with the Nimiq RPC server.
How to use this package:
// Initialise a new client
nimiqClient := NewClient("address.to.nimiqnode.com")
// Do an RPC call. For example retrieve the balance of a Nimiq account:
balance, err := nimiqClient.GetBalance("NQ52 V4BF 52J3 0PM6 BG4M 9QY1 RUYS UAL6 CJD2")
if err != nil {
// Do your error handling here
}
// Do something with the response. In this case we print the balance
fmt.Printf("Balance: %v\n", balance)
Index ¶
- Variables
- type Account
- type AddressObject
- type Block
- type BlockTemplate
- type Client
- func (nc *Client) Accounts() (accounts []Account, err error)
- func (nc *Client) BlockNumber() (blockHeight int, err error)
- func (nc *Client) Consensus() (consensus string, err error)
- func (nc *Client) CreateAccount() (wallet *Wallet, err error)
- func (nc *Client) CreateRawTransaction(trn OutgoingTransaction) (transactionHex string, err error)
- func (nc *Client) GetAccount(address string) (account *Account, err error)
- func (nc *Client) GetBalance(address string) (balance Luna, err error)
- func (nc *Client) GetBlockByHash(blockHash string, fullTransactions bool) (block *Block, err error)
- func (nc *Client) GetBlockByNumber(blockNumber int, fullTransactions bool) (block *Block, err error)
- func (nc *Client) GetBlockTemplate(params ...interface{}) (template *BlockTemplate, err error)
- func (nc *Client) GetBlockTransactionCountByHash(blockHash string) (transactionCount int, err error)
- func (nc *Client) GetBlockTransactionCountByNumber(blockNumber int) (transactionCount int, err error)
- func (nc *Client) GetTransactionByBlockHashAndIndex(blockHash string, index int) (transaction *Transaction, err error)
- func (nc *Client) GetTransactionByBlockNumberAndIndex(blockNumber int, index int) (transaction *Transaction, err error)
- func (nc *Client) GetTransactionByHash(transactionHash string) (transaction *Transaction, err error)
- func (nc *Client) GetTransactionReceipt(transactionHash string) (transactionReceipt *TransactionReceipt, err error)
- func (nc *Client) GetTransactionsByAddress(address string, maxEntries int) (transactions []Transaction, err error)
- func (nc *Client) GetWork(params ...interface{}) (work *Work, err error)
- func (nc *Client) Hashrate() (hashrate float64, err error)
- func (nc *Client) Log(tag string, level LogLevel) (succes bool, err error)
- func (nc *Client) Mempool() (mempool *Mempool, err error)
- func (nc *Client) Mining() (status bool, err error)
- func (nc *Client) PeerCount() (peers int, err error)
- func (nc *Client) RawCall(req *RPCRequest) (resp *RPCResponse, err error)
- func (nc *Client) SendRawTransaction(signedTransaction string) (transactionHash string, err error)
- func (nc *Client) SendTransaction(trn OutgoingTransaction) (transactionHash string, err error)
- func (nc *Client) SubmitBlock(fullBlock string) (err error)
- func (nc *Client) Syncing() (syncing bool, syncStatus *SyncStatus, err error)
- type LogLevel
- type Luna
- type Mempool
- type NIM
- type OutgoingTransaction
- type RPCError
- type RPCRequest
- type RPCResponse
- type SyncStatus
- type Transaction
- type TransactionReceipt
- type Wallet
- type Work
Constants ¶
This section is empty.
Variables ¶
var ( // ErrRespBodyEmpty is returned when the underlying HTTP response body is empty ErrRespBodyEmpty = errors.New("The HTTP response body was empty") // ErrResultUnexpected is returned when the expected result could not be read ErrResultUnexpected = errors.New("Unexpected result") ErrUnauthorized = errors.New("Unauthorized to do the request") )
var ( // ErrRPCIDMismatch is returned when the request ID and response ID don't match. // According to the JSON-RPC 2.0 spec, the request and response ID should always match. ErrRPCIDMismatch = errors.New("JSON-RPC: The request ID and the response ID didn't match") // ErrRPCParse is returned when an invalid JSON was received by the server. // This is a standard error from the JSON-RPC 2.0 spec. ErrRPCParse = errors.New("JSON-RPC: Invalid JSON was received by the server. An error occurred on the server while parsing the JSON text") // ErrRPCInvalidReq is returned when the JSON sent was not a valid request object. // This is a standard error from the JSON-RPC 2.0 spec. ErrRPCInvalidReq = errors.New("JSON-RPC: The JSON sent is not a valid Request object") // ErrRPCMethodNotFound is returned when the requested method does not exist or is not available on the server. // This is a standard error from the JSON-RPC 2.0 spec. ErrRPCMethodNotFound = errors.New("JSON-RPC: The method does not exist / is not available") // ErrRPCInvalidParams is returned when the parameters for the requested method are invalid // This is a standard error from the JSON-RPC 2.0 spec. ErrRPCInvalidParams = errors.New("JSON-RPC: Invalid method parameter(s)") // ErrRPCInternal is returned when a internal error occurred on the RPC server // This is a standard error from the JSON-RPC 2.0 spec. ErrRPCInternal = errors.New("JSON-RPC: Internal JSON-RPC error") // ErrRPCServer is returned when a server error occurred. // This is a standard error from the JSON-RPC 2.0 spec. ErrRPCServer = errors.New("JSON-RPC: Server error") )
Functions ¶
This section is empty.
Types ¶
type Account ¶
type Account struct {
// ID - Hex-encoded 20 byte address
ID string `json:"id,omitempty"`
// address: String - User friendly address (NQ-address).
Address string `json:"address,omitempty"`
// balance: Integer - Balance of the account (in smallest unit).
Balance Luna `json:"balance,omitempty"`
// type: Integer - The account type associated with the account (BASIC: 0, VESTING: 1, HTLC: 2).
Type int `json:"type,omitempty"`
// owner: String - Hex-encoded 20 byte address of the owner of the vesting contract.
Owner string `json:"owner,omitempty"`
// ownerAddress: String - User friendly address (NQ-address) of the owner of the vesting contract.
OwnerAddress string `json:"ownerAddress,omitempty"`
// vestingStart: Integer - The block that the vesting contracted commenced.
VestingStart int `json:"vestingStart,omitempty"`
// vestingStepBlocks: Integer - The number of blocks after which some part of the vested funds is released.
VestingStepBlocks int `json:"vestingStepBlocks,omitempty"`
// vestingStepAmount: Integer - The amount (in smallest unit) released every vestingStepBlocks blocks.
VestingStepAmount int `json:"vestingStepAmount,omitempty"`
// vestingTotalAmount: Integer - The total amount (in smallest unit) that was provided at the contract creation.
VestingTotalAmount int `json:"vestingTotalAmount,omitempty"`
// sender: String - Hex-encoded 20 byte address of the sender of the HTLC.
Sender string `json:"sender,omitempty"`
// senderAddress: String - User friendly address (NQ-address) of the sender of the HTLC.
SenderAddress string `json:"senderAddress,omitempty"`
// recipient: String - Hex-encoded 20 byte address of the recipient of the HTLC.
Recipient string `json:"recipient,omitempty"`
// recipientAddress: String - User friendly address (NQ-address) of the recipient of the HTLC.
RecipientAddress string `json:"recipientAddress,omitempty"`
// hashRoot: String - Hex-encoded 32 byte hash root.
HashRoot string `json:"hashRoot,omitempty"`
// hashCount: Integer - Number of hashes this HTLC is split into
HashCount int `json:"hashCount,omitempty"`
// timeout: Integer - Block after which the contract can only be used by the original sender to recover funds.
Timeout int `json:"timeout,omitempty"`
// totalAmount: Integer - The total amount (in smallest unit) that was provided at the contract creation.
TotalAmount int `json:"totalAmount,omitempty"`
}
Account holds the details on an account
type AddressObject ¶
type AddressObject struct {
// id: String - Hex-encoded 20 byte address.
ID string `json:"id,omitempty"`
// address: String - User friendly address (NQ-address).
Address string `json:"address,omitempty"`
}
AddressObject holds the representation of a Nimiq address in two formats.
type Block ¶
type Block struct {
// number: Integer - Height of the block.
Number int `json:"number,omitempty"`
// hash: String - Hex-encoded 32-byte hash of the block.
Hash string `json:"hash,omitempty"`
// pow: String - Hex-encoded 32-byte Proof-of-Work hash of the block.
POW string `json:"pow,omitempty"`
// parentHash: String - Hex-encoded 32-byte hash of the predecessor block.
ParentHash string `json:"ParentHash,omitempty"`
// nonce: Integer - The nonce of the block used to fulfill the Proof-of-Work.
Nonce int `json:"nonce,omitempty"`
// bodyHash: String - Hex-encoded 32-byte hash of the block body merkel root.
BodyHash string `json:"bodyHash,omitempty"`
// accountHash: String - Hex-encoded 32-byte hash of the accounts tree root.
AccountHash string `json:"accountHash,omitempty"`
// miner: String - Hex-encoded 20 byte address of the miner of the block.
Miner string `json:"miner,omitempty"`
// minerAddress: String - User friendly address (NQ-address) of the miner of the block.
MinerAddress string `json:"minerAddress,omitempty"`
// difficulty: String - Block difficulty, encoded as decimal number in string. (TODO)
Difficulty string `json:"difficulty,omitempty"`
// extraData: String - Hex-encoded value of the extra data field, maximum of 255 bytes.
ExtraData string `json:"extraData,omitempty"`
// size: Integer - Block size in byte.
Size int `json:"size,omitempty"`
// timestamp: Integer - UNIX timestamp of the block
Timestamp int `json:"timestamp,omitempty"`
// transactions: Array - Array of transactions. Either represented by the transaction hash or a Transaction object.
// Because Transactions can either be a slice of strings or a slice of transactions,
// transactions will be unmarshalled in a raw JSON message so that the message can be
// unmarshalled into TransactionsHashes or TransactionsObjects depending on the data type.
// The functions that return a Block, will automatically fill either TransactionsHashes or TransactionsObjects
Transactions json.RawMessage `json:"transactions,omitempty"`
// transactionsHashes contains a slice of transactions represented by the transaction hash
TransactionsHashes []string
// transactionsObjects contains a slice of transactions represented by transaction objects
TransactionsObjects []Transaction
}
Block holds the details on a block
type BlockTemplate ¶
type BlockTemplate struct {
// Block header
Header struct {
// version: Integer - Version in block header.
Version int `json:"version,omitempty"`
// prevHash: String - 32-byte hex-encoded hash of the previous block.
PrevHash string `json:"prevHash,omitempty"`
// interlinkHash: String - 32-byte hex-encoded hash of the interlink.
InterlinkHash string `json:"interlinkHash,omitempty"`
// accountsHash: String - 32-byte hex-encoded hash of the accounts tree.
AccountHash string `json:"accountHash,omitempty"`
// nBits: Integer - Compact form of the hash target for this block.
NBits int `json:"nBits,omitempty"`
// height: Integer - Height of the block in the block chain (also known as block number).
Height int `json:"height,omitempty"`
} `json:"header,omitempty"`
// interlink: String - Hex-encoded interlink
Interlink string `json:"interlink,omitempty"`
// Block template body
Body struct {
// hash: String - 32-byte hex-encoded hash of the block body.
Hash string `json:"hash,omitempty"`
// minerAddr: String - 20-byte hex-encoded miner address.
MinerAddr string `json:"minerAddr,omitempty"`
// extraData: String - Hex-encoded value of the extra data field.
ExtraData string `json:"extraData,omitempty"`
// transactions: String[] - Array of hex-encoded transactions for this block.
Transactions []string `json:"transactions,omitempty"`
// prunedAccounts: String[] - Array of hex-encoded pruned accounts for this block.
PrunedAccounts []string `json:"prunedAccounts,omitempty"`
// merkleHashes: String[] - Array of hex-encoded hashes that verify the path of the miner
// address in the merkle tree. This can be used to change the miner address easily.
MerkleHashes []string `json:"merkleHashes,omitempty"`
} `json:"body,omitempty"`
// target: Integer - Compact form of the hash target to submit a block to this client.
Target int `json:"target,omitempty"`
}
BlockTemplate contains details on a block template
type Client ¶
type Client struct {
// Address is the address of the RPC server / Nimiq node
Address string
// Transport is used to handle HTTP requests to the RPC server
Transport http.RoundTripper
// Headers contains the headers that will be copied over to each
// JSON-RPC request. This allows to set custom headers for all requests
// handled by the client.
Headers http.Header
// contains filtered or unexported fields
}
Client contains a Nimiq RPC client
func (*Client) BlockNumber ¶
BlockNumber returns the height of most recent block.
func (*Client) CreateAccount ¶
CreateAccount creates a new account and stores its private key in the client store.
func (*Client) CreateRawTransaction ¶
func (nc *Client) CreateRawTransaction(trn OutgoingTransaction) (transactionHex string, err error)
CreateRawTransaction creates and signs a transaction without sending it. The transaction can then be send via sendRawTransaction without accidentally replaying it.
func (*Client) GetAccount ¶
GetAccount returns details for the account of given address.
func (*Client) GetBalance ¶
GetBalance returns the balance of the account of given address.
func (*Client) GetBlockByHash ¶
GetBlockByHash returns information about a block by block hash. If fullTransactions is true it returns a block with the full transaction objects, if false only the hashes of the transactions will be returned.
func (*Client) GetBlockByNumber ¶
func (nc *Client) GetBlockByNumber(blockNumber int, fullTransactions bool) (block *Block, err error)
GetBlockByNumber returns information about a block by block number. If fullTransactions is true it returns a block with the full transaction objects, if false only the hashes of the transactions will be returned.
func (*Client) GetBlockTemplate ¶
func (nc *Client) GetBlockTemplate(params ...interface{}) (template *BlockTemplate, err error)
GetBlockTemplate returns a template to build the next block for mining. This will consider pool instructions when connected to a pool. Optional parameters: (1) The address to use as a miner for this block. This overrides the address provided during startup or from the pool. and (2) Hex-encoded value for the extra data field. This overrides the address provided during startup or from the pool.
func (*Client) GetBlockTransactionCountByHash ¶
func (nc *Client) GetBlockTransactionCountByHash(blockHash string) (transactionCount int, err error)
GetBlockTransactionCountByHash returns the number of transactions in a block from a block matching the given block hash.
func (*Client) GetBlockTransactionCountByNumber ¶
func (nc *Client) GetBlockTransactionCountByNumber(blockNumber int) (transactionCount int, err error)
GetBlockTransactionCountByNumber returns the number of transactions in a block from a block matching the given block number.
func (*Client) GetTransactionByBlockHashAndIndex ¶
func (nc *Client) GetTransactionByBlockHashAndIndex(blockHash string, index int) (transaction *Transaction, err error)
GetTransactionByBlockHashAndIndex returns information about a transaction by block hash and transaction index position.
func (*Client) GetTransactionByBlockNumberAndIndex ¶
func (nc *Client) GetTransactionByBlockNumberAndIndex(blockNumber int, index int) (transaction *Transaction, err error)
GetTransactionByBlockNumberAndIndex returns information about a transaction by block hash and transaction index position.
func (*Client) GetTransactionByHash ¶
func (nc *Client) GetTransactionByHash(transactionHash string) (transaction *Transaction, err error)
GetTransactionByHash Returns the information about a transaction requested by transaction hash.
func (*Client) GetTransactionReceipt ¶
func (nc *Client) GetTransactionReceipt(transactionHash string) (transactionReceipt *TransactionReceipt, err error)
GetTransactionReceipt returns the receipt of a transaction by transaction hash.
func (*Client) GetTransactionsByAddress ¶
func (nc *Client) GetTransactionsByAddress(address string, maxEntries int) (transactions []Transaction, err error)
GetTransactionsByAddress returns the latest transactions successfully performed by or for an address. The array will not contain more than maxEntries, but might contain less, even when more transactions happened. Any interpretation of the length of this array might result in worng assumptions.
func (*Client) GetWork ¶
GetWork returns instructions to mine the next block. This will consider pool instructions when connected to a pool. Optional arameters: (1) The address to use as a miner for this block. This overrides the address provided during startup or from the pool. and (2) Hex-encoded value for the extra data field. This overrides the address provided during startup or from the pool
func (*Client) Hashrate ¶
Hashrate returns the number of hashes per second that the node is mining with.
func (*Client) Mempool ¶
Mempool Returns information on the current mempool situation. This will provide an overview of the number of transactions sorted into buckets based on their fee per byte (in smallest unit).
func (*Client) RawCall ¶
func (nc *Client) RawCall(req *RPCRequest) (resp *RPCResponse, err error)
RawCall can be used to send a raw JSON-RPC request. This function is used internally to handle all the RPC functions provided by the client. Therefore this function should generally not be used. It does however provide the functionality to do RPC requests that are (not yet) implemented by the client.
func (*Client) SendRawTransaction ¶
SendRawTransaction sends a signed message call transaction or a contract creation, if the data field contains code.
func (*Client) SendTransaction ¶
func (nc *Client) SendTransaction(trn OutgoingTransaction) (transactionHash string, err error)
SendTransaction creates new message call transaction or a contract creation, if the data field contains code.
func (*Client) SubmitBlock ¶
SubmitBlock submits a block to the node. When the block is valid, the node will forward it to other nodes in the network. The argument is a hex-encoded full block (including header, interlink and body). When submitting work from getWork, remember to include the suffix.
type LogLevel ¶
type LogLevel string
LogLevel is de level of logging that is enabled on a node
const ( // LogLevelTrace represents the trace log level LogLevelTrace LogLevel = "trace" // LogLevelVerbose represents the verbose log level LogLevelVerbose LogLevel = "verbose" // LogLevelDebug represents the debug log level LogLevelDebug LogLevel = "debug" // LogLevelInfo represents the info log level LogLevelInfo LogLevel = "info" // LogLevelWarn represents the warn log level LogLevelWarn LogLevel = "warn" // LogLevelError represents the error log level LogLevelError LogLevel = "error" // LogLevelAssert represents the assert log level LogLevelAssert LogLevel = "assert" )
type Mempool ¶
type Mempool struct {
//total: Integer - Total number of pending transactions in mempool.
Total int `json:"total,omitempty"`
// buckets Integer[] - Array containing a subset of fee per byte buckets from
// [10000, 5000, 2000, 1000, 500, 200, 100, 50, 20, 10, 5, 2, 1, 0]
// that currently have more than one transaction.
Buckets []int `json:"buckets,omitempty"`
// any of the numbers present in buckets: Integer - Number of transaction in the bucket.
// A transaction is assigned to the highest bucket of a value lower than its fee per byte value.
Bucket0 int `json:"0,omitempty"`
Bucket1 int `json:"1,omitempty"`
Bucket2 int `json:"2,omitempty"`
Bucket5 int `json:"5,omitempty"`
Bucket10 int `json:"10,omitempty"`
Bucket20 int `json:"20,omitempty"`
Bucket50 int `json:"50,omitempty"`
Bucket100 int `json:"100,omitempty"`
Bucket200 int `json:"200,omitempty"`
Bucket500 int `json:"500,omitempty"`
Bucket1000 int `json:"1000,omitempty"`
Bucket2000 int `json:"2000,omitempty"`
Bucket5000 int `json:"5000,omitempty"`
}
Mempool holds the details on a mempool.
type NIM ¶
type NIM float64
NIM is the token transacted within Nimiq as a store and transfer of value: it acts as digital cash
type OutgoingTransaction ¶
type OutgoingTransaction struct {
// from: Address - The address the transaction is send from.
From string `json:"from"`
// fromType: Integer - (optional, default: 0, Account.Type.BASIC) The account type at the given address (BASIC: 0, VESTING: 1, HTLC: 2).
FromType int `json:"fromType,omitempty"`
// to: Address - The address the transaction is directed to.
To string `json:"to"`
// toType: Integer - (optional, default: 0, Account.Type.BASIC) The account type at the given address (BASIC: 0, VESTING: 1, HTLC: 2).
ToType int `json:"toType,omitempty"`
// value: Integer - Integer of the value (in smallest unit) sent with this transaction.
Value int `json:"value"`
// fee: Integer - Integer of the fee (in smallest unit) for this transaction.
Fee int `json:"fee"`
// data: String - (optional, default: null) Hex-encoded contract parameters or a message.
Data string `json:"data,omitempty"`
}
OutgoingTransaction holds the details on a transaction that is not yet sent.
type RPCError ¶
type RPCError struct {
Code int `json:"code,omitempty"`
Message string `json:"message,omitempty"`
Data string `json:"data,omitempty"`
}
RPCError represents a JSON-RPC error object
type RPCRequest ¶
type RPCRequest struct {
JSONRPC string `json:"jsonrpc,omitempty"`
Method string `json:"method,omitempty"`
Params interface{} `json:"params,omitempty"`
ID int `json:"id,omitempty"`
}
RPCRequest represents a JSON-RPC 2.0 request object
func NewRPCRequest ¶
func NewRPCRequest(method string, params interface{}) *RPCRequest
NewRPCRequest returns a new RPCRequest using the method and params as arguments
type RPCResponse ¶
type RPCResponse struct {
JSONRPC string `json:"jsonrpc,omitempty"`
Result json.RawMessage `json:"result,omitempty"`
Error RPCError `json:"error,omitempty"`
ID int `json:"id,omitempty"`
}
RPCResponse represents a JSON-RPC 2.0 response object
type SyncStatus ¶
type SyncStatus struct {
// startingBlock: Integer - The block at which the import started (will only be reset, after the sync reached his head)
StartingBlock int `json:"startingBlock,omitempty"`
// currentBlock: Integer - The current block, same as blockNumber
CurrentBlock int `json:"currentBlock,omitempty"`
// highestBlock: Integer - The estimated highest block
HighestBlock int `json:"highestBlock,omitempty"`
}
SyncStatus holds information about the sync status.
type Transaction ¶
type Transaction struct {
// hash: String - Hex-encoded hash of the transaction.
Hash string `json:"hash,omitempty"`
// blockHash: String (optional) - Hex-encoded hash of the block containing the transaction.
BlockHash string `json:"blockHash,omitempty"`
// blockNumber: Integer (optional) - Height of the block containing the transaction.
BlockNumber int `json:"blockNumber,omitempty"`
// timestamp: Integer (optional) - UNIX timestamp of the block containing the transaction.
Timestamp int `json:"timestamp,omitempty"`
// confirmations: Integer (optional, default: 0) - Number of confirmations of the block containing the transaction.
Confirmations int `json:"confirmations,omitempty"`
// transactionIndex: Integer (optional) - Index of the transaction in the block.
TransactionIndex int `json:"transactionIndex,omitempty"`
// from: String - Hex-encoded address of the sending account.
From string `json:"from,omitempty"`
// fromAddress: String - Nimiq user friendly address (NQ-address) of the sending account.
FromAddress string `json:"FromAddress,omitempty"`
// to: String - Hex-encoded address of the recipient account.
To string `json:"to,omitempty"`
// toAddress: String - Nimiq user friendly address (NQ-address) of the recipient account.
ToAddress string `json:"toAddress,omitempty"`
// value: Integer - Integer of the value (in smallest unit) sent with this transaction.
Value int `json:"value,omitempty"`
// fee: Integer - Integer of the fee (in smallest unit) for this transaction.
Fee int `json:"fee,omitempty"`
// data: String - (optional, default: null) Hex-encoded contract parameters or a message.
Data string `json:"data,omitempty"`
// flags: Integer - Bit-encoded transaction flags.
Flags int `json:"flags,omitempty"`
}
Transaction holds the details on a transaction
type TransactionReceipt ¶
type TransactionReceipt struct {
// transactionHash : String - Hex-encoded hash of the transaction.
TransactionHash string `json:"transactionHash,omitempty"`
// transactionIndex: Integer - Integer of the transactions index position in the block.
TransactionIndex int `json:"transactionIndex,omitempty"`
// blockHash: String - Hex-encoded hash of the block where this transaction was in.
BlockHash string `json:"blockHash,omitempty"`
// blockNumber: Integer - Block number where this transaction was in.
BlockNumber int `json:"blockNumber,omitempty"`
// confirmations: Integer - Number of confirmations for this transaction (number of blocks on top of the block where this transaction was in).
Confirmations int `json:"confirmations,omitempty"`
// timestamp: Integer - Timestamp of the block where this transaction was in.
Timestamp int `json:"timestamp,omitempty"`
}
TransactionReceipt holds the details on a transaction receipt.
type Wallet ¶
type Wallet struct {
// id: String - Hex-encoded 20 byte address.
ID string `json:"id,omitempty"`
// address: String - User friendly address (NQ-address).
Address string `json:"address,omitempty"`
// publicKey: String - Hex-encoded 32 byte Ed25519 public key.
PublicKey string `json:"publicKey,omitempty"`
// privateKey: String (optional) - Hex-encoded 32 byte Ed25519 private key.
PrivateKey string `json:"privateKey,omitempty"`
}
Wallet holds the details on a wallet.
type Work ¶
type Work struct {
// data: String - Hex-encoded block header. This is what should be passed through the hash function. The last 4 bytes describe the nonce, the 4 bytes before are the current timestamp. Most implementations allow the miner to arbitrarily choose the nonce and to update the timestamp without requesting new work instructions.
Data string `json:"data,omitempty"`
// suffix: String - Hex-encoded block without the header. When passing a mining result to submitBlock, append the suffix to the data string with selected nonce.
Suffix string `json:"suffix,omitempty"`
// target: Integer - Compact form of the hash target to submit a block to this client.
Target int `json:"target,omitempty"`
// algorithm String - Field to describe the algorithm used to mine the block. Always nimiq-argon2 for now.
Algorithm string `json:"algorithm,omitempty"`
}
Work holds the instructions to mine the next block