Skip to content

Commit

Permalink
rpcserver: add txid to getblocktemplate response
Browse files Browse the repository at this point in the history
  • Loading branch information
onyb authored and jcvernaleo committed Oct 5, 2020
1 parent 40ae935 commit 0bf42f4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
7 changes: 3 additions & 4 deletions btcjson/chainsvrresults.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,10 +236,9 @@ type GetBlockFilterResult struct {
// GetBlockTemplateResultTx models the transactions field of the
// getblocktemplate command.
type GetBlockTemplateResultTx struct {
Data string `json:"data"`
Hash string `json:"hash"`
// TODO: remove omitempty once implemented in rpcserver
TxID string `json:"txid,omitempty"`
Data string `json:"data"`
Hash string `json:"hash"`
TxID string `json:"txid"`
Depends []int64 `json:"depends"`
Fee int64 `json:"fee"`
SigOps int64 `json:"sigops"`
Expand Down
7 changes: 4 additions & 3 deletions rpcserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -1689,8 +1689,8 @@ func (state *gbtWorkState) blockTemplateResult(useCoinbaseValue bool, submitOld
transactions := make([]btcjson.GetBlockTemplateResultTx, 0, numTx-1)
txIndex := make(map[chainhash.Hash]int64, numTx)
for i, tx := range msgBlock.Transactions {
txHash := tx.TxHash()
txIndex[txHash] = int64(i)
txID := tx.TxHash()
txIndex[txID] = int64(i)

// Skip the coinbase transaction.
if i == 0 {
Expand Down Expand Up @@ -1724,7 +1724,8 @@ func (state *gbtWorkState) blockTemplateResult(useCoinbaseValue bool, submitOld
bTx := btcutil.NewTx(tx)
resultTx := btcjson.GetBlockTemplateResultTx{
Data: hex.EncodeToString(txBuf.Bytes()),
Hash: txHash.String(),
TxID: txID.String(),
Hash: tx.WitnessHash().String(),
Depends: depends,
Fee: template.Fees[i],
SigOps: template.SigOpCosts[i],
Expand Down

0 comments on commit 0bf42f4

Please sign in to comment.