Page MenuHomePhabricator

D6406.diff
No OneTemporary

D6406.diff

diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h
--- a/src/wallet/wallet.h
+++ b/src/wallet/wallet.h
@@ -626,7 +626,7 @@
int64_t GetTxTime() const;
- // RelayWalletTransaction may only be called if fBroadcastTransactions!
+ // Pass this transaction to the node to relay to its peers
bool RelayWalletTransaction(interfaces::Chain::Lock &locked_chain);
/**
diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp
--- a/src/wallet/wallet.cpp
+++ b/src/wallet/wallet.cpp
@@ -2169,23 +2169,37 @@
}
bool CWalletTx::RelayWalletTransaction(interfaces::Chain::Lock &locked_chain) {
- assert(pwallet->GetBroadcastTransactions());
- if (IsCoinBase() || isAbandoned() ||
- GetDepthInMainChain(locked_chain) != 0) {
+ // Can't relay if wallet is not broadcasting
+ if (!pwallet->GetBroadcastTransactions()) {
return false;
}
-
- CValidationState state;
- // GetDepthInMainChain already catches known conflicts.
- if (InMempool() || AcceptToMemoryPool(locked_chain, state)) {
- pwallet->WalletLogPrintf("Relaying wtx %s\n", GetId().ToString());
- if (pwallet->chain().p2pEnabled()) {
- pwallet->chain().relayTransaction(GetId());
- return true;
- }
+ // Don't relay coinbase transactions outside blocks
+ if (IsCoinBase()) {
+ return false;
+ }
+ // Don't relay abandoned transactions
+ if (isAbandoned()) {
+ return false;
+ }
+ // Don't relay conflicted or already confirmed transactions
+ if (GetDepthInMainChain(locked_chain) != 0) {
+ return false;
+ }
+ // Don't relay transactions that aren't accepted to the mempool
+ CValidationState unused_state;
+ if (!InMempool() && !AcceptToMemoryPool(locked_chain, unused_state)) {
+ return false;
+ }
+ // Don't try to relay if the node is not connected to the p2p network
+ if (!pwallet->chain().p2pEnabled()) {
+ return false;
}
- return false;
+ // Try to relay the transaction
+ pwallet->WalletLogPrintf("Relaying wtx %s\n", GetId().ToString());
+ pwallet->chain().relayTransaction(GetId());
+
+ return true;
}
std::set<TxId> CWalletTx::GetConflicts() const {

File Metadata

Mime Type
text/plain
Expires
Sat, Mar 1, 12:38 (8 m, 42 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5187866
Default Alt Text
D6406.diff (2 KB)

Event Timeline