return CWalletDB(strWalletFile).WriteCScript(Hash160(redeemScript), redeemScript);
}
+bool CWallet::LoadCScript(const CScript& redeemScript)
+{
+ /* A sanity check was added in commit 5ed0a2b to avoid adding redeemScripts
+ * that never can be redeemed. However, old wallets may still contain
+ * these. Do not add them to the wallet and warn. */
+ if (redeemScript.size() > MAX_SCRIPT_ELEMENT_SIZE)
+ {
+ std::string strAddr = CBitcoinAddress(redeemScript.GetID()).ToString();
+ printf("LoadCScript() : Warning: This wallet contains a redeemScript of size %" PRIszu " which exceeds maximum size %i thus can never be redeemed. Do not use address %s.\n",
+ redeemScript.size(), MAX_SCRIPT_ELEMENT_SIZE, strAddr.c_str());
+ return true;
+ }
+
+ return CCryptoKeyStore::AddCScript(redeemScript);
+}
+
+
bool CWallet::AddWatchOnly(const CScript &dest)
{
if (!CCryptoKeyStore::AddWatchOnly(dest))
}
int64_t nChange = nValueIn - nValue - nFeeRet;
- // if sub-cent change is required, the fee must be raised to at least MIN_TX_FEE
- // or until nChange becomes zero
- // NOTE: this depends on the exact behaviour of GetMinFee
- if (wtxNew.nTime < FEE_SWITCH_TIME && !fTestNet)
- {
- if (nFeeRet < MIN_TX_FEE && nChange > 0 && nChange < CENT)
- {
- int64_t nMoveToFee = min(nChange, MIN_TX_FEE - nFeeRet);
- nChange -= nMoveToFee;
- nFeeRet += nMoveToFee;
- }
-
- // sub-cent change is moved to fee
- if (nChange > 0 && nChange < CENT)
- {
- nFeeRet += nChange;
- nChange = 0;
- }
- }
-
if (nChange > 0)
{
// Fill a vout to ourself
dPriority /= nBytes;
// Check that enough fee is included
- int64_t nPayFee = nTransactionFee * (1 + (int64_t)nBytes / 1000);
bool fAllowFree = CTransaction::AllowFree(dPriority);
-
- // Disable free transactions until 1 July 2014
- if (!fTestNet && wtxNew.nTime < FEE_SWITCH_TIME)
- {
- fAllowFree = false;
- }
-
+ int64_t nPayFee = nTransactionFee * (1 + (int64_t)nBytes / 1000);
int64_t nMinFee = wtxNew.GetMinFee(1, fAllowFree, GMF_SEND, nBytes);
if (nFeeRet < max(nPayFee, nMinFee))
continue;
// Add meta record
- // txid => ((txindex, (tx, vout.n)), (block, modifier))
+ // (txid, vout.n) => ((txindex, (tx, vout.n)), (block, modifier))
mapMeta[make_pair(pcoin->first->GetHash(), pcoin->second)] = make_pair(make_pair(txindex, *pcoin), make_pair(block, nStakeModifier));
if (fDebug)