コード例 #1
0
void TestZeroConf(void)
{

   BlockDataManager_MMAP & bdm = BlockDataManager_MMAP::GetInstance(); 
   BinaryData myAddress;
   BtcWallet wlt;
   /*
   bdm.Reset();
   bdm.readBlkFile_FromScratch("zctest/blk0001.dat");

   // More testnet addresses, with only a few transactions
   myAddress.createFromHex("4c98e1fb7aadce864b310b2e52b685c09bdfd5e7"); wlt.addAddress(myAddress);
   myAddress.createFromHex("08ccdf1ef9269b95f6ce93899ece9f68cd5afb22"); wlt.addAddress(myAddress);
   myAddress.createFromHex("edf6bbd7ba7aad222c2b28e6d8d5001178e3680c"); wlt.addAddress(myAddress);
   myAddress.createFromHex("18d9cae7ee0be5c6d58f02a992442d2cdb9914fa"); wlt.addAddress(myAddress);

   bdm.scanBlockchainForTx(wlt);

   bdm.enableZeroConf("zctest/mempool_new.bin");
   uint32_t currBlk = bdm.getTopBlockHeader().getBlockHeight();

   ifstream zcIn("zctest/mempool.bin", ios::in | ios::binary);
   zcIn.seekg(0, ios::end);
   uint64_t filesize = (size_t)zcIn.tellg();
   zcIn.seekg(0, ios::beg);

   BinaryData memPool(filesize);
   zcIn.read((char*)memPool.getPtr(), filesize);

   BinaryRefReader brr(memPool);
   cout << "Starting Wallet:" << endl;
   bdm.rescanWalletZeroConf(wlt);
   wlt.pprintLedger();
   while(brr.getSizeRemaining() > 8)
   {
      cout << endl << endl;
      cout << "Inserting another 0-conf tx..." << endl;
      uint64_t txtime = brr.get_uint64_t();
      TxRef zcTx(brr);
      bool wasAdded = bdm.addNewZeroConfTx(zcTx.serialize(), txtime, true);

      if(wasAdded)
         bdm.rescanWalletZeroConf(wlt);

      cout << "UltBal: " << wlt.getFullBalance() << endl;
      cout << "SpdBal: " << wlt.getSpendableBalance() << endl;
      cout << "UncBal: " << wlt.getUnconfirmedBalance(currBlk) << endl;
      wlt.pprintLedger();

      cout << "Unspent TxOuts:" << endl;
      vector<UnspentTxOut> utxoList = wlt.getSpendableTxOutList(currBlk);
      uint64_t bal = 0;
      for(uint32_t i=0; i<utxoList.size(); i++)
      {
         bal += utxoList[i].getValue();
         utxoList[i].pprintOneLine(currBlk);
      }
      cout << "Sum of TxOuts: " << bal/1e8 << endl;
   }
   */

   ifstream is("zctest/mempool_new.bin", ios::in  | ios::binary);
   ofstream os("zctest/mempool.bin",     ios::out | ios::binary);
   is.seekg(0, ios::end);
   uint64_t filesize = (size_t)is.tellg();
   is.seekg(0, ios::beg);
   BinaryData mempool(filesize);
   is.read ((char*)mempool.getPtr(), filesize);
   os.write((char*)mempool.getPtr(), filesize);
   is.close();
   os.close();

   ////////////////////////////////////////////////////////////////////////////
   ////////////////////////////////////////////////////////////////////////////
   // Start testing balance/wlt update after a new block comes in

   bdm.Reset();
   bdm.readBlkFile_FromScratch("zctest/blk0001.dat");
   // More testnet addresses, with only a few transactions
   wlt = BtcWallet();
   myAddress.createFromHex("4c98e1fb7aadce864b310b2e52b685c09bdfd5e7"); wlt.addAddress(myAddress);
   myAddress.createFromHex("08ccdf1ef9269b95f6ce93899ece9f68cd5afb22"); wlt.addAddress(myAddress);
   myAddress.createFromHex("edf6bbd7ba7aad222c2b28e6d8d5001178e3680c"); wlt.addAddress(myAddress);
   myAddress.createFromHex("18d9cae7ee0be5c6d58f02a992442d2cdb9914fa"); wlt.addAddress(myAddress);
   uint32_t topBlk = bdm.getTopBlockHeader().getBlockHeight();

   // This will load the memory pool into the zeroConfPool_ in BDM
   bdm.enableZeroConf("zctest/mempool.bin");

   // Now scan all transactions, which ends with scanning zero-conf
   bdm.scanBlockchainForTx(wlt);

   wlt.pprintAlot(topBlk, true);

   // The new blkfile has about 10 new blocks, one of which has these tx
   bdm.readBlkFileUpdate("zctest/blk0001_updated.dat");
   bdm.scanBlockchainForTx(wlt, topBlk);
   topBlk = bdm.getTopBlockHeader().getBlockHeight();
   wlt.pprintAlot(topBlk, true);

}
コード例 #2
0
void TestScanForWalletTx(string blkfile)
{
   BlockDataManager_MMAP & bdm = BlockDataManager_MMAP::GetInstance(); 
   bdm.readBlkFile_FromScratch(blkfile);
   /////////////////////////////////////////////////////////////////////////////
   BinaryData myAddress;
   BtcWallet wlt;
   
   // Main-network addresses
   myAddress.createFromHex("604875c897a079f4db88e5d71145be2093cae194"); wlt.addAddress(myAddress);
   myAddress.createFromHex("8996182392d6f05e732410de4fc3fa273bac7ee6"); wlt.addAddress(myAddress);
   myAddress.createFromHex("b5e2331304bc6c541ffe81a66ab664159979125b"); wlt.addAddress(myAddress);
   myAddress.createFromHex("ebbfaaeedd97bc30df0d6887fd62021d768f5cb8"); wlt.addAddress(myAddress);
   myAddress.createFromHex("11b366edfc0a8b66feebae5c2e25a7b6a5d1cf31"); wlt.addAddress(myAddress);

   // This address contains a tx with a non-std TxOut, but the other TxOuts are valid
   myAddress.createFromHex("6c27c8e67b7376f3ab63553fe37a4481c4f951cf"); wlt.addAddress(myAddress);

   // More testnet addresses, with only a few transactions
   myAddress.createFromHex("0c6b92101c7025643c346d9c3e23034a8a843e21"); wlt.addAddress(myAddress);
   myAddress.createFromHex("34c9f8dc91dfe1ae1c59e76cbe1aa39d0b7fc041"); wlt.addAddress(myAddress);
   myAddress.createFromHex("d77561813ca968270d5f63794ddb6aab3493605e"); wlt.addAddress(myAddress);
   myAddress.createFromHex("0e0aec36fe2545fb31a41164fb6954adcd96b342"); wlt.addAddress(myAddress);

   TIMER_WRAP(bdm.scanBlockchainForTx(wlt));
   TIMER_WRAP(bdm.scanBlockchainForTx(wlt));
   TIMER_WRAP(bdm.scanBlockchainForTx(wlt));
   
   cout << "Checking balance of all addresses: " << wlt.getNumAddr() << " addrs" << endl;
   for(uint32_t i=0; i<wlt.getNumAddr(); i++)
   {
      BinaryData addr20 = wlt.getAddrByIndex(i).getAddrStr20();
      cout << "  Addr: " << wlt.getAddrByIndex(i).getFullBalance() << ","
                         << wlt.getAddrByHash160(addr20).getFullBalance() << endl;
      vector<LedgerEntry> const & ledger = wlt.getAddrByIndex(i).getTxLedger();
      for(uint32_t j=0; j<ledger.size(); j++)
      {  
         cout << "    Tx: " 
           << ledger[j].getAddrStr20().getSliceCopy(0,4).toHexStr() << "  "
           << ledger[j].getValue()/(float)(CONVERTBTC) << " (" 
           << ledger[j].getBlockNum()
           << ")  TxHash: " << ledger[j].getTxHash().getSliceCopy(0,4).toHexStr() << endl;
      }

   }
   cout << endl << endl;



   cout << "Printing SORTED allAddr ledger..." << endl;
   wlt.sortLedger();
   vector<LedgerEntry> const & ledgerAll = wlt.getTxLedger();
   for(uint32_t j=0; j<ledgerAll.size(); j++)
   {  
      cout << "    Tx: " 
           << ledgerAll[j].getAddrStr20().toHexStr() << "  "
           << ledgerAll[j].getValue()/1e8 << " (" 
           << ledgerAll[j].getBlockNum()
           << ")  TxHash: " << ledgerAll[j].getTxHash().getSliceCopy(0,4).toHexStr() << endl;
           
   }



   /////////////////////////////////////////////////////////////////////////////
   cout << "Test txout aggregation, with different prioritization schemes" << endl;
   BtcWallet myWallet;

#ifndef TEST_NETWORK
   // TODO:  I somehow borked my list of test addresses.  Make sure I have some
   //        test addresses in here for each network that usually has lots of 
   //        unspent TxOuts
   
   // Main-network addresses
   myAddress.createFromHex("0e0aec36fe2545fb31a41164fb6954adcd96b342"); myWallet.addAddress(myAddress);
#else
   // Testnet addresses
   //myAddress.createFromHex("d184cea7e82c775d08edd288344bcd663c3f99a2"); myWallet.addAddress(myAddress);
   //myAddress.createFromHex("205fa00890e6898b987de6ff8c0912805416cf90"); myWallet.addAddress(myAddress);
   //myAddress.createFromHex("fc0ef58380e6d4bcb9599c5369ce82d0bc01a5c4"); myWallet.addAddress(myAddress);
#endif

   cout << "Rescanning the blockchain for new addresses." << endl;
   bdm.scanBlockchainForTx(myWallet);

   //vector<UnspentTxOut> sortedUTOs = bdm.getUnspentTxOutsForWallet(myWallet, 1);
   vector<UnspentTxOut> sortedUTOs = myWallet.getSpendableTxOutList();

   int i=1;
   cout << "   Sorting Method: " << i << endl;
   cout << "   Value\t#Conf\tTxHash\tTxIdx" << endl;
   for(int j=0; j<sortedUTOs.size(); j++)
   {
      cout << "   "
           << sortedUTOs[j].getValue()/1e8 << "\t"
           << sortedUTOs[j].getNumConfirm() << "\t"
           << sortedUTOs[j].getTxHash().toHexStr() << "\t"
           << sortedUTOs[j].getTxOutIndex() << endl;
   }
   cout << endl;


   // Test the zero-conf ledger-entry detection
   //le.pprint();

   //vector<LedgerEntry> levect = wlt.getAddrLedgerEntriesForTx(txSelf);
   //for(int i=0; i<levect.size(); i++)
   //{
      //levect[i].pprint();
   //}
   

}
コード例 #3
0
void TestReadAndOrganizeChainWithWallet(string blkfile)
{
   cout << endl << "Starting blockchain loading with wallets..." << endl;
   /////////////////////////////////////////////////////////////////////////////
   BlockDataManager_MMAP & bdm = BlockDataManager_MMAP::GetInstance(); 
   BinaryData myAddress;
   BtcWallet wlt1;
   BtcWallet wlt2;
   
   // Main-network addresses
   //myAddress.createFromHex("604875c897a079f4db88e5d71145be2093cae194"); wlt2.addAddress(myAddress);
   //myAddress.createFromHex("8996182392d6f05e732410de4fc3fa273bac7ee6"); wlt2.addAddress(myAddress);
   //myAddress.createFromHex("b5e2331304bc6c541ffe81a66ab664159979125b"); wlt2.addAddress(myAddress);
   //myAddress.createFromHex("ebbfaaeedd97bc30df0d6887fd62021d768f5cb8"); wlt2.addAddress(myAddress);
   myAddress.createFromHex("11b366edfc0a8b66feebae5c2e25a7b6a5d1cf31"); wlt2.addAddress(myAddress);

   // Add some relevant testnet addresses
   myAddress.createFromHex("0c6b92101c7025643c346d9c3e23034a8a843e21"); wlt2.addAddress(myAddress);
   myAddress.createFromHex("34c9f8dc91dfe1ae1c59e76cbe1aa39d0b7fc041"); wlt1.addAddress(myAddress);
   myAddress.createFromHex("d77561813ca968270d5f63794ddb6aab3493605e"); wlt1.addAddress(myAddress);
   myAddress.createFromHex("0e0aec36fe2545fb31a41164fb6954adcd96b342"); wlt1.addAddress(myAddress);

   vector<BtcWallet*> wltList;
   wltList.push_back(&wlt1);
   wltList.push_back(&wlt2);

   bdm.registerWallet(&wlt1);
   bdm.registerWallet(&wlt2);

   /////////////////////////////////////////////////////////////////////////////
   cout << "Reading data from blockchain... (with wallet scan)" << endl;
   TIMER_START("BDM_Load_Scan_Blockchain_With_Wallet");
   bdm.readBlkFile_FromScratch(blkfile);  
   TIMER_STOP("BDM_Load_Scan_Blockchain_With_Wallet");
   cout << endl << endl;

   /////////////////////////////////////////////////////////////////////////////
   cout << endl << "Organizing blockchain: " ;
   TIMER_START("BDM_Organize_Chain");
   bool isGenOnMainChain = bdm.organizeChain();
   TIMER_STOP("BDM_Organize_Chain");
   cout << (isGenOnMainChain ? "No Reorg!" : "Reorg Detected!") << endl;
   cout << endl << endl;

   cout << endl << "Updating wallet (1) based on initial MMAP blockchain scan" << endl;
   TIMER_WRAP(bdm.scanBlockchainForTx(wlt1));
   cout << "Printing Wallet(1) Ledger" << endl;
   wlt1.pprintLedger();

   cout << endl << "Updating wallet (2) based on initial MMAP blockchain scan" << endl;
   TIMER_WRAP(bdm.scanBlockchainForTx(wlt2));
   cout << "Printing Wallet(2) Ledger" << endl;
   wlt2.pprintLedger();


   cout << endl << "Rescanning wlt2 multiple times" << endl;
   TIMER_WRAP(bdm.scanBlockchainForTx(wlt2));
   TIMER_WRAP(bdm.scanBlockchainForTx(wlt2));
   cout << "Printing Wallet(2) Ledger AGAIN" << endl;
   wlt2.pprintLedger();


   cout << endl << "ADD a new address to Wlt(1) requiring a blockchain rescan..." << endl;
   // This address contains a tx with a non-std TxOut, but the other TxOuts are valid
   myAddress.createFromHex("6c27c8e67b7376f3ab63553fe37a4481c4f951cf"); 
   wlt1.addAddress(myAddress);
   bdm.scanBlockchainForTx(wlt1);
   wlt1.pprintLedger();
   
   cout << endl << "ADD new address to wlt(2) but as a just-created addr not requiring rescan" << endl;
   myAddress.createFromHex("6c27c8e67b7376f3ab63553fe37a4481c4f951cf"); 
   wlt2.addNewAddress(myAddress);
   bdm.scanBlockchainForTx(wlt2);
   wlt2.pprintLedger();


   cout << endl << "Create new, unregistered wallet, scan it once (should rescan)..." << endl;
   BtcWallet wlt3;
   myAddress.createFromHex("72e20a94d6b2ed34a3b4d3757c1fed5152071993"); wlt3.addAddress(myAddress);
   wlt3.addAddress(myAddress);
   bdm.scanBlockchainForTx(wlt3);
   wlt3.pprintLedger();

   
   cout << endl << "Rescan unregistered wallet: addr should be registered, so no rescan..." << endl;
   bdm.scanBlockchainForTx(wlt3);
   wlt3.pprintLedger();


   cout << endl << endl;
   cout << "Getting Sent-To Address List for Wlt1:" << endl;
   vector<AddressBookEntry> targAddrVect = wlt1.createAddressBook();
   for(uint32_t i=0; i<targAddrVect.size(); i++)
   {
      vector<RegisteredTx> txList = targAddrVect[i].getTxList();

      cout << targAddrVect[i].getAddr160().toHexStr() << " " 
           << txList.size() << endl;
      
      for(uint32_t j=0; j<txList.size(); j++)
         cout << "   " << txList[j].txHash_.toHexStr()
              << "   " << txList[j].blkNum_
              << "   " << txList[j].txIndex_ << endl;
   }


   // Results for the sent-to address list, as of 09 Apr, 2012
   /*
   "13Tn1QkAcqnQvGA7kBiCBH7NbijNcr6GMs"
   "17ZqBkFgR6TWawd8rRKbyJAnpTWDWtok72"
   "12irKW1XFSnnu6v5FevcC3wZ6hfvPmaEDQ"
   "12Tg96ZPSYc3P2g5c9c4znFFH2whriN9NQ"
   "1PymCiNzubeTtJt47dqFdi31Zy9MAM1YZk"
   "1H3Jbv99F7Ng8oiadCovvda17CGZ9EFkPM"
   "16jN5NhB4eoUqFrSvuNnvDEc57oz6GRNi4"
   "17aLXn2XHKH7nhwdCPaWmkY6jgr36zSjyz"
   "1PjURhoxGr6cdK5YY5SyDDY2pQhEpbZdoK"
   "1NgBFTvqM6FsooFtkvFgf7VxzRBdXKnxpR"
   "176msrhhemi6q8DEdpBCoTQJvRCiGV5qEm"
   "16FSHWWyUv6wzT9qpbi7tCaovf6XX7T9xN"
   "1JiLbGTrVNmk6BsePVQWmBiD7DFUDmMYXw"
   "124DJWV7vYS8DUcVan4SXcGNAubopS1BHj"
   "1PESigPSLwsvaQAQfCDDPZM21i9m8Vqt21"
   "18i1rVZHMMXQwRxZuSrHZrpqUoejkV2Gh2"
   "1PZjRprkrM93GVXNdJ5zu7C1p84weTovWj"
   "14cKqt9e8QvgMaBrwbuykBjha1vXNtaj72"
   "1QJUzen8xL7EyBTGnkDUX6fnoMX9TL1fU7"
   "17iRBkToUTzDvVpXsNUT8usT6c6aEDe15R"
   "1NVJS8DWLdrte45rc5oGvWyjrAe9y1rtFt"
   "1MzxEf2Ck9XSC7U5y5DHQvMyPhL2UNcjSD"
   "1F7G4aq9fbAhqGb9jcnsVn6CRm6dqJf3sD"
   "15dYCgedoR1s4y1t5iiKNrRbgHNDize8VW"
   "15XopyBFQetJzyhE5BbM6WiuYDPeKPNfVP"
   "1SAD1wfvNCxz23WjEyQMG6fjKsiQx7FFK"
   "1TaintGh3cPFVGX9REbRk8FXSKTb1pcFZ"
   "1SAD2i96iGVQvsfhdhEhpi5GeFQpuP4Ye"
   "1SAD5qJu5UhhXdAZbW7zpjso4ay364W3B"
   "1SAD7gSBTkhMz5Qaf92SFjUdAsZiE6fq3"
   "13Sgmy78mfw7ToMiKQujyad9spmPGUZvCN"
   "1M7bd7iYNuJoFw8F7fGXvz2Fe9cGnhA3P6"
   */

   /* Here's the hash160 version of the above list
   "1b00a2f6899335366f04b277e19d777559c35bc8"
   "480649dc5fd4448f8c4bf75b3c84bb98ec40b45a"
   "12e259809932ee8fdab278946911dbd6c6e9e977"
   "10039ce4fdb5d4ee56148fe3935b9bfbbe4ecc89"
   "fc0ef58380e6d4bcb9599c5369ce82d0bc01a5c4"
   "aff189b24a36a1b93de2ea4d157c13d18251270a"
   "3edbb132f2cd894bc45fee76cfbf13d79fa87bbb"
   "481ec8e7d30c484ea664824fb7f52b5ae0a99d1d"
   "f95b21b39dbd7cfe9dd5ef81fe19777707b57f00"
   "edc36b7309fe440fea79e59c3b50d3969e7fa97d"
   "42e84bba78b26c2a8917f5cb48493316c3766f88"
   "39938f166521cbbef621f7c016308fbb428fd9e0"
   "c24b8bdcba3cb15a7fe95aa99b7ab6ceba5a4c2c"
   "0b93a48b5ebf29c0e6c7ce53d6701cb4495fc623"
   "f3dda4c01f89186a012c68607899a5cfd172e408"
   "548aa5b107b7a5d787c3b21db4fa07ec1cd7b1ec"
   "f7837ec1fccdbcb1c9848c271468aa9ddf12bf7a"
   "2796aa497bf2e3d8989319ceff88d1f30300ae36"
   "ff9955241d540b35fcd429b04e4f59fcfa34580d"
   "49a5ff7f45c3e2c256adf0615f45f2bbba7a33d3"
   "ebb4d74391893c08716988c5b9f684275be5966b"
   "e658556ebd5104f49ea88c27212e8fba71f38e3d"
   "9ac0d4663bae84fbccfb3f3d887551c075283d7b"
   "32c985fe4602556cef24b9fd1a35459a0d39e806"
   "31b4123c92a4aed2d7cfd08edced603dedefcfb7"
   "04c215b608229b1e71f6314d6973d235fe448c2e"
   "0506f6a7742b6b4c554ada6c780f7242c85bfdc2"
   "04c215c2800a1fb2a50f79865bd87a51ae9505c5"
   "04c215f54c237440e91ebc0e7ed01ecec18d09c0"
   "04c21613557ce112d0b95a37e08fabf3f8ec96b2"
   "1acbda75c997d00e2cef09389750708e75433357"
   "dca1e9baf8d970229f5efa269a15dd420ea7cfab"
   */

   cout << "Testing soft-scanning..." << endl;

   BinaryData txHash1 = BinaryData::CreateFromHex("2ec3a745e032c8bcc1061ebf270afcee47318a43462ba57215174084775c794d");
   BinaryData txHash2 = BinaryData::CreateFromHex("b754fa89f7eb7f7c564611d9297dbcb471cf8d3cb0d235686323b6a5b263b094");

   LedgerEntry le;
   le = wlt1.calcLedgerEntryForTx( *bdm.getTxByHash(txHash1) ); le.pprintOneLine(); cout << endl;
   le = wlt2.calcLedgerEntryForTx( *bdm.getTxByHash(txHash1) ); le.pprintOneLine(); cout << endl;
   le = wlt1.calcLedgerEntryForTx( *bdm.getTxByHash(txHash2) ); le.pprintOneLine(); cout << endl;
   le = wlt2.calcLedgerEntryForTx( *bdm.getTxByHash(txHash2) ); le.pprintOneLine(); cout << endl;
  
}
コード例 #4
0
void TestScanForWalletTx(string blkfile)
{
   BlockDataManager_FullRAM & bdm = BlockDataManager_FullRAM::GetInstance(); 
   bdm.readBlkFile_FromScratch(blkfile, false);  // don't organize, just index
   /////////////////////////////////////////////////////////////////////////////
   BinaryData myAddress;
   BtcWallet wlt;
   
#ifndef TEST_NETWORK
   // Main-network addresses
   myAddress.createFromHex("604875c897a079f4db88e5d71145be2093cae194"); wlt.addAddress(myAddress);
   myAddress.createFromHex("8996182392d6f05e732410de4fc3fa273bac7ee6"); wlt.addAddress(myAddress);
   myAddress.createFromHex("b5e2331304bc6c541ffe81a66ab664159979125b"); wlt.addAddress(myAddress);
   myAddress.createFromHex("ebbfaaeedd97bc30df0d6887fd62021d768f5cb8"); wlt.addAddress(myAddress);
#else
   // Test-network addresses
   myAddress.createFromHex("abda0c878dd7b4197daa9622d96704a606d2cd14"); wlt.addAddress(myAddress);
   myAddress.createFromHex("11b366edfc0a8b66feebae5c2e25a7b6a5d1cf31"); wlt.addAddress(myAddress);
   myAddress.createFromHex("baa72d8650baec634cdc439c1b84a982b2e596b2"); wlt.addAddress(myAddress);
   myAddress.createFromHex("fc0ef58380e6d4bcb9599c5369ce82d0bc01a5c4"); wlt.addAddress(myAddress);
#endif

   myAddress.createFromHex("0e0aec36fe2545fb31a41164fb6954adcd96b342"); wlt.addAddress(myAddress);

   TIMER_WRAP(bdm.scanBlockchainForTx_FromScratch(wlt));
   
   cout << "Checking balance of all addresses: " << wlt.getNumAddr() << " addrs" << endl;
   for(uint32_t i=0; i<wlt.getNumAddr(); i++)
   {
      BinaryData addr20 = wlt.getAddrByIndex(i).getAddrStr20();
      cout << "  Addr: " << wlt.getAddrByIndex(i).getBalance() << ","
                         << wlt.getAddrByHash160(addr20).getBalance() << endl;
      vector<LedgerEntry> const & ledger = wlt.getAddrByIndex(i).getTxLedger();
      for(uint32_t j=0; j<ledger.size(); j++)
      {  
         cout << "    Tx: " 
           << ledger[j].getAddrStr20().getSliceCopy(0,4).toHexStr() << "  "
           << ledger[j].getValue()/(float)(CONVERTBTC) << " (" 
           << ledger[j].getBlockNum()
           << ")  TxHash: " << ledger[j].getTxHash().getSliceCopy(0,4).toHexStr() << endl;
      }

   }
   cout << endl << endl;



   cout << "Printing SORTED allAddr ledger..." << endl;
   wlt.sortLedger();
   vector<LedgerEntry> const & ledgerAll = wlt.getTxLedger();
   for(uint32_t j=0; j<ledgerAll.size(); j++)
   {  
      cout << "    Tx: " 
           << ledgerAll[j].getAddrStr20().toHexStr() << "  "
           << ledgerAll[j].getValue()/1e8 << " (" 
           << ledgerAll[j].getBlockNum()
           << ")  TxHash: " << ledgerAll[j].getTxHash().getSliceCopy(0,4).toHexStr() << endl;
           
   }


   /////////////////////////////////////////////////////////////////////////////
   cout << "Test txout aggregation, with different prioritization schemes" << endl;
   BtcWallet myWallet;

#ifndef TEST_NETWORK
   // TODO:  I somehow borked my list of test addresses.  Make sure I have some
   //        test addresses in here for each network that usually has lots of 
   //        unspent TxOuts
   
   // Main-network addresses
   myAddress.createFromHex("0e0aec36fe2545fb31a41164fb6954adcd96b342"); myWallet.addAddress(myAddress);
#else
   // Testnet addresses
   //myAddress.createFromHex("d184cea7e82c775d08edd288344bcd663c3f99a2"); myWallet.addAddress(myAddress);
   //myAddress.createFromHex("205fa00890e6898b987de6ff8c0912805416cf90"); myWallet.addAddress(myAddress);
   //myAddress.createFromHex("fc0ef58380e6d4bcb9599c5369ce82d0bc01a5c4"); myWallet.addAddress(myAddress);
#endif

   cout << "Rescanning the blockchain for new addresses." << endl;
   bdm.scanBlockchainForTx_FromScratch(myWallet);

   vector<UnspentTxOut> sortedUTOs = bdm.getUnspentTxOutsForWallet(myWallet, 1);

   int i=1;
   cout << "   Sorting Method: " << i << endl;
   cout << "   Value\t#Conf\tTxHash\tTxIdx" << endl;
   for(int j=0; j<sortedUTOs.size(); j++)
   {
      cout << "   "
           << sortedUTOs[j].getValue()/1e8 << "\t"
           << sortedUTOs[j].getNumConfirm() << "\t"
           << sortedUTOs[j].getTxHash().toHexStr() << "\t"
           << sortedUTOs[j].getTxOutIndex() << endl;
   }
   cout << endl;
}