@ -1946,7 +1946,7 @@ CAmount CWallet::GetImmatureWatchOnlyBalance() const
return nTotal ;
return nTotal ;
}
}
void CWallet : : AvailableCoins ( std : : vector < COutput > & vCoins , bool fOnlyConfirmed , const CCoinControl * coinControl , bool fIncludeZeroValue ) const
void CWallet : : AvailableCoins ( std : : vector < COutput > & vCoins , bool fOnlySafe , const CCoinControl * coinControl , bool fIncludeZeroValue ) const
{
{
vCoins . clear ( ) ;
vCoins . clear ( ) ;
@ -1960,9 +1960,6 @@ void CWallet::AvailableCoins(std::vector<COutput>& vCoins, bool fOnlyConfirmed,
if ( ! CheckFinalTx ( * pcoin ) )
if ( ! CheckFinalTx ( * pcoin ) )
continue ;
continue ;
if ( fOnlyConfirmed & & ! pcoin - > IsTrusted ( ) )
continue ;
if ( pcoin - > IsCoinBase ( ) & & pcoin - > GetBlocksToMaturity ( ) > 0 )
if ( pcoin - > IsCoinBase ( ) & & pcoin - > GetBlocksToMaturity ( ) > 0 )
continue ;
continue ;
@ -1975,6 +1972,8 @@ void CWallet::AvailableCoins(std::vector<COutput>& vCoins, bool fOnlyConfirmed,
if ( nDepth = = 0 & & ! pcoin - > InMempool ( ) )
if ( nDepth = = 0 & & ! pcoin - > InMempool ( ) )
continue ;
continue ;
bool safeTx = pcoin - > IsTrusted ( ) ;
// We should not consider coins from transactions that are replacing
// We should not consider coins from transactions that are replacing
// other transactions.
// other transactions.
//
//
@ -1990,8 +1989,8 @@ void CWallet::AvailableCoins(std::vector<COutput>& vCoins, bool fOnlyConfirmed,
// be a 1-block reorg away from the chain where transactions A and C
// be a 1-block reorg away from the chain where transactions A and C
// were accepted to another chain where B, B', and C were all
// were accepted to another chain where B, B', and C were all
// accepted.
// accepted.
if ( nDepth = = 0 & & fOnlyConfirmed & & pcoin - > mapValue . count ( " replaces_txid " ) ) {
if ( nDepth = = 0 & & pcoin - > mapValue . count ( " replaces_txid " ) ) {
continu e;
safeTx = fals e;
}
}
// Similarly, we should not consider coins from transactions that
// Similarly, we should not consider coins from transactions that
@ -2002,7 +2001,11 @@ void CWallet::AvailableCoins(std::vector<COutput>& vCoins, bool fOnlyConfirmed,
// intending to replace A', but potentially resulting in a scenario
// intending to replace A', but potentially resulting in a scenario
// where A, A', and D could all be accepted (instead of just B and
// where A, A', and D could all be accepted (instead of just B and
// D, or just A and A' like the user would want).
// D, or just A and A' like the user would want).
if ( nDepth = = 0 & & fOnlyConfirmed & & pcoin - > mapValue . count ( " replaced_by_txid " ) ) {
if ( nDepth = = 0 & & pcoin - > mapValue . count ( " replaced_by_txid " ) ) {
safeTx = false ;
}
if ( fOnlySafe & & ! safeTx ) {
continue ;
continue ;
}
}
@ -2014,7 +2017,7 @@ void CWallet::AvailableCoins(std::vector<COutput>& vCoins, bool fOnlyConfirmed,
vCoins . push_back ( COutput ( pcoin , i , nDepth ,
vCoins . push_back ( COutput ( pcoin , i , nDepth ,
( ( mine & ISMINE_SPENDABLE ) ! = ISMINE_NO ) | |
( ( mine & ISMINE_SPENDABLE ) ! = ISMINE_NO ) | |
( coinControl & & coinControl - > fAllowWatchOnly & & ( mine & ISMINE_WATCH_SOLVABLE ) ! = ISMINE_NO ) ,
( coinControl & & coinControl - > fAllowWatchOnly & & ( mine & ISMINE_WATCH_SOLVABLE ) ! = ISMINE_NO ) ,
( mine & ( ISMINE_SPENDABLE | ISMINE_WATCH_SOLVABLE ) ) ! = ISMINE_NO ) ) ;
( mine & ( ISMINE_SPENDABLE | ISMINE_WATCH_SOLVABLE ) ) ! = ISMINE_NO , safeTx ) ) ;
}
}
}
}
}
}