From cc9f922a6e60f61f2de84653a3f8ad41d3745acf Mon Sep 17 00:00:00 2001 From: Larry Ruane Date: Fri, 15 Jul 2022 10:48:40 -0600 Subject: [PATCH] Fix GetMempoolTx bug returning no entries This was broken by PR 393, which changed how txids are determined. --- common/mempool.go | 4 ---- frontend/service.go | 5 +++++ 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/common/mempool.go b/common/mempool.go index 4ee9dc2f..244b1c21 100644 --- a/common/mempool.go +++ b/common/mempool.go @@ -54,7 +54,6 @@ func GetMempool(sendToClient func(*walletrpc.RawTransaction) error) error { if g_lastBlockChainInfo.BestBlockHash != blockChainInfo.BestBlockHash { // A new block has arrived g_lastBlockChainInfo = blockChainInfo - Log.Infoln("Latest Block changed, clearing everything") // We're the first thread to notice, clear cached state. g_txidSeen = map[txid]struct{}{} g_txList = []*walletrpc.RawTransaction{} @@ -89,8 +88,6 @@ func GetMempool(sendToClient func(*walletrpc.RawTransaction) error) error { // RefreshMempoolTxns gets all new mempool txns and sends any new ones to waiting clients func refreshMempoolTxns() error { - Log.Infoln("Refreshing mempool") - params := []json.RawMessage{} result, rpcErr := RawRequest("getrawmempool", params) if rpcErr != nil { @@ -132,7 +129,6 @@ func refreshMempoolTxns() error { if err != nil { return err } - Log.Infoln("appending", txidstr) newRtx := &walletrpc.RawTransaction{ Data: txBytes, Height: uint64(g_lastBlockChainInfo.Blocks), diff --git a/frontend/service.go b/frontend/service.go index 364b6214..432bb654 100644 --- a/frontend/service.go +++ b/frontend/service.go @@ -466,6 +466,11 @@ func (s *lwdStreamer) GetMempoolTx(exclude *walletrpc.Exclude, resp walletrpc.Co } newmempoolMap[txidstr] = &walletrpc.CompactTx{} if tx.HasShieldedElements() { + txidBytes, err := hex.DecodeString(txidstr) + if err != nil { + return err + } + tx.SetTxID(txidBytes) newmempoolMap[txidstr] = tx.ToCompact( /* height */ 0) } }