MCPcopy Create free account
hub / github.com/ElementsProject/elements / CanProvide

Method CanProvide

src/wallet/scriptpubkeyman.cpp:595–616  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

593}
594
595bool LegacyScriptPubKeyMan::CanProvide(const CScript& script, SignatureData& sigdata)
596{
597 IsMineResult ismine = IsMineInner(*this, script, IsMineSigVersion::TOP, /* recurse_scripthash= */ false);
598 if (ismine == IsMineResult::SPENDABLE || ismine == IsMineResult::WATCH_ONLY) {
599 // If ismine, it means we recognize keys or script ids in the script, or
600 // are watching the script itself, and we can at least provide metadata
601 // or solving information, even if not able to sign fully.
602 return true;
603 } else {
604 // If, given the stuff in sigdata, we could make a valid sigature, then we can provide for this script
605 ProduceSignature(*this, DUMMY_SIGNATURE_CREATOR, script, sigdata);
606 if (!sigdata.signatures.empty()) {
607 // If we could make signatures, make sure we have a private key to actually make a signature
608 bool has_privkeys = false;
609 for (const auto& key_sig_pair : sigdata.signatures) {
610 has_privkeys |= HaveKey(key_sig_pair.first);
611 }
612 return has_privkeys;
613 }
614 return false;
615 }
616}
617
618bool LegacyScriptPubKeyMan::SignTransaction(CMutableTransaction& tx, const std::map<COutPoint, Coin>& coins, int sighash, std::map<int, bilingual_str>& input_errors) const
619{

Callers 4

SignMessageMethod · 0.45
GetScriptPubKeyMansMethod · 0.45
GetSolvingProviderMethod · 0.45
BOOST_AUTO_TEST_CASEFunction · 0.45

Calls 4

IsMineInnerFunction · 0.85
ProduceSignatureFunction · 0.85
HaveKeyFunction · 0.85
emptyMethod · 0.45

Tested by 1

BOOST_AUTO_TEST_CASEFunction · 0.36