Skip to content

Commit

Permalink
fixed getAddrCommentIfAvail
Browse files Browse the repository at this point in the history
  • Loading branch information
goatpig committed Mar 25, 2014
1 parent 70d9ab9 commit 44a9d5c
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 21 deletions.
71 changes: 52 additions & 19 deletions cppForSwig/BlockUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1000,7 +1000,8 @@ void BlockDataManager_LevelDB::registeredScrAddrScan( Tx & theTx )
void BtcWallet::scanTx(Tx & tx,
uint32_t txIndex,
uint32_t txtime,
uint32_t blknum)
uint32_t blknum,
bool mainwallet)
{

int64_t totalLedgerAmt = 0;
Expand Down Expand Up @@ -1100,8 +1101,6 @@ void BtcWallet::scanTx(Tx & tx,
false, // SentToSelf is meaningless for addr ledger
false); // "isChangeBack" is meaningless for TxIn
thisAddrPtr->addLedgerEntry(newEntry, isZeroConf);
ledgerAllAddr_.push_back(newEntry);


// Update last seen on the network
thisAddrPtr->setLastTimestamp(txtime);
Expand Down Expand Up @@ -1227,7 +1226,6 @@ void BtcWallet::scanTx(Tx & tx,
false, // sentToSelf meaningless for addr ledger
false); // we don't actually know
thisAddrPtr->addLedgerEntry(newLedger, isZeroConf);
ledgerAllAddr_.push_back(newLedger);
}
// Check if this is the first time we've seen this
if(thisAddrPtr->getFirstTimestamp() == 0)
Expand All @@ -1244,33 +1242,66 @@ void BtcWallet::scanTx(Tx & tx,

bool allTxOutIsOurs = true;
bool anyTxOutIsOurs = false;
vector<BinaryData> scrAddrV;
for(uint32_t i=0; i<tx.getNumTxOut(); i++)
{
if( thisTxOutIsOurs[i] )
{
anyTxOutIsOurs = true;
if(!mainwallet)
{
TxOut txout = tx.getTxOutCopy(i);
if( txout.getScriptType() != TXOUT_SCRIPT_NONSTANDARD )
scrAddrV.push_back(txout.getScrAddressStr());
}
}
else
allTxOutIsOurs = false;
}

bool isSentToSelf = (anyTxInIsOurs && allTxOutIsOurs);
bool isChangeBack = (anyTxInIsOurs && anyTxOutIsOurs && !isSentToSelf);

if(anyNewTxInIsOurs || anyNewTxOutIsOurs)
if((anyNewTxInIsOurs || anyNewTxOutIsOurs))
{
LedgerEntry le( BinaryData(0),
totalLedgerAmt,
blknum,
tx.getThisHash(),
txIndex,
txtime,
isCoinbaseTx,
isSentToSelf,
isChangeBack);

if(isZeroConf)
ledgerAllAddrZC_.push_back(le);
if(mainwallet)
{
LedgerEntry le( BinaryData(0),
totalLedgerAmt,
blknum,
tx.getThisHash(),
txIndex,
txtime,
isCoinbaseTx,
isSentToSelf,
isChangeBack);

if(isZeroConf)
ledgerAllAddrZC_.push_back(le);
else
ledgerAllAddr_.push_back(le);
}
else
ledgerAllAddr_.push_back(le);
{
vector<BinaryData>::iterator saIt;
for(saIt = scrAddrV.begin(); saIt != scrAddrV.end(); saIt++)
{
LedgerEntry le( (*saIt),
totalLedgerAmt,
blknum,
tx.getThisHash(),
txIndex,
txtime,
isCoinbaseTx,
isSentToSelf,
isChangeBack);

if(isZeroConf)
ledgerAllAddrZC_.push_back(le);
else
ledgerAllAddr_.push_back(le);
}
}
}
}

Expand Down Expand Up @@ -3693,6 +3724,8 @@ void BlockDataManager_LevelDB::scanRegisteredTxForWallet( BtcWallet & wlt,
SCOPED_TIMER("scanRegisteredTxForWallet");

if(wlt.lastScanned_ > blkStart) blkStart = wlt.lastScanned_;
bool isMainWallet = true;
if(&wlt != (*registeredWallets_.begin())) isMainWallet = false;

// Make sure RegisteredTx objects have correct data, then sort.
// TODO: Why did I not need this with the MMAP blockchain? Somehow
Expand Down Expand Up @@ -3740,7 +3773,7 @@ void BlockDataManager_LevelDB::scanRegisteredTxForWallet( BtcWallet & wlt,
continue;

// If we made it here, we want to scan this tx!
wlt.scanTx(theTx, txIter->txIndex_, bhptr->getTimestamp(), thisBlk);
wlt.scanTx(theTx, txIter->txIndex_, bhptr->getTimestamp(), thisBlk, isMainWallet);
}

wlt.sortLedger();
Expand Down
5 changes: 3 additions & 2 deletions cppForSwig/BlockUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -388,10 +388,11 @@ class BtcWallet
map<OutPoint, TxIOPair> const & txiomap,
bool withMultiSig=false) const;

void scanTx(Tx & tx,
void scanTx(Tx & tx,
uint32_t txIndex = UINT32_MAX,
uint32_t blktime = UINT32_MAX,
uint32_t blknum = UINT32_MAX);
uint32_t blknum = UINT32_MAX,
bool mainwallet = true);

void scanNonStdTx(uint32_t blknum,
uint32_t txidx,
Expand Down

0 comments on commit 44a9d5c

Please sign in to comment.