aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2021-11-16 08:42:17 +0100
committerMarcoFalke <falke.marco@gmail.com>2021-11-16 08:42:21 +0100
commitcf63d635b168fe4166f56839101b4200f09e3844 (patch)
tree7a7ec7f3e6f0c15236dc69fe3bfa151665b396f5
parentffdab41f94521dc87e68a160546af55355340af5 (diff)
parent0e0f4fdd892223766db4a83194b6576847b757f7 (diff)
Merge bitcoin/bitcoin#23499: multiprocess: Add interfaces::Node::broadCastTransaction method
0e0f4fdd892223766db4a83194b6576847b757f7 multiprocess: Add interfaces::Node::broadCastTransaction method (Russell Yanofsky) Pull request description: This fixes a null pointer crash in the bitcoin-gui PSBT dialog. The bitcoin-gui interfaces::Node object has a null NodeContext pointer, and can't broadcast transactions directly. It needs to broadcast transactions through the bitcoin-node process instead. --- This PR is part of the [process separation project](https://github.com/bitcoin/bitcoin/projects/10). ACKs for top commit: lsilva01: Code Review ACK 0e0f4fd Tree-SHA512: cd2c1fe8dc15e7cecf01a21d64319d6add1124995305a9ef9cb72f8492dc692c62d4f846182567d47a5048a533178a925419250941a47cb39932467c36bea3e1
-rw-r--r--src/interfaces/node.h4
-rw-r--r--src/node/interfaces.cpp4
-rw-r--r--src/qt/psbtoperationsdialog.cpp4
3 files changed, 10 insertions, 2 deletions
diff --git a/src/interfaces/node.h b/src/interfaces/node.h
index ea1cb5ed72..974156e6e1 100644
--- a/src/interfaces/node.h
+++ b/src/interfaces/node.h
@@ -30,6 +30,7 @@ class RPCTimerInterface;
class UniValue;
class proxyType;
enum class SynchronizationState;
+enum class TransactionError;
struct CNodeStateStats;
struct NodeContext;
struct bilingual_str;
@@ -183,6 +184,9 @@ public:
//! Get unspent outputs associated with a transaction.
virtual bool getUnspentOutput(const COutPoint& output, Coin& coin) = 0;
+ //! Broadcast transaction.
+ virtual TransactionError broadcastTransaction(CTransactionRef tx, CAmount max_tx_fee, std::string& err_string) = 0;
+
//! Get wallet client.
virtual WalletClient& walletClient() = 0;
diff --git a/src/node/interfaces.cpp b/src/node/interfaces.cpp
index 9f457570fa..9c2d23f839 100644
--- a/src/node/interfaces.cpp
+++ b/src/node/interfaces.cpp
@@ -276,6 +276,10 @@ public:
LOCK(::cs_main);
return chainman().ActiveChainstate().CoinsTip().GetCoin(output, coin);
}
+ TransactionError broadcastTransaction(CTransactionRef tx, CAmount max_tx_fee, std::string& err_string) override
+ {
+ return BroadcastTransaction(*m_context, std::move(tx), err_string, max_tx_fee, /*relay=*/ true, /*wait_callback=*/ false);
+ }
WalletClient& walletClient() override
{
return *Assert(m_context->wallet_client);
diff --git a/src/qt/psbtoperationsdialog.cpp b/src/qt/psbtoperationsdialog.cpp
index 34d56e5506..3e598bfab9 100644
--- a/src/qt/psbtoperationsdialog.cpp
+++ b/src/qt/psbtoperationsdialog.cpp
@@ -110,8 +110,8 @@ void PSBTOperationsDialog::broadcastTransaction()
CTransactionRef tx = MakeTransactionRef(mtx);
std::string err_string;
- TransactionError error = BroadcastTransaction(
- *m_client_model->node().context(), tx, err_string, DEFAULT_MAX_RAW_TX_FEE_RATE.GetFeePerK(), /* relay */ true, /* await_callback */ false);
+ TransactionError error =
+ m_client_model->node().broadcastTransaction(tx, DEFAULT_MAX_RAW_TX_FEE_RATE.GetFeePerK(), err_string);
if (error == TransactionError::OK) {
showStatus(tr("Transaction broadcast successfully! Transaction ID: %1")