|
|
@@ -1067,11 +1067,15 @@ class Witnessifier : public boost::static_visitor<bool> |
|
|
bool operator()(const CKeyID &keyID) {
|
|
|
if (pwallet) {
|
|
|
CScript basescript = GetScriptForDestination(keyID);
|
|
|
- isminetype typ;
|
|
|
- typ = IsMine(*pwallet, basescript, SIGVERSION_WITNESS_V0);
|
|
|
- if (typ != ISMINE_SPENDABLE && typ != ISMINE_WATCH_SOLVABLE)
|
|
|
- return false;
|
|
|
CScript witscript = GetScriptForWitness(basescript);
|
|
|
+ SignatureData sigs;
|
|
|
+ // This check is to make sure that the script we created can actually be solved for and signed by us
|
|
|
+ // if we were to have the private keys. This is just to make sure that the script is valid and that,
|
|
|
+ // if found in a transaction, we would still accept and relay that transcation.
|
|
|
+ if (!ProduceSignature(DummySignatureCreator(pwallet), witscript, sigs) ||
|
|
|
+ !VerifyScript(sigs.scriptSig, witscript, &sigs.scriptWitness, MANDATORY_SCRIPT_VERIFY_FLAGS | SCRIPT_VERIFY_WITNESS_PUBKEYTYPE, DummySignatureCreator(pwallet).Checker())) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
pwallet->AddCScript(witscript);
|
|
|
result = CScriptID(witscript);
|
|
|
return true;
|
|
|
@@ -1088,11 +1092,15 @@ class Witnessifier : public boost::static_visitor<bool> |
|
|
result = scriptID;
|
|
|
return true;
|
|
|
}
|
|
|
- isminetype typ;
|
|
|
- typ = IsMine(*pwallet, subscript, SIGVERSION_WITNESS_V0);
|
|
|
- if (typ != ISMINE_SPENDABLE && typ != ISMINE_WATCH_SOLVABLE)
|
|
|
- return false;
|
|
|
CScript witscript = GetScriptForWitness(subscript);
|
|
|
+ SignatureData sigs;
|
|
|
+ // This check is to make sure that the script we created can actually be solved for and signed by us
|
|
|
+ // if we were to have the private keys. This is just to make sure that the script is valid and that,
|
|
|
+ // if found in a transaction, we would still accept and relay that transcation.
|
|
|
+ if (!ProduceSignature(DummySignatureCreator(pwallet), witscript, sigs) ||
|
|
|
+ !VerifyScript(sigs.scriptSig, witscript, &sigs.scriptWitness, MANDATORY_SCRIPT_VERIFY_FLAGS | SCRIPT_VERIFY_WITNESS_PUBKEYTYPE, DummySignatureCreator(pwallet).Checker())) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
pwallet->AddCScript(witscript);
|
|
|
result = CScriptID(witscript);
|
|
|
return true;
|
|
|
|