@@ -848,19 +848,19 @@ void CWallet::LoadToWallet(CWalletTx& wtxIn)
848
848
}
849
849
}
850
850
851
- bool CWallet::AddToWalletIfInvolvingMe (const CTransactionRef& ptx, CWalletTx::Status status, const uint256& block_hash, int posInBlock , bool fUpdate )
851
+ bool CWallet::AddToWalletIfInvolvingMe (const CTransactionRef& ptx, CWalletTx::Confirmation confirm , bool fUpdate )
852
852
{
853
853
const CTransaction& tx = *ptx;
854
854
{
855
855
AssertLockHeld (cs_wallet);
856
856
857
- if (!block_hash .IsNull ()) {
857
+ if (!confirm. hashBlock .IsNull ()) {
858
858
for (const CTxIn& txin : tx.vin ) {
859
859
std::pair<TxSpends::const_iterator, TxSpends::const_iterator> range = mapTxSpends.equal_range (txin.prevout );
860
860
while (range.first != range.second ) {
861
861
if (range.first ->second != tx.GetHash ()) {
862
- WalletLogPrintf (" Transaction %s (in block %s) conflicts with wallet transaction %s (both spend %s:%i)\n " , tx.GetHash ().ToString (), block_hash .ToString (), range.first ->second .ToString (), range.first ->first .hash .ToString (), range.first ->first .n );
863
- MarkConflicted (block_hash , range.first ->second );
862
+ WalletLogPrintf (" Transaction %s (in block %s) conflicts with wallet transaction %s (both spend %s:%i)\n " , tx.GetHash ().ToString (), confirm. hashBlock .ToString (), range.first ->second .ToString (), range.first ->first .hash .ToString (), range.first ->first .n );
863
+ MarkConflicted (confirm. hashBlock , range.first ->second );
864
864
}
865
865
range.first ++;
866
866
}
@@ -888,7 +888,7 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransactionRef& ptx, CWalletTx::St
888
888
889
889
// Block disconnection override an abandoned tx as unconfirmed
890
890
// which means user may have to call abandontransaction again
891
- wtx.SetConf (status, block_hash, posInBlock) ;
891
+ wtx.m_confirm = confirm ;
892
892
893
893
return AddToWallet (wtx, false );
894
894
}
@@ -1022,9 +1022,9 @@ void CWallet::MarkConflicted(const uint256& hashBlock, const uint256& hashTx)
1022
1022
}
1023
1023
}
1024
1024
1025
- void CWallet::SyncTransaction (const CTransactionRef& ptx, CWalletTx::Status status, const uint256& block_hash, int posInBlock , bool update_tx)
1025
+ void CWallet::SyncTransaction (const CTransactionRef& ptx, CWalletTx::Confirmation confirm , bool update_tx)
1026
1026
{
1027
- if (!AddToWalletIfInvolvingMe (ptx, status, block_hash, posInBlock , update_tx))
1027
+ if (!AddToWalletIfInvolvingMe (ptx, confirm , update_tx))
1028
1028
return ; // Not one of ours
1029
1029
1030
1030
// If a transaction changes 'conflicted' state, that changes the balance
@@ -1036,7 +1036,8 @@ void CWallet::SyncTransaction(const CTransactionRef& ptx, CWalletTx::Status stat
1036
1036
void CWallet::TransactionAddedToMempool (const CTransactionRef& ptx) {
1037
1037
auto locked_chain = chain ().lock ();
1038
1038
LOCK (cs_wallet);
1039
- SyncTransaction (ptx, CWalletTx::Status::UNCONFIRMED, {} /* block hash */ , 0 /* position in block */ );
1039
+ CWalletTx::Confirmation confirm (CWalletTx::Status::UNCONFIRMED, {}, 0 );
1040
+ SyncTransaction (ptx, confirm);
1040
1041
1041
1042
auto it = mapWallet.find (ptx->GetHash ());
1042
1043
if (it != mapWallet.end ()) {
@@ -1061,7 +1062,8 @@ void CWallet::BlockConnected(const CBlock& block, const std::vector<CTransaction
1061
1062
m_last_block_processed_height = height;
1062
1063
m_last_block_processed = block_hash;
1063
1064
for (size_t i = 0 ; i < block.vtx .size (); i++) {
1064
- SyncTransaction (block.vtx [i], CWalletTx::Status::CONFIRMED, block_hash, i);
1065
+ CWalletTx::Confirmation confirm (CWalletTx::Status::CONFIRMED, m_last_block_processed, i);
1066
+ SyncTransaction (block.vtx [i], confirm);
1065
1067
TransactionRemovedFromMempool (block.vtx [i]);
1066
1068
}
1067
1069
for (const CTransactionRef& ptx : vtxConflicted) {
@@ -1081,7 +1083,8 @@ void CWallet::BlockDisconnected(const CBlock& block, int height)
1081
1083
m_last_block_processed_height = height - 1 ;
1082
1084
m_last_block_processed = block.hashPrevBlock ;
1083
1085
for (const CTransactionRef& ptx : block.vtx ) {
1084
- SyncTransaction (ptx, CWalletTx::Status::UNCONFIRMED, {} /* block hash */ , 0 /* position in block */ );
1086
+ CWalletTx::Confirmation confirm (CWalletTx::Status::UNCONFIRMED, {}, 0 );
1087
+ SyncTransaction (ptx, confirm);
1085
1088
}
1086
1089
}
1087
1090
@@ -1627,7 +1630,8 @@ CWallet::ScanResult CWallet::ScanForWalletTransactions(const uint256& start_bloc
1627
1630
break ;
1628
1631
}
1629
1632
for (size_t posInBlock = 0 ; posInBlock < block.vtx .size (); ++posInBlock) {
1630
- SyncTransaction (block.vtx [posInBlock], CWalletTx::Status::CONFIRMED, block_hash, posInBlock, fUpdate );
1633
+ CWalletTx::Confirmation confirm (CWalletTx::Status::CONFIRMED, block_hash, posInBlock);
1634
+ SyncTransaction (block.vtx [posInBlock], confirm, fUpdate );
1631
1635
}
1632
1636
// scan succeeded, record block as most recent successfully scanned
1633
1637
result.last_scanned_block = block_hash;
@@ -3918,18 +3922,6 @@ CKeyPool::CKeyPool(const CPubKey& vchPubKeyIn, bool internalIn)
3918
3922
m_pre_split = false ;
3919
3923
}
3920
3924
3921
- void CWalletTx::SetConf (Status status, const uint256& block_hash, int posInBlock)
3922
- {
3923
- // Update tx status
3924
- m_confirm.status = status;
3925
-
3926
- // Update the tx's hashBlock
3927
- m_confirm.hashBlock = block_hash;
3928
-
3929
- // set the position of the transaction in the block
3930
- m_confirm.nIndex = posInBlock;
3931
- }
3932
-
3933
3925
int CWalletTx::GetDepthInMainChain (interfaces::Chain::Lock& locked_chain) const
3934
3926
{
3935
3927
if (isUnconfirmed () || isAbandoned ()) return 0 ;
0 commit comments