diff --git a/src/interfaces/node.h b/src/interfaces/node.h index 34fdde3774..12f2fce22b 100644 --- a/src/interfaces/node.h +++ b/src/interfaces/node.h @@ -31,6 +31,7 @@ class RPCTimerInterface; class UniValue; class proxyType; enum class SynchronizationState; +enum class TransactionError; struct CNodeStateStats; struct NodeContext; struct bilingual_str; @@ -174,6 +175,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 192caf7994..57142e1c73 100644 --- a/src/node/interfaces.cpp +++ b/src/node/interfaces.cpp @@ -261,6 +261,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")