rpcserver: add txid to getblocktemplate response

This commit is contained in:
Anirudha Bose 2020-09-21 23:11:48 +02:00 committed by John C. Vernaleo
parent 40ae93587d
commit 0bf42f4476
2 changed files with 7 additions and 7 deletions

View file

@ -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"`

View file

@ -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 {
@ -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],