Skip to content

Commit cf63d63

Browse files
author
MarcoFalke
committed
Merge bitcoin/bitcoin#23499: multiprocess: Add interfaces::Node::broadCastTransaction method
0e0f4fd 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
2 parents ffdab41 + 0e0f4fd commit cf63d63

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
@@ -30,6 +30,7 @@ class RPCTimerInterface;
3030
class UniValue;
3131
class proxyType;
3232
enum class SynchronizationState;
33+
enum class TransactionError;
3334
struct CNodeStateStats;
3435
struct NodeContext;
3536
struct bilingual_str;
@@ -183,6 +184,9 @@ class Node
183184
//! Get unspent outputs associated with a transaction.
184185
virtual bool getUnspentOutput(const COutPoint& output, Coin& coin) = 0;
185186

187+
//! Broadcast transaction.
188+
virtual TransactionError broadcastTransaction(CTransactionRef tx, CAmount max_tx_fee, std::string& err_string) = 0;
189+
186190
//! Get wallet client.
187191
virtual WalletClient& walletClient() = 0;
188192

src/node/interfaces.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,10 @@ class NodeImpl : public Node
276276
LOCK(::cs_main);
277277
return chainman().ActiveChainstate().CoinsTip().GetCoin(output, coin);
278278
}
279+
TransactionError broadcastTransaction(CTransactionRef tx, CAmount max_tx_fee, std::string& err_string) override
280+
{
281+
return BroadcastTransaction(*m_context, std::move(tx), err_string, max_tx_fee, /*relay=*/ true, /*wait_callback=*/ false);
282+
}
279283
WalletClient& walletClient() override
280284
{
281285
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)