|
|
@ -457,17 +457,19 @@ bool CWallet::AddToWallet(const CWalletTx& wtxIn) |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
#ifndef QT_GUI |
|
|
|
#ifndef QT_GUI |
|
|
|
// If default receiving address gets used, replace it with a new one
|
|
|
|
// If default receiving address gets used, replace it with a new one
|
|
|
|
CScript scriptDefaultKey; |
|
|
|
if (vchDefaultKey.IsValid()) { |
|
|
|
scriptDefaultKey.SetDestination(vchDefaultKey.GetID()); |
|
|
|
CScript scriptDefaultKey; |
|
|
|
BOOST_FOREACH(const CTxOut& txout, wtx.vout) |
|
|
|
scriptDefaultKey.SetDestination(vchDefaultKey.GetID()); |
|
|
|
{ |
|
|
|
BOOST_FOREACH(const CTxOut& txout, wtx.vout) |
|
|
|
if (txout.scriptPubKey == scriptDefaultKey) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
CPubKey newDefaultKey; |
|
|
|
if (txout.scriptPubKey == scriptDefaultKey) |
|
|
|
if (GetKeyFromPool(newDefaultKey, false)) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
SetDefaultKey(newDefaultKey); |
|
|
|
CPubKey newDefaultKey; |
|
|
|
SetAddressBookName(vchDefaultKey.GetID(), ""); |
|
|
|
if (GetKeyFromPool(newDefaultKey, false)) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
SetDefaultKey(newDefaultKey); |
|
|
|
|
|
|
|
SetAddressBookName(vchDefaultKey.GetID(), ""); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -1199,8 +1201,8 @@ bool CWallet::CreateTransaction(const vector<pair<CScript, int64> >& vecSend, CW |
|
|
|
// post-backup change.
|
|
|
|
// post-backup change.
|
|
|
|
|
|
|
|
|
|
|
|
// Reserve a new key pair from key pool
|
|
|
|
// Reserve a new key pair from key pool
|
|
|
|
CPubKey vchPubKey = reservekey.GetReservedKey(); |
|
|
|
CPubKey vchPubKey; |
|
|
|
// assert(mapKeys.count(vchPubKey));
|
|
|
|
assert(reservekey.GetReservedKey(vchPubKey)); // should never fail, as we just unlocked
|
|
|
|
|
|
|
|
|
|
|
|
// Fill a vout to ourself
|
|
|
|
// Fill a vout to ourself
|
|
|
|
// TODO: pass in scriptChange instead of reservekey so
|
|
|
|
// TODO: pass in scriptChange instead of reservekey so
|
|
|
@ -1737,7 +1739,7 @@ set< set<CTxDestination> > CWallet::GetAddressGroupings() |
|
|
|
return ret; |
|
|
|
return ret; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
CPubKey CReserveKey::GetReservedKey() |
|
|
|
bool CReserveKey::GetReservedKey(CPubKey& pubkey) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (nIndex == -1) |
|
|
|
if (nIndex == -1) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -1745,14 +1747,17 @@ CPubKey CReserveKey::GetReservedKey() |
|
|
|
pwallet->ReserveKeyFromKeyPool(nIndex, keypool); |
|
|
|
pwallet->ReserveKeyFromKeyPool(nIndex, keypool); |
|
|
|
if (nIndex != -1) |
|
|
|
if (nIndex != -1) |
|
|
|
vchPubKey = keypool.vchPubKey; |
|
|
|
vchPubKey = keypool.vchPubKey; |
|
|
|
else |
|
|
|
else { |
|
|
|
{ |
|
|
|
if (pwallet->vchDefaultKey.IsValid()) { |
|
|
|
printf("CReserveKey::GetReservedKey(): Warning: Using default key instead of a new key, top up your keypool!"); |
|
|
|
printf("CReserveKey::GetReservedKey(): Warning: Using default key instead of a new key, top up your keypool!"); |
|
|
|
vchPubKey = pwallet->vchDefaultKey; |
|
|
|
vchPubKey = pwallet->vchDefaultKey; |
|
|
|
|
|
|
|
} else |
|
|
|
|
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
assert(vchPubKey.IsValid()); |
|
|
|
assert(vchPubKey.IsValid()); |
|
|
|
return vchPubKey; |
|
|
|
pubkey = vchPubKey; |
|
|
|
|
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void CReserveKey::KeepKey() |
|
|
|
void CReserveKey::KeepKey() |
|
|
|