@ -2150,11 +2150,11 @@ void CWallet::ReacceptWalletTransactions(interfaces::Chain::Lock& locked_chain)
for ( const std : : pair < const int64_t , CWalletTx * > & item : mapSorted ) {
for ( const std : : pair < const int64_t , CWalletTx * > & item : mapSorted ) {
CWalletTx & wtx = * ( item . second ) ;
CWalletTx & wtx = * ( item . second ) ;
std : : string unused_err_string ;
std : : string unused_err_string ;
wtx . SubmitMemoryPoolAndRelay ( unused_err_string , false );
wtx . SubmitMemoryPoolAndRelay ( unused_err_string , false , locked_chain );
}
}
}
}
bool CWalletTx : : SubmitMemoryPoolAndRelay ( std : : string & err_string , bool relay )
bool CWalletTx : : SubmitMemoryPoolAndRelay ( std : : string & err_string , bool relay , interfaces : : Chain : : Lock & locked_chain )
{
{
// Can't relay if wallet is not broadcasting
// Can't relay if wallet is not broadcasting
if ( ! pwallet - > GetBroadcastTransactions ( ) ) return false ;
if ( ! pwallet - > GetBroadcastTransactions ( ) ) return false ;
@ -2163,6 +2163,8 @@ bool CWalletTx::SubmitMemoryPoolAndRelay(std::string& err_string, bool relay)
// Don't try to submit coinbase transactions. These would fail anyway but would
// Don't try to submit coinbase transactions. These would fail anyway but would
// cause log spam.
// cause log spam.
if ( IsCoinBase ( ) ) return false ;
if ( IsCoinBase ( ) ) return false ;
// Don't try to submit conflicted or confirmed transactions.
if ( GetDepthInMainChain ( locked_chain ) ! = 0 ) return false ;
// Submit transaction to mempool for relay
// Submit transaction to mempool for relay
pwallet - > WalletLogPrintf ( " Submitting wtx %s to mempool for relay \n " , GetHash ( ) . ToString ( ) ) ;
pwallet - > WalletLogPrintf ( " Submitting wtx %s to mempool for relay \n " , GetHash ( ) . ToString ( ) ) ;
@ -2377,11 +2379,12 @@ void CWallet::ResendWalletTransactions()
// Relay transactions
// Relay transactions
for ( std : : pair < const uint256 , CWalletTx > & item : mapWallet ) {
for ( std : : pair < const uint256 , CWalletTx > & item : mapWallet ) {
CWalletTx & wtx = item . second ;
CWalletTx & wtx = item . second ;
// only rebroadcast unconfirmed txes older than 5 minutes before the
// Attempt to rebroadcast all txes more than 5 minutes older than
// last block was found
// the last block. SubmitMemoryPoolAndRelay() will not rebroadcast
// any confirmed or conflicting txs.
if ( wtx . nTimeReceived > m_best_block_time - 5 * 60 ) continue ;
if ( wtx . nTimeReceived > m_best_block_time - 5 * 60 ) continue ;
std : : string unused_err_string ;
std : : string unused_err_string ;
if ( wtx . SubmitMemoryPoolAndRelay ( unused_err_string , true )) + + submitted_tx_count ;
if ( wtx . SubmitMemoryPoolAndRelay ( unused_err_string , true , * locked_chain )) + + submitted_tx_count ;
}
}
} // locked_chain and cs_wallet
} // locked_chain and cs_wallet
@ -3326,7 +3329,7 @@ bool CWallet::CommitTransaction(CTransactionRef tx, mapValue_t mapValue, std::ve
if ( fBroadcastTransactions )
if ( fBroadcastTransactions )
{
{
std : : string err_string ;
std : : string err_string ;
if ( ! wtx . SubmitMemoryPoolAndRelay ( err_string , true )) {
if ( ! wtx . SubmitMemoryPoolAndRelay ( err_string , true , * locked_chain )) {
WalletLogPrintf ( " CommitTransaction(): Transaction cannot be broadcast immediately, %s \n " , err_string ) ;
WalletLogPrintf ( " CommitTransaction(): Transaction cannot be broadcast immediately, %s \n " , err_string ) ;
// TODO: if we expect the failure to be long term or permanent, instead delete wtx from the wallet and return failure.
// TODO: if we expect the failure to be long term or permanent, instead delete wtx from the wallet and return failure.
}
}