diff --git a/rpc/common.go b/rpc/common.go index 834916c..85dee4d 100644 --- a/rpc/common.go +++ b/rpc/common.go @@ -89,3 +89,28 @@ type Entry struct { type KeyImages struct { KeyImages []string `json:"key_images"` } + +type BlockHeader struct { + BlockSize uint64 `json:"block_size"` + BlockWeight uint64 `json:"block_weight"` + CumulativeDifficulty uint64 `json:"cumulative_difficulty"` + CumulativeDifficultyTop64 uint64 `json:"cumulative_difficulty_top64"` + Depth uint64 `json:"depth"` + Difficulty uint64 `json:"difficulty"` + DifficultyTop64 uint64 `json:"difficulty_top64"` + Hash string `json:"hash"` + Height uint64 `json:"height"` + LongTermWeight uint64 `json:"long_term_weight"` + MajorVersion uint64 `json:"major_version"` + MinerTxHash string `json:"miner_tx_hash"` + MinorVersion uint64 `json:"minor_version"` + Nonce uint64 `json:"nonce"` + NumTxes uint64 `json:"num_txes"` + OrphanStatus bool `json:"orphan_status"` + PowHash string `json:"pow_hash"` + PrevHash string `json:"prev_hash"` + Reward uint64 `json:"reward"` + Timestamp uint64 `json:"timestamp"` + WideCumulativeDifficulty string `json:"wide_cumulative_difficulty"` + WideDifficulty string `json:"wide_difficulty"` +} diff --git a/rpc/create_address.go b/rpc/create_address.go index 765ee94..5a626cb 100644 --- a/rpc/create_address.go +++ b/rpc/create_address.go @@ -8,6 +8,9 @@ type CreateAddressRequest struct { // (Optional) Label for the new address. Label string `json:"label,omitempty"` + + // (Optional) Number of addresses to create (Defaults to 1). + Count uint64 `json:"count"` } type CreateAddressResponse struct { @@ -16,6 +19,12 @@ type CreateAddressResponse struct { // Index of the new address under the input account. AddressIndex uint64 `json:"address_index"` + + // List of (count) address indeces + AddressIndeces []uint64 `json:"address_indices"` + + // List of (count) addresses + Addresses []string `json:"addresses"` } // Create a new address for an account. Optionally, label the new address. diff --git a/rpc/daemon_get_block.go b/rpc/daemon_get_block.go new file mode 100644 index 0000000..c00fa0b --- /dev/null +++ b/rpc/daemon_get_block.go @@ -0,0 +1,32 @@ +package rpc + +import "context" + +type DaemonGetBlockResponse struct { + Blob string `json:"blob"` + BlockHeader BlockHeader `json:"block_header"` + Credits uint64 `json:"credits"` + Json string `json:"json"` // json formatted details + MinerTxHash string `json:"miner_tx_hash"` // coinbase tx + Status string `json:"status"` + TopHash string `json:"top_hash"` + TxHashes []string `json:"tx_hashes"` // non-coinbase txs + Untrusted bool `json:"untrusted"` +} + +// Inputs (pick height or hash): +type DaemonGetBlockRequest struct { + // The block's height. + Height uint64 `json:"height"` + // The block's sha256 hash. + Hash string `json:"hash"` + // Optional; defaults to false. Add PoW hash to block_header response. + FillPowHash bool `json:"fill_pow_hash"` +} + +// Return block info from the daemon given the hash +func (c *Client) DaemonGetBlock(ctx context.Context, req *DaemonGetBlockRequest) (*DaemonGetBlockResponse, error) { + resp := &DaemonGetBlockResponse{} + err := c.Do(ctx, "get_block", req, resp) + return resp, err +} diff --git a/rpc/daemon_get_block_count.go b/rpc/daemon_get_block_count.go new file mode 100644 index 0000000..b3413dc --- /dev/null +++ b/rpc/daemon_get_block_count.go @@ -0,0 +1,16 @@ +package rpc + +import "context" + +type DaemonGetBlockCountResponse struct { + Count uint64 `json:"count"` // the number of blocks not the zero based height + Status string `json:"status"` + Untrusted bool `json:"untrusted"` +} + +// Return the current block count known to the daemon +func (c *Client) DaemonGetBlockCount(ctx context.Context) (*DaemonGetBlockCountResponse, error) { + resp := &DaemonGetBlockCountResponse{} + err := c.Do(ctx, "get_block_count", nil, resp) + return resp, err +} diff --git a/rpc/daemon_get_block_header.go b/rpc/daemon_get_block_header.go new file mode 100644 index 0000000..705d5f0 --- /dev/null +++ b/rpc/daemon_get_block_header.go @@ -0,0 +1,39 @@ +package rpc + +import "context" + +type DaemonGetBlockHeaderResponse struct { + BlockHeader BlockHeader `json:"block_header"` + Credits uint64 `json:"credits"` + Status string `json:"status"` + TopHash string `json:"top_hash"` + Untrusted bool `json:"untrusted"` +} + +type DaemonGetBlockHeaderByHashRequest struct { + // The block's sha256 hash. + Hash string `json:"hash"` + // Optional; defaults to false. Add PoW hash to block_header response. + FillPowHash bool `json:"fill_pow_hash"` +} + +// Return block header info from the daemon given the hash +func (c *Client) DaemonGetBlockHeaderByHash(ctx context.Context, req *DaemonGetBlockHeaderByHashRequest) (*DaemonGetBlockHeaderResponse, error) { + resp := &DaemonGetBlockHeaderResponse{} + err := c.Do(ctx, "get_block_header_by_hash", req, resp) + return resp, err +} + +type DaemonGetBlockHeaderByHeightRequest struct { + // The block's height. + Height uint64 `json:"height"` + // Optional; defaults to false. Add PoW hash to block_header response. + FillPowHash bool `json:"fill_pow_hash"` +} + +// Return block header info from the daemon given the height +func (c *Client) DaemonGetBlockHeaderByHeight(ctx context.Context, req *DaemonGetBlockHeaderByHeightRequest) (*DaemonGetBlockHeaderResponse, error) { + resp := &DaemonGetBlockHeaderResponse{} + err := c.Do(ctx, "get_block_header_by_height", req, resp) + return resp, err +} diff --git a/rpc/daemon_get_fee_estimate.go b/rpc/daemon_get_fee_estimate.go new file mode 100644 index 0000000..791f66c --- /dev/null +++ b/rpc/daemon_get_fee_estimate.go @@ -0,0 +1,20 @@ +package rpc + +import "context" + +type DaemonGetFeeEstimateResponse struct { + Credits uint64 `json:"credits"` + Fee uint64 `json:"fee"` // atomic units / byte + Fees []uint64 `json:"fees"` // base fees at different priotities: slow, normal, fast, fastest + QuantizationMask uint64 `json:"quantization_mask"` // Final fee should be rounded up to an even multiple of this value + Status string `json:"status"` + TopHash string `json:"top_hash"` + Untrusted bool `json:"untrusted"` +} + +// Return a fee estimate from the daemon +func (c *Client) DaemonGetFeeEstimate(ctx context.Context) (*DaemonGetFeeEstimateResponse, error) { + resp := &DaemonGetFeeEstimateResponse{} + err := c.Do(ctx, "get_fee_estimate", nil, resp) + return resp, err +} diff --git a/rpc/daemon_get_info.go b/rpc/daemon_get_info.go index 1926a58..e217b32 100644 --- a/rpc/daemon_get_info.go +++ b/rpc/daemon_get_info.go @@ -24,7 +24,7 @@ type DemonGetInfoResponse struct { Mainnet bool `json:"mainnet"` NetType string `json:"nettype"` Offline bool `json:"offline"` - OutgoingConnectionsCount int64 `json:"outgoing_connections_count"` + OutgoingConnectionsCount uint64 `json:"outgoing_connections_count"` Restricted bool `json:"restricted"` RpcConnectionsCount uint64 `json:"rpc_connections_count"` Stagenet bool `json:"stagenet"` diff --git a/rpc/daemon_get_last_block_header.go b/rpc/daemon_get_last_block_header.go new file mode 100644 index 0000000..458a671 --- /dev/null +++ b/rpc/daemon_get_last_block_header.go @@ -0,0 +1,15 @@ +package rpc + +import "context" + +type DaemonGetLastBlockHeaderRequest struct { + // Optional; defaults to false. Add PoW hash to block_header response. + FillPowHash bool `json:"fill_pow_hash"` +} + +// Return latest block header info from the daemon +func (c *Client) DaemonGetLastBlockHeader(ctx context.Context, req *DaemonGetLastBlockHeaderRequest) (*DaemonGetBlockHeaderResponse, error) { + resp := &DaemonGetBlockHeaderResponse{} + err := c.Do(ctx, "get_last_block_header", req, resp) + return resp, err +} diff --git a/rpc/transfer.go b/rpc/transfer.go index b18a8b3..9124c67 100644 --- a/rpc/transfer.go +++ b/rpc/transfer.go @@ -12,6 +12,9 @@ type TransferRequest struct { // (Optional) Transfer from this set of subaddresses. (Defaults to empty - all indices) SubaddrIndices []uint64 `json:"subaddr_indices,omitempty"` + // (Optional) Subtract fee from output(s) - Choose which destinations to fund the tx fee from instead of the change output. + SubtractFeeFromOutputs []uint64 `json:"subtract_fee_from_outputs,omitempty"` + // Set a priority for the transaction. Accepted Values are: 0-3 for: default, unimportant, normal, elevated, priority. Priority Priority `json:"priority"` diff --git a/rpc/validate_address.go b/rpc/validate_address.go index e3b67fd..b33afdc 100644 --- a/rpc/validate_address.go +++ b/rpc/validate_address.go @@ -26,8 +26,8 @@ type ValidateAddressResponse struct { // Specifies which of the three Monero networks (mainnet, stagenet, and testnet) the address belongs to. Nettype string `json:"nettype"` - // True if the address is OpenAlias-formatted. - OpenaliasAddress bool `json:"openalias_address"` + // If the address is OpenAlias it will be returned here + OpenaliasAddress string `json:"openalias_address"` } // Analyzes a string to determine whether it is a valid monero wallet address and returns the result and the address specifications.