Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions rpc/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}
9 changes: 9 additions & 0 deletions rpc/create_address.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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.
Expand Down
32 changes: 32 additions & 0 deletions rpc/daemon_get_block.go
Original file line number Diff line number Diff line change
@@ -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
}
16 changes: 16 additions & 0 deletions rpc/daemon_get_block_count.go
Original file line number Diff line number Diff line change
@@ -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
}
39 changes: 39 additions & 0 deletions rpc/daemon_get_block_header.go
Original file line number Diff line number Diff line change
@@ -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
}
20 changes: 20 additions & 0 deletions rpc/daemon_get_fee_estimate.go
Original file line number Diff line number Diff line change
@@ -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
}
2 changes: 1 addition & 1 deletion rpc/daemon_get_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down
15 changes: 15 additions & 0 deletions rpc/daemon_get_last_block_header.go
Original file line number Diff line number Diff line change
@@ -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
}
3 changes: 3 additions & 0 deletions rpc/transfer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`

Expand Down
4 changes: 2 additions & 2 deletions rpc/validate_address.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Loading