Skip to content

Commit 0e0f4fd

Browse files
committed
multiprocess: Add interfaces::Node::broadCastTransaction method
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.
1 parent c9dd5c8 commit 0e0f4fd

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

src/interfaces/node.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ class RPCTimerInterface;
3131
class UniValue;
3232
class proxyType;
3333
enum class SynchronizationState;
34+
enum class TransactionError;
3435
struct CNodeStateStats;
3536
struct NodeContext;
3637
struct bilingual_str;
@@ -174,6 +175,9 @@ class Node
174175
//! Get unspent outputs associated with a transaction.
175176
virtual bool getUnspentOutput(const COutPoint& output, Coin& coin) = 0;
176177

178+
//! Broadcast transaction.
179+
virtual TransactionError broadcastTransaction(CTransactionRef tx, CAmount max_tx_fee, std::string& err_string) = 0;
180+
177181
//! Get wallet client.
178182
virtual WalletClient& walletClient() = 0;
179183

src/node/interfaces.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,10 @@ class NodeImpl : public Node
261261
LOCK(::cs_main);
262262
return chainman().ActiveChainstate().CoinsTip().GetCoin(output, coin);
263263
}
264+
TransactionError broadcastTransaction(CTransactionRef tx, CAmount max_tx_fee, std::string& err_string) override
265+
{
266+
return BroadcastTransaction(*m_context, std::move(tx), err_string, max_tx_fee, /*relay=*/ true, /*wait_callback=*/ false);
267+
}
264268
WalletClient& walletClient() override
265269
{
266270
return *Assert(m_context->wallet_client);

src/qt/psbtoperationsdialog.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,8 @@ void PSBTOperationsDialog::broadcastTransaction()
110110

111111
CTransactionRef tx = MakeTransactionRef(mtx);
112112
std::string err_string;
113-
TransactionError error = BroadcastTransaction(
114-
*m_client_model->node().context(), tx, err_string, DEFAULT_MAX_RAW_TX_FEE_RATE.GetFeePerK(), /* relay */ true, /* await_callback */ false);
113+
TransactionError error =
114+
m_client_model->node().broadcastTransaction(tx, DEFAULT_MAX_RAW_TX_FEE_RATE.GetFeePerK(), err_string);
115115

116116
if (error == TransactionError::OK) {
117117
showStatus(tr("Transaction broadcast successfully! Transaction ID: %1")

0 commit comments

Comments
 (0)