Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/wallet.cpp
Show First 20 Lines • Show All 1,495 Lines • ▼ Show 20 Lines | |||||
// Helper for producing a max-sized low-S low-R signature (eg 71 bytes) | // Helper for producing a max-sized low-S low-R signature (eg 71 bytes) | ||||
// or a max-sized low-S signature (e.g. 72 bytes) if use_max_sig is true | // or a max-sized low-S signature (e.g. 72 bytes) if use_max_sig is true | ||||
bool CWallet::DummySignInput(CTxIn &tx_in, const CTxOut &txout, | bool CWallet::DummySignInput(CTxIn &tx_in, const CTxOut &txout, | ||||
bool use_max_sig) const { | bool use_max_sig) const { | ||||
// Fill in dummy signatures for fee calculation. | // Fill in dummy signatures for fee calculation. | ||||
const CScript &scriptPubKey = txout.scriptPubKey; | const CScript &scriptPubKey = txout.scriptPubKey; | ||||
SignatureData sigdata; | SignatureData sigdata; | ||||
const SigningProvider *provider = GetSigningProvider(scriptPubKey); | std::unique_ptr<SigningProvider> provider = | ||||
GetSigningProvider(scriptPubKey); | |||||
if (!provider) { | if (!provider) { | ||||
// We don't know about this scriptpbuKey; | // We don't know about this scriptpbuKey; | ||||
return false; | return false; | ||||
} | } | ||||
if (!ProduceSignature(*provider, | if (!ProduceSignature(*provider, | ||||
use_max_sig ? DUMMY_MAXIMUM_SIGNATURE_CREATOR | use_max_sig ? DUMMY_MAXIMUM_SIGNATURE_CREATOR | ||||
: DUMMY_SIGNATURE_CREATOR, | : DUMMY_SIGNATURE_CREATOR, | ||||
▲ Show 20 Lines • Show All 882 Lines • ▼ Show 20 Lines | for (const auto &entry : mapWallet) { | ||||
if (mine == ISMINE_NO) { | if (mine == ISMINE_NO) { | ||||
continue; | continue; | ||||
} | } | ||||
if (!allow_used_addresses && IsUsedDestination(wtxid, i)) { | if (!allow_used_addresses && IsUsedDestination(wtxid, i)) { | ||||
continue; | continue; | ||||
} | } | ||||
const SigningProvider *provider = | std::unique_ptr<SigningProvider> provider = | ||||
GetSigningProvider(wtx.tx->vout[i].scriptPubKey); | GetSigningProvider(wtx.tx->vout[i].scriptPubKey); | ||||
bool solvable = | bool solvable = | ||||
provider ? IsSolvable(*provider, wtx.tx->vout[i].scriptPubKey) | provider ? IsSolvable(*provider, wtx.tx->vout[i].scriptPubKey) | ||||
: false; | : false; | ||||
bool spendable = | bool spendable = | ||||
((mine & ISMINE_SPENDABLE) != ISMINE_NO) || | ((mine & ISMINE_SPENDABLE) != ISMINE_NO) || | ||||
(((mine & ISMINE_WATCH_ONLY) != ISMINE_NO) && | (((mine & ISMINE_WATCH_ONLY) != ISMINE_NO) && | ||||
▲ Show 20 Lines • Show All 315 Lines • ▼ Show 20 Lines | for (CTxIn &input : tx.vin) { | ||||
return false; | return false; | ||||
} | } | ||||
const CScript &scriptPubKey = | const CScript &scriptPubKey = | ||||
mi->second.tx->vout[input.prevout.GetN()].scriptPubKey; | mi->second.tx->vout[input.prevout.GetN()].scriptPubKey; | ||||
const Amount amount = mi->second.tx->vout[input.prevout.GetN()].nValue; | const Amount amount = mi->second.tx->vout[input.prevout.GetN()].nValue; | ||||
SignatureData sigdata; | SignatureData sigdata; | ||||
SigHashType sigHashType = SigHashType().withForkId(); | SigHashType sigHashType = SigHashType().withForkId(); | ||||
const SigningProvider *provider = GetSigningProvider(scriptPubKey); | std::unique_ptr<SigningProvider> provider = | ||||
GetSigningProvider(scriptPubKey); | |||||
if (!provider) { | if (!provider) { | ||||
// We don't know about this scriptpbuKey; | // We don't know about this scriptpbuKey; | ||||
return false; | return false; | ||||
} | } | ||||
if (!ProduceSignature(*provider, | if (!ProduceSignature(*provider, | ||||
MutableTransactionSignatureCreator( | MutableTransactionSignatureCreator( | ||||
&tx, nIn, amount, sigHashType), | &tx, nIn, amount, sigHashType), | ||||
▲ Show 20 Lines • Show All 467 Lines • ▼ Show 20 Lines | txNew.nLockTime = GetLocktimeForNewTransaction(chain(), locked_chainIn); | ||||
if (sign) { | if (sign) { | ||||
SigHashType sigHashType = SigHashType().withForkId(); | SigHashType sigHashType = SigHashType().withForkId(); | ||||
int nIn = 0; | int nIn = 0; | ||||
for (const auto &coin : selected_coins) { | for (const auto &coin : selected_coins) { | ||||
const CScript &scriptPubKey = coin.txout.scriptPubKey; | const CScript &scriptPubKey = coin.txout.scriptPubKey; | ||||
SignatureData sigdata; | SignatureData sigdata; | ||||
const SigningProvider *provider = | std::unique_ptr<SigningProvider> provider = | ||||
GetSigningProvider(scriptPubKey); | GetSigningProvider(scriptPubKey); | ||||
if (!provider || | if (!provider || | ||||
!ProduceSignature( | !ProduceSignature( | ||||
*provider, | *provider, | ||||
MutableTransactionSignatureCreator( | MutableTransactionSignatureCreator( | ||||
&txNew, nIn, coin.txout.nValue, sigHashType), | &txNew, nIn, coin.txout.nValue, sigHashType), | ||||
scriptPubKey, sigdata)) { | scriptPubKey, sigdata)) { | ||||
error = _("Signing transaction failed"); | error = _("Signing transaction failed"); | ||||
▲ Show 20 Lines • Show All 1,476 Lines • ▼ Show 20 Lines | |||||
ScriptPubKeyMan *CWallet::GetScriptPubKeyMan(const uint256 &id) const { | ScriptPubKeyMan *CWallet::GetScriptPubKeyMan(const uint256 &id) const { | ||||
if (m_spk_managers.count(id) > 0) { | if (m_spk_managers.count(id) > 0) { | ||||
return m_spk_managers.at(id).get(); | return m_spk_managers.at(id).get(); | ||||
} | } | ||||
return nullptr; | return nullptr; | ||||
} | } | ||||
const SigningProvider * | std::unique_ptr<SigningProvider> | ||||
CWallet::GetSigningProvider(const CScript &script) const { | CWallet::GetSigningProvider(const CScript &script) const { | ||||
SignatureData sigdata; | SignatureData sigdata; | ||||
return GetSigningProvider(script, sigdata); | return GetSigningProvider(script, sigdata); | ||||
} | } | ||||
const SigningProvider * | std::unique_ptr<SigningProvider> | ||||
CWallet::GetSigningProvider(const CScript &script, | CWallet::GetSigningProvider(const CScript &script, | ||||
SignatureData &sigdata) const { | SignatureData &sigdata) const { | ||||
for (const auto &spk_man_pair : m_spk_managers) { | for (const auto &spk_man_pair : m_spk_managers) { | ||||
if (spk_man_pair.second->CanProvide(script, sigdata)) { | if (spk_man_pair.second->CanProvide(script, sigdata)) { | ||||
return spk_man_pair.second->GetSigningProvider(script); | return spk_man_pair.second->GetSigningProvider(script); | ||||
} | } | ||||
} | } | ||||
return nullptr; | return nullptr; | ||||
▲ Show 20 Lines • Show All 48 Lines • Show Last 20 Lines |