| 593 | } |
| 594 | |
| 595 | bool 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 | |
| 618 | bool LegacyScriptPubKeyMan::SignTransaction(CMutableTransaction& tx, const std::map<COutPoint, Coin>& coins, int sighash, std::map<int, bilingual_str>& input_errors) const |
| 619 | { |