| 433 | } |
| 434 | |
| 435 | bool IsSolvable(const CKeyStore& store, const CScript& script) |
| 436 | { |
| 437 | // This check is to make sure that the script we created can actually be solved for and signed by us |
| 438 | // if we were to have the private keys. This is just to make sure that the script is valid and that, |
| 439 | // if found in a transaction, we would still accept and relay that transaction. In particular, |
| 440 | // it will reject witness outputs that require signing with an uncompressed public key. |
| 441 | DummySignatureCreator creator(&store); |
| 442 | SignatureData sigs; |
| 443 | // Make sure that STANDARD_SCRIPT_VERIFY_FLAGS includes SCRIPT_VERIFY_WITNESS_PUBKEYTYPE, the most |
| 444 | // important property this function is designed to test for. |
| 445 | static_assert(STANDARD_SCRIPT_VERIFY_FLAGS & SCRIPT_VERIFY_WITNESS_PUBKEYTYPE, "IsSolvable requires standard script flags to include WITNESS_PUBKEYTYPE"); |
| 446 | if (ProduceSignature(creator, script, sigs)) { |
| 447 | // VerifyScript check is just defensive, and should never fail. |
| 448 | assert(VerifyScript(sigs.scriptSig, script, &sigs.scriptWitness, STANDARD_SCRIPT_VERIFY_FLAGS, creator.Checker())); |
| 449 | return true; |
| 450 | } |
| 451 | return false; |
| 452 | } |
no test coverage detected