From 156f49d682ef025fb942c997a6c5475e18eef9cf Mon Sep 17 00:00:00 2001 From: Ryan Ofsky Date: Mon, 12 Sep 2022 11:09:06 -0400 Subject: interfaces: Change getUnspentOutput return type to avoid multiprocess segfault Coin serialize method segfaults if IsSpent condition is true. This caused multiprocess code to segfault when serializing the Coin& output argument to of the Node::getUnspentOutput method if the coin was not found. Segfault could be triggered by double clicking and viewing transaction details in the GUI transaction list. Fix this by replacing Coin& output argument with optional return value to avoid trying to serializing spent coins. --- src/node/interfaces.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/node') diff --git a/src/node/interfaces.cpp b/src/node/interfaces.cpp index f6dbe4f008..944c26f00a 100644 --- a/src/node/interfaces.cpp +++ b/src/node/interfaces.cpp @@ -328,10 +328,12 @@ public: std::vector listRpcCommands() override { return ::tableRPC.listCommands(); } void rpcSetTimerInterfaceIfUnset(RPCTimerInterface* iface) override { RPCSetTimerInterfaceIfUnset(iface); } void rpcUnsetTimerInterface(RPCTimerInterface* iface) override { RPCUnsetTimerInterface(iface); } - bool getUnspentOutput(const COutPoint& output, Coin& coin) override + std::optional getUnspentOutput(const COutPoint& output) override { LOCK(::cs_main); - return chainman().ActiveChainstate().CoinsTip().GetCoin(output, coin); + Coin coin; + if (chainman().ActiveChainstate().CoinsTip().GetCoin(output, coin)) return coin; + return {}; } TransactionError broadcastTransaction(CTransactionRef tx, CAmount max_tx_fee, std::string& err_string) override { -- cgit v1.2.3 From 441d00c60f0a67889d23f8556190ff99dde488bc Mon Sep 17 00:00:00 2001 From: Ryan Ofsky Date: Tue, 26 Sep 2023 13:47:05 -0400 Subject: interfaces: Rename CalculateBumpFees methods to be compatible with capn'proto --- src/node/interfaces.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/node') diff --git a/src/node/interfaces.cpp b/src/node/interfaces.cpp index 944c26f00a..c876d9b6a7 100644 --- a/src/node/interfaces.cpp +++ b/src/node/interfaces.cpp @@ -671,7 +671,7 @@ public: m_node.mempool->GetTransactionAncestry(txid, ancestors, descendants, ancestorsize, ancestorfees); } - std::map CalculateIndividualBumpFees(const std::vector& outpoints, const CFeeRate& target_feerate) override + std::map calculateIndividualBumpFees(const std::vector& outpoints, const CFeeRate& target_feerate) override { if (!m_node.mempool) { std::map bump_fees; @@ -683,7 +683,7 @@ public: return MiniMiner(*m_node.mempool, outpoints).CalculateBumpFees(target_feerate); } - std::optional CalculateCombinedBumpFee(const std::vector& outpoints, const CFeeRate& target_feerate) override + std::optional calculateCombinedBumpFee(const std::vector& outpoints, const CFeeRate& target_feerate) override { if (!m_node.mempool) { return 0; -- cgit v1.2.3