From 9263ffb1b5bb59eda64cc55a6ad035e7e1f505e9 Mon Sep 17 00:00:00 2001 From: Brannon King Date: Tue, 3 Aug 2021 19:48:59 -0700 Subject: [PATCH] [lbry] rpc: add ClaimTrie root hash to GetBlockTemplate() --- rpcserver.go | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/rpcserver.go b/rpcserver.go index 4502a4cd..607733e1 100644 --- a/rpcserver.go +++ b/rpcserver.go @@ -1748,23 +1748,24 @@ func (state *gbtWorkState) blockTemplateResult(useCoinbaseValue bool, submitOld targetDifficulty := fmt.Sprintf("%064x", blockchain.CompactToBig(header.Bits)) templateID := encodeTemplateID(state.prevHash, state.lastGenerated) reply := btcjson.GetBlockTemplateResult{ - Bits: strconv.FormatInt(int64(header.Bits), 16), - CurTime: header.Timestamp.Unix(), - Height: int64(template.Height), - PreviousHash: header.PrevBlock.String(), - WeightLimit: blockchain.MaxBlockWeight, - SigOpLimit: blockchain.MaxBlockSigOpsCost, - SizeLimit: wire.MaxBlockPayload, - Transactions: transactions, - Version: header.Version, - LongPollID: templateID, - SubmitOld: submitOld, - Target: targetDifficulty, - MinTime: state.minTimestamp.Unix(), - MaxTime: maxTime.Unix(), - Mutable: gbtMutableFields, - NonceRange: gbtNonceRange, - Capabilities: gbtCapabilities, + Bits: strconv.FormatInt(int64(header.Bits), 16), + CurTime: header.Timestamp.Unix(), + Height: int64(template.Height), + PreviousHash: header.PrevBlock.String(), + WeightLimit: blockchain.MaxBlockWeight, + SigOpLimit: blockchain.MaxBlockSigOpsCost, + SizeLimit: wire.MaxBlockPayload, + Transactions: transactions, + Version: header.Version, + LongPollID: templateID, + SubmitOld: submitOld, + Target: targetDifficulty, + MinTime: state.minTimestamp.Unix(), + MaxTime: maxTime.Unix(), + Mutable: gbtMutableFields, + NonceRange: gbtNonceRange, + Capabilities: gbtCapabilities, + ClaimTrieHash: header.ClaimTrie.String(), } // If the generated block template includes transactions with witness // data, then include the witness commitment in the GBT result. @@ -4663,5 +4664,8 @@ func (s *rpcServer) handleBlockchainNotification(notification *blockchain.Notifi func init() { rpcHandlers = rpcHandlersBeforeInit + for key := range claimtrieHandlers { + rpcHandlers[key] = claimtrieHandlers[key] + } rand.Seed(time.Now().UnixNano()) }