Skip to content

Commit

Permalink
get_block_template: allow setting extra_nonce
Browse files Browse the repository at this point in the history
  • Loading branch information
duggavo committed May 18, 2023
1 parent 98f0d4b commit a6943bd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
11 changes: 2 additions & 9 deletions rpc/daemon/jsonrpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ const (
methodGetBlockHeadersRange = "get_block_headers_range"
methodGetBlockHeaderByHash = "get_block_header_by_hash"
methodGetBlockHeaderByHeight = "get_block_header_by_height"
methodGetBlockTemplate = "get_block_template"
methodGetCoinbaseTxSum = "get_coinbase_tx_sum"
methodGetConnections = "get_connections"
methodGetFeeEstimate = "get_fee_estimate"
Expand Down Expand Up @@ -216,16 +215,10 @@ func (c *Client) RelayTx(
}

// GetBlockTemplate gets a block template on which mining a new block.
func (c *Client) GetBlockTemplate(
ctx context.Context, walletAddress string, reserveSize uint,
) (*GetBlockTemplateResult, error) {
func (c *Client) GetBlockTemplate(ctx context.Context, params GetBlockTemplateParams) (*GetBlockTemplateResult, error) {
resp := &GetBlockTemplateResult{}
params := map[string]interface{}{
"wallet_address": walletAddress,
"reserve_size": reserveSize,
}

err := c.JSONRPC(ctx, methodGetBlockTemplate, params, resp)
err := c.JSONRPC(ctx, "get_block_template", params, resp)
if err != nil {
return nil, fmt.Errorf("jsonrpc: %w", err)
}
Expand Down
10 changes: 10 additions & 0 deletions rpc/daemon/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,16 @@ type GetInfoResult struct {
RPCResultFooter `json:",inline"`
}

type GetBlockTemplateParams struct {
WalletAddress string `json:"wallet_address"`

// ReserveSize reserves X byte in the block header for the extra nonce.
ReserveSize uint `json:"reserve_size,omitempty"`

// ExtraNonce is the hex string representing the extra nonce.
ExtraNonce string `json:"extra_nonce,omitempty"`
}

// GetBlockTemplateResult is the result of a call to the GetBlockTemplate RPC
// method.
type GetBlockTemplateResult struct {
Expand Down

0 comments on commit a6943bd

Please sign in to comment.