@ -644,7 +644,7 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl
CWalletTx wtx ( this , tx ) ;
CWalletTx wtx ( this , tx ) ;
// Get merkle branch if transaction was found in a block
// Get merkle branch if transaction was found in a block
if ( pblock )
if ( pblock )
wtx . SetMerkleBranch ( pblock ) ;
wtx . SetMerkleBranch ( * pblock ) ;
return AddToWallet ( wtx ) ;
return AddToWallet ( wtx ) ;
}
}
}
}
@ -2195,32 +2195,19 @@ CWalletKey::CWalletKey(int64_t nExpires)
nTimeExpires = nExpires ;
nTimeExpires = nExpires ;
}
}
int CMerkleTx : : SetMerkleBranch ( const CBlock * p block)
int CMerkleTx : : SetMerkleBranch ( const CBlock & block )
{
{
AssertLockHeld ( cs_main ) ;
AssertLockHeld ( cs_main ) ;
CBlock blockTmp ;
CBlock blockTmp ;
if ( pblock = = NULL ) {
CCoins coins ;
if ( pcoinsTip - > GetCoins ( GetHash ( ) , coins ) ) {
CBlockIndex * pindex = chainActive [ coins . nHeight ] ;
if ( pindex ) {
if ( ! ReadBlockFromDisk ( blockTmp , pindex ) )
return 0 ;
pblock = & blockTmp ;
}
}
}
if ( pblock ) {
// Update the tx's hashBlock
// Update the tx's hashBlock
hashBlock = pblock - > GetHash ( ) ;
hashBlock = block . GetHash ( ) ;
// Locate the transaction
// Locate the transaction
for ( nIndex = 0 ; nIndex < ( int ) pblock - > vtx . size ( ) ; nIndex + + )
for ( nIndex = 0 ; nIndex < ( int ) block . vtx . size ( ) ; nIndex + + )
if ( pblock - > vtx [ nIndex ] = = * ( CTransaction * ) this )
if ( block . vtx [ nIndex ] = = * ( CTransaction * ) this )
break ;
break ;
if ( nIndex = = ( int ) pblock - > vtx . size ( ) )
if ( nIndex = = ( int ) block . vtx . size ( ) )
{
{
vMerkleBranch . clear ( ) ;
vMerkleBranch . clear ( ) ;
nIndex = - 1 ;
nIndex = - 1 ;
@ -2229,14 +2216,13 @@ int CMerkleTx::SetMerkleBranch(const CBlock* pblock)
}
}
// Fill in merkle branch
// Fill in merkle branch
vMerkleBranch = pblock - > GetMerkleBranch ( nIndex ) ;
vMerkleBranch = block . GetMerkleBranch ( nIndex ) ;
}
// Is the tx in a block that's in the main chain
// Is the tx in a block that's in the main chain
map < uint256 , CBlockIndex * > : : iterator mi = mapBlockIndex . find ( hashBlock ) ;
map < uint256 , CBlockIndex * > : : iterator mi = mapBlockIndex . find ( hashBlock ) ;
if ( mi = = mapBlockIndex . end ( ) )
if ( mi = = mapBlockIndex . end ( ) )
return 0 ;
return 0 ;
CBlockIndex * pindex = ( * mi ) . second ;
const CBlockIndex * pindex = ( * mi ) . second ;
if ( ! pindex | | ! chainActive . Contains ( pindex ) )
if ( ! pindex | | ! chainActive . Contains ( pindex ) )
return 0 ;
return 0 ;