- BDC4FC472BE4A86FB91FA69368FAACE04414FDEEE5B8C82795E31D37E21581B973CAF7F3E9CCC27D487944A5782E3B59615180EAB87C8B3E81242901F3039E4D
+ 1BBB78C44552BFB47B91BD1F5C9DE6AEA2021E1EF54BE00AE6C57294747AC8ED888B2210909E804F4CA92DA41BBA35589123CDC09759FEF2B96711A0985FD47B
bitcoin/src/wallet.cpp
(92 . 7)(92 . 7)
2060 if (pMasterKey.second.nDeriveIterations < 25000)
2061 pMasterKey.second.nDeriveIterations = 25000;
2062
2063 printf("Wallet passphrase changed to an nDeriveIterations of %i\n", pMasterKey.second.nDeriveIterations);
2064 printf(SINF SWAL "passphrase changed through %i deriving iterations\n", pMasterKey.second.nDeriveIterations);
2065
2066 if (!crypter.SetKeyFromPassphrase(strNewWalletPassphrase, pMasterKey.second.vchSalt, pMasterKey.second.nDeriveIterations, pMasterKey.second.nDerivationMethod))
2067 return false;
(151 . 7)(151 . 7)
2069 if (kMasterKey.nDeriveIterations < 25000)
2070 kMasterKey.nDeriveIterations = 25000;
2071
2072 printf("Encrypting Wallet with an nDeriveIterations of %i\n", kMasterKey.nDeriveIterations);
2073 printf(SINF SWAL "encrypting using %i deriving iterations\n", kMasterKey.nDeriveIterations);
2074
2075 if (!crypter.SetKeyFromPassphrase(strWalletPassphrase, kMasterKey.vchSalt, kMasterKey.nDeriveIterations, kMasterKey.nDerivationMethod))
2076 return false;
(214 . 7)(214 . 7)
2078 CWalletTx& wtx = (*mi).second;
2079 if (!wtx.IsSpent(txin.prevout.n) && IsMine(wtx.vout[txin.prevout.n]))
2080 {
2081 printf("WalletUpdateSpent found spent coin %sbc %s\n", FormatMoney(wtx.GetCredit()).c_str(), wtx.GetHash().ToString().c_str());
2082 printf(SWAR SWAL "found spent %s bitcoin on tx %s\n", FormatMoney(wtx.GetCredit()).c_str(), wtx.GetHash().ToString().c_str());
2083 wtx.MarkSpent(txin.prevout.n);
2084 wtx.WriteToDisk();
2085 vWalletUpdated.push_back(txin.prevout.hash);
(261 . 7)(261 . 7)
2087 }
2088
2089 //// debug print
2090 printf("AddToWallet %s %s%s\n", wtxIn.GetHash().ToString().substr(0,10).c_str(), (fInsertedNew ? "new" : ""), (fUpdated ? "update" : ""));
2091 printf(SINF SWAL "adding input from tx %s. (%s)\n", wtxIn.GetHash().ToString().c_str(), (fInsertedNew ? "new, " : (fUpdated ? "update" : "")));
2092
2093 // Write to disk
2094 if (fInsertedNew || fUpdated)
(440 . 7)(440 . 7)
2096 vector<unsigned char> vchPubKey;
2097 if (!ExtractAddress(txout.scriptPubKey, NULL, address))
2098 {
2099 printf("CWalletTx::GetAmounts: Unknown transaction type found, txid %s\n",
2100 printf(SWAR SWAL "unknown transaction type found, tx %s\n",
2101 this->GetHash().ToString().c_str());
2102 address = " unknown ";
2103 }
(537 . 7)(537 . 7)
2105 }
2106 else
2107 {
2108 printf("ERROR: AddSupportingTransactions() : unsupported transaction\n");
2109 printf(SERR SWAL "unsupported tx\n");
2110 continue;
2111 }
2112
(605 . 7)(605 . 7)
2114 // Update fSpent if a tx got spent somewhere else by a copy of wallet.dat
2115 if (txindex.vSpent.size() != wtx.vout.size())
2116 {
2117 printf("ERROR: ReacceptWalletTransactions() : txindex.vSpent.size() %d != wtx.vout.size() %d\n", txindex.vSpent.size(), wtx.vout.size());
2118 printf(SERR SWAL "tx index spent count differs from output index length\n");
2119 continue;
2120 }
2121 for (int i = 0; i < txindex.vSpent.size(); i++)
(621 . 7)(621 . 8)
2123 }
2124 if (fUpdated)
2125 {
2126 printf("ReacceptWalletTransactions found spent coin %sbc %s\n", FormatMoney(wtx.GetCredit()).c_str(), wtx.GetHash().ToString().c_str());
2127 printf(SERR SWAL "found spent %s bitcoin on tx %s\n",
2128 FormatMoney(wtx.GetCredit()).c_str(), wtx.GetHash().ToString().c_str());
2129 wtx.MarkDirty();
2130 wtx.WriteToDisk();
2131 }
(658 . 7)(659 . 7)
2133 uint256 hash = GetHash();
2134 if (!txdb.ContainsTx(hash))
2135 {
2136 printf("Relaying wtx %s\n", hash.ToString().substr(0,10).c_str());
2137 printf(SINF SWAL "relaying wallet tx %s\n", hash.ToString().c_str());
2138 RelayMessage(CInv(MSG_TX, hash), (CTransaction)*this);
2139 }
2140 }
(689 . 7)(690 . 7)
2142 nLastTime = GetTime();
2143
2144 // Rebroadcast any of our txes that aren't in a block yet
2145 printf("ResendWalletTransactions()\n");
2146 printf(SWAR SWAL "resending wallet txs\n");
2147 CTxDB txdb("r");
2148 CRITICAL_BLOCK(cs_wallet)
2149 {
(890 . 11)(891 . 11)
2151 }
2152
2153 //// debug print
2154 printf("SelectCoins() best subset: ");
2155 std::string str;
2156 for (int i = 0; i < vValue.size(); i++)
2157 if (vfBest[i])
2158 printf("%s ", FormatMoney(vValue[i].first).c_str());
2159 printf("total %s\n", FormatMoney(nBest).c_str());
2160 str += FormatMoney(vValue[i].first) + (i == vValue.size() - 1 ? "" : " ");
2161 printf(SINF SWAL "selecting best output subset: %s\n", str.c_str());
2162 }
2163
2164 return true;
(1041 . 7)(1042 . 7)
2166 CRITICAL_BLOCK(cs_main)
2167 CRITICAL_BLOCK(cs_wallet)
2168 {
2169 printf("CommitTransaction:\n%s", wtxNew.ToString().c_str());
2170 printf(SINF SWAL "commit tx %s\n", wtxNew.ToString().c_str());
2171 {
2172 // This is only to keep the database open to defeat the auto-flush for the
2173 // duration of this scope. This is the only place where this optimization
(1077 . 7)(1078 . 7)
2175 if (!wtxNew.AcceptToMemoryPool())
2176 {
2177 // This must not fail. The transaction has already been signed and recorded.
2178 printf("CommitTransaction() : Error: Transaction not valid");
2179 printf(SERR SWAL "tx found non-valid while commiting");
2180 return false;
2181 }
2182 wtxNew.RelayWalletTransaction();
(1097 . 17)(1098 . 19)
2184 if (IsLocked())
2185 {
2186 string strError = _("Error: Wallet locked, unable to create transaction ");
2187 printf("SendMoney() : %s", strError.c_str());
2188 printf(SERR SWAL "send money failed with error %s\n", strError.c_str());
2189 return strError;
2190 }
2191 if (!CreateTransaction(scriptPubKey, nValue, wtxNew, reservekey, nFeeRequired))
2192 {
2193 string strError;
2194 if (nValue + nFeeRequired > GetBalance())
2195 strError = strprintf(_("Error: This transaction requires a transaction fee of at least %s because of its amount, complexity, or use of recently received funds "), FormatMoney(nFeeRequired).c_str());
2196 strError += strprintf("tx requires a tx fee of at"
2197 " least %s because of its amount, complexity, or use of recently"
2198 " received funds", FormatMoney(nFeeRequired).c_str());
2199 else
2200 strError = _("Error: Transaction creation failed ");
2201 printf("SendMoney() : %s", strError.c_str());
2202 strError += strprintf("tx creation failed");
2203 printf(SERR SWAL "send money failed with error: %s", strError.c_str());
2204 return strError;
2205 }
2206
(1205 . 10)(1208 . 10)
2208 if (mapWallet.count(block.vtx[0].GetHash()))
2209 {
2210 CWalletTx& wtx = mapWallet[block.vtx[0].GetHash()];
2211 printf(" mine: %d %d %d", wtx.GetDepthInMainChain(), wtx.GetBlocksToMaturity(), wtx.GetCredit());
2212 printf(SINF SWAL "depth is %d, blocks to maturity is %d and credit is %d\n",
2213 wtx.GetDepthInMainChain(), wtx.GetBlocksToMaturity(), wtx.GetCredit());
2214 }
2215 }
2216 printf("\n");
2217 }
2218
2219 bool CWallet::GetTransaction(const uint256 &hashTx, CWalletTx& wtx)
(1267 . 7)(1270 . 7)
2221 walletdb.WritePool(nIndex, CKeyPool(GenerateNewKey()));
2222 setKeyPool.insert(nIndex);
2223 }
2224 printf("CWallet::NewKeyPool wrote %"PRI64d" new keys\n", nKeys);
2225 printf(SINF SWAL "%"PRI64d" new keys written\n", nKeys);
2226 }
2227 return true;
2228 }
(1291 . 7)(1294 . 7)
2230 if (!walletdb.WritePool(nEnd, CKeyPool(GenerateNewKey())))
2231 throw runtime_error("TopUpKeyPool() : writing generated key failed");
2232 setKeyPool.insert(nEnd);
2233 printf("keypool added key %"PRI64d", size=%d\n", nEnd, setKeyPool.size());
2234 printf(SINF SWAL "added key %"PRI64d", current size is %d\n", nEnd, setKeyPool.size());
2235 }
2236 }
2237 return true;
(1319 . 7)(1322 . 7)
2239 if (!HaveKey(Hash160(keypool.vchPubKey)))
2240 throw runtime_error("ReserveKeyFromKeyPool() : unknown key in key pool");
2241 assert(!keypool.vchPubKey.empty());
2242 printf("keypool reserve %"PRI64d"\n", nIndex);
2243 printf(SINF SWAL "keypool reserve %"PRI64d"\n", nIndex);
2244 }
2245 }
2246
(1331 . 7)(1334 . 7)
2248 CWalletDB walletdb(strWalletFile);
2249 walletdb.ErasePool(nIndex);
2250 }
2251 printf("keypool keep %"PRI64d"\n", nIndex);
2252 printf(SINF SWAL "keypool keep %"PRI64d"\n", nIndex);
2253 }
2254
2255 void CWallet::ReturnKey(int64 nIndex)
(1339 . 7)(1342 . 7)
2257 // Return to key pool
2258 CRITICAL_BLOCK(cs_wallet)
2259 setKeyPool.insert(nIndex);
2260 printf("keypool return %"PRI64d"\n", nIndex);
2261 printf(SINF SWAL "keypool return %"PRI64d"\n", nIndex);
2262 }
2263
2264 bool CWallet::GetKeyFromPool(vector<unsigned char>& result, bool fAllowReuse)
(1387 . 7)(1390 . 7)
2266 vchPubKey = keypool.vchPubKey;
2267 else
2268 {
2269 printf("CReserveKey::GetReservedKey(): Warning: using default key instead of a new key, top up your keypool.");
2270 printf(SWAR SWAL "using default key instead of a new key, top up your keypool\n");
2271 vchPubKey = pwallet->vchDefaultKey;
2272 }
2273 }