Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/wallet.cpp
Show First 20 Lines • Show All 2,839 Lines • ▼ Show 20 Lines | |||||
bool CWallet::CreateTransaction(interfaces::Chain::Lock &locked_chainIn, | bool CWallet::CreateTransaction(interfaces::Chain::Lock &locked_chainIn, | ||||
const std::vector<CRecipient> &vecSend, | const std::vector<CRecipient> &vecSend, | ||||
CTransactionRef &tx, Amount &nFeeRet, | CTransactionRef &tx, Amount &nFeeRet, | ||||
int &nChangePosInOut, | int &nChangePosInOut, | ||||
std::string &strFailReason, | std::string &strFailReason, | ||||
const CCoinControl &coinControl, bool sign) { | const CCoinControl &coinControl, bool sign) { | ||||
Amount nValue = Amount::zero(); | Amount nValue = Amount::zero(); | ||||
ReserveDestination reservedest(this); | const OutputType change_type = TransactionChangeType( | ||||
coinControl.m_change_type ? *coinControl.m_change_type | |||||
: m_default_change_type, | |||||
vecSend); | |||||
ReserveDestination reservedest(this, change_type); | |||||
int nChangePosRequest = nChangePosInOut; | int nChangePosRequest = nChangePosInOut; | ||||
unsigned int nSubtractFeeFromAmount = 0; | unsigned int nSubtractFeeFromAmount = 0; | ||||
for (const auto &recipient : vecSend) { | for (const auto &recipient : vecSend) { | ||||
if (nValue < Amount::zero() || recipient.nAmount < Amount::zero()) { | if (nValue < Amount::zero() || recipient.nAmount < Amount::zero()) { | ||||
strFailReason = | strFailReason = | ||||
_("Transaction amounts must not be negative").translated; | _("Transaction amounts must not be negative").translated; | ||||
return false; | return false; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 49 Lines • ▼ Show 20 Lines | txNew.nLockTime = GetLocktimeForNewTransaction(chain(), locked_chainIn); | ||||
if (!CanGetAddresses(true)) { | if (!CanGetAddresses(true)) { | ||||
strFailReason = | strFailReason = | ||||
_("Can't generate a change-address key. No keys in the " | _("Can't generate a change-address key. No keys in the " | ||||
"internal keypool and can't generate any keys.") | "internal keypool and can't generate any keys.") | ||||
.translated; | .translated; | ||||
return false; | return false; | ||||
} | } | ||||
CTxDestination dest; | CTxDestination dest; | ||||
const OutputType change_type = TransactionChangeType( | bool ret = reservedest.GetReservedDestination(dest, true); | ||||
coinControl.m_change_type ? *coinControl.m_change_type | |||||
: m_default_change_type, | |||||
vecSend); | |||||
bool ret = | |||||
reservedest.GetReservedDestination(change_type, dest, true); | |||||
if (!ret) { | if (!ret) { | ||||
strFailReason = | strFailReason = | ||||
_("Keypool ran out, please call keypoolrefill first") | _("Keypool ran out, please call keypoolrefill first") | ||||
.translated; | .translated; | ||||
return false; | return false; | ||||
} | } | ||||
scriptChange = GetScriptForDestination(dest); | scriptChange = GetScriptForDestination(dest); | ||||
▲ Show 20 Lines • Show All 534 Lines • ▼ Show 20 Lines | |||||
bool CWallet::GetNewChangeDestination(const OutputType type, | bool CWallet::GetNewChangeDestination(const OutputType type, | ||||
CTxDestination &dest, | CTxDestination &dest, | ||||
std::string &error) { | std::string &error) { | ||||
error.clear(); | error.clear(); | ||||
m_spk_man->TopUp(); | m_spk_man->TopUp(); | ||||
ReserveDestination reservedest(this); | ReserveDestination reservedest(this, type); | ||||
if (!reservedest.GetReservedDestination(type, dest, true)) { | if (!reservedest.GetReservedDestination(dest, true)) { | ||||
error = "Error: Keypool ran out, please call keypoolrefill first"; | error = "Error: Keypool ran out, please call keypoolrefill first"; | ||||
return false; | return false; | ||||
} | } | ||||
reservedest.KeepDestination(); | reservedest.KeepDestination(); | ||||
return true; | return true; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 165 Lines • ▼ Show 20 Lines | for (const std::pair<const CTxDestination, CAddressBookData> &item : | ||||
if (strName == label) { | if (strName == label) { | ||||
result.insert(address); | result.insert(address); | ||||
} | } | ||||
} | } | ||||
return result; | return result; | ||||
} | } | ||||
bool ReserveDestination::GetReservedDestination(const OutputType type, | bool ReserveDestination::GetReservedDestination(CTxDestination &dest, | ||||
CTxDestination &dest, | |||||
bool internal) { | bool internal) { | ||||
m_spk_man = pwallet->GetLegacyScriptPubKeyMan(); | m_spk_man = pwallet->GetLegacyScriptPubKeyMan(); | ||||
if (!m_spk_man) { | if (!m_spk_man) { | ||||
return false; | return false; | ||||
} | } | ||||
if (!pwallet->CanGetAddresses(internal)) { | if (!pwallet->CanGetAddresses(internal)) { | ||||
return false; | return false; | ||||
▲ Show 20 Lines • Show All 862 Lines • Show Last 20 Lines |