Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rpcserver: add txid to getblocktemplate response #1639

Merged
merged 1 commit into from
Oct 5, 2020
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
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