<!-- This issue tracker is only for technical issues related to Bitcoin Core.

General bitcoin questions and/or support requests are best directed to the Bitcoin StackExchange at https://bitcoin.stackexchange.com.

For reporting security issues, please read instructions at https://bitcoincore.org/en/contact/.

If the node is "stuck" during sync or giving "block checksum mismatch" errors, please ensure your hardware is stable by running memtest and observe CPU temperature with a load-test tool such as linpack before creating an issue! -->

<!-- Describe the issue -->
Unexpected output during multisig signing. See the following example when signing a 2/2 key.

```
bc signrawtransactionwithkey 0200000001b8a7873d892de2930cdb00a6c69dadbe8d553e2bef0688186a71009fd82062460100000000ffffffff028093dc140000000017a914a732060d1955ab93c50c1096597e2ea466b9937d8780d6e34c0000000017a9142d2aad185524b244ef2b2f6a0507d6f187d02fbe8700000000 '["cU3C1Uu4oN8ZPXrCz55GyjmrsaeoF8UhmBai2d9jzq9iw7ty9EMc"]' '[{"txid":"466220d89f00716a188806ef2b3e558dbead9dc6a600db0c93e22d893d87a7b8", "vout":1,"scriptPubKey":"a9142d2aad185524b244ef2b2f6a0507d6f187d02fbe87","redeemScript":"5221032559b7054ff5468aa9508579379b62c5f6b31145e5bfe743fc66c0ec72608dab21030eaf6ea71e09bd6f6b10a3ee42cc1a445d9020627a4569f17b7fbf1d5801959a52ae"}]'
```

```
{
  "hex": "0200000001b8a7873d892de2930cdb00a6c69dadbe8d553e2bef0688186a71009fd820624601000000920047304402202d3ccf2360f990235e2e0ce17f5f28f4313f413301869b554c4e79905de93508022009a4acd673571d7924e8c0cd192386972a72316e8195338ebb8577a2a2941ed70100475221032559b7054ff5468aa9508579379b62c5f6b31145e5bfe743fc66c0ec72608dab21030eaf6ea71e09bd6f6b10a3ee42cc1a445d9020627a4569f17b7fbf1d5801959a52aeffffffff028093dc140000000017a914a732060d1955ab93c50c1096597e2ea466b9937d8780d6e34c0000000017a9142d2aad185524b244ef2b2f6a0507d6f187d02fbe8700000000",
  "complete": false,
  "errors": [
    {
      "txid": "466220d89f00716a188806ef2b3e558dbead9dc6a600db0c93e22d893d87a7b8",
      "vout": 1,
      "witness": [
      ],
      "scriptSig": "0047304402202d3ccf2360f990235e2e0ce17f5f28f4313f413301869b554c4e79905de93508022009a4acd673571d7924e8c0cd192386972a72316e8195338ebb8577a2a2941ed70100475221032559b7054ff5468aa9508579379b62c5f6b31145e5bfe743fc66c0ec72608dab21030eaf6ea71e09bd6f6b10a3ee42cc1a445d9020627a4569f17b7fbf1d5801959a52ae",
      "sequence": 4294967295,
      "error": "Signature must be zero for failed CHECK(MULTI)SIG operation"
    }
  ]
}
```

```
bc signrawtransactionwithkey 0200000001b8a7873d892de2930cdb00a6c69dadbe8d553e2bef0688186a71009fd820624601000000920047304402202d3ccf2360f990235e2e0ce17f5f28f4313f413301869b554c4e79905de93508022009a4acd673571d7924e8c0cd192386972a72316e8195338ebb8577a2a2941ed70100475221032559b7054ff5468aa9508579379b62c5f6b31145e5bfe743fc66c0ec72608dab21030eaf6ea71e09bd6f6b10a3ee42cc1a445d9020627a4569f17b7fbf1d5801959a52aeffffffff028093dc140000000017a914a732060d1955ab93c50c1096597e2ea466b9937d8780d6e34c0000000017a9142d2aad185524b244ef2b2f6a0507d6f187d02fbe8700000000 '["cSB1o7v1QBZDHJropQqBYfuiUA4Js1o24uzkgB2vYeND1st5uGqV"]' 
```

```
{
  "hex": "0200000001b8a7873d892de2930cdb00a6c69dadbe8d553e2bef0688186a71009fd820624601000000d90047304402202d3ccf2360f990235e2e0ce17f5f28f4313f413301869b554c4e79905de93508022009a4acd673571d7924e8c0cd192386972a72316e8195338ebb8577a2a2941ed70147304402206fe3aa79e02894ec40d3f6e9df7d7056c5b50cd7a39e1cde3aa3dd097c76798f0220464cd0a39690cbf28687b3b695eb0dc59ca73aef624b16b9586ade31a0761b3101475221032559b7054ff5468aa9508579379b62c5f6b31145e5bfe743fc66c0ec72608dab21030eaf6ea71e09bd6f6b10a3ee42cc1a445d9020627a4569f17b7fbf1d5801959a52aeffffffff028093dc140000000017a914a732060d1955ab93c50c1096597e2ea466b9937d8780d6e34c0000000017a9142d2aad185524b244ef2b2f6a0507d6f187d02fbe8700000000",
  "complete": true
}
```

<!--- What behavior did you expect? -->
When dealing with the RPC calls alone, it was difficult to realize that the partial signing was actually working. This is due to the this specific portion of the response:

```
  "errors": [
    {
      "txid": "466220d89f00716a188806ef2b3e558dbead9dc6a600db0c93e22d893d87a7b8",
      "vout": 1,
      "witness": [
      ],
      "scriptSig": "0047304402202d3ccf2360f990235e2e0ce17f5f28f4313f413301869b554c4e79905de93508022009a4acd673571d7924e8c0cd192386972a72316e8195338ebb8577a2a2941ed70100475221032559b7054ff5468aa9508579379b62c5f6b31145e5bfe743fc66c0ec72608dab21030eaf6ea71e09bd6f6b10a3ee42cc1a445d9020627a4569f17b7fbf1d5801959a52ae",
      "sequence": 4294967295,
      "error": "Signature must be zero for failed CHECK(MULTI)SIG operation"
    }

```

Based on the RPC respons on here: https://bitcoin.org/en/developer-examples#p2sh-multisig

I expected the successful partial signature to be as follows:
```
{
    "hex" : "010000000175e1769813db8418fea17576694af1ff31cb2b512\
             b7333e6eb42f030d0d7787200000000b5004830450221008d5e\
             c57d362ff6ef6602e4e756ef1bdeee12bd5c5c72697ef1455b3\
             79c90531002202ef3ea04dfbeda043395e5bc701e4878c15baa\
             b9c6ba5808eb3d04c91f641a0c014c69522103310188e911026\
             cf18c3ce274e0ebb5f95b007f230d8cb7d09879d96dbeab1aff\
             210243930746e6ed6552e03359db521b088134652905bd2d154\
             1fa9124303a41e95621029e03a901b85534ff1e92c43c74431f\
             7ce72046060fcf7a95c37e148f78c7725553aeffffffff01c0b\
             c973b000000001976a914b6f64f5bf3e38f25ead28817df7929\
             c06fe847ee88ac00000000",
    "complete" : false
}
```

I'm using `Bitcoin Core RPC client version v0.17.0`

I suspect the issue is related to this: https://github.com/bitcoin/bitcoin/issues/9988, however they're using a different RPC call.
SignatureData sigdata = DataFromTransaction(mtx, i, coin->second.out);
        
        if (!fHashSingle || (i < mtx.vout.size())) {
            ProduceSignature(*keystore, MutableTransactionSignatureCreator(&mtx, i, amount, nHashType), prevPubKey, sigdata);
        }
        UpdateInput(txin, sigdata);
        
        if (amount == MAX_MONEY && !txin.scriptWitness.IsNull()) {
            throw JSONRPCError(RPC_TYPE_ERROR, strprintf("Missing amount for %s", coin->second.out.ToString()));
        }
        ScriptError serror = SCRIPT_ERR_OK;
        if (!VerifyScript(txin.scriptSig, prevPubKey, &txin.scriptWitness, STANDARD_SCRIPT_VERIFY_FLAGS, TransactionSignatureChecker(&txConst, i, amount), &serror)) {
            if (serror == SCRIPT_ERR_INVALID_STACK_OPERATION) {
                
                TxInErrorToJSON(txin, vErrors, "Unable to sign input, invalid stack size (possibly missing key)");
            } else {
                TxInErrorToJSON(txin, vErrors, ScriptErrorString(serror));
            }
        }
    }
    bool fComplete = vErrors.empty();
    UniValue result(UniValue::VOBJ);
    result.pushKV("hex", EncodeHexTx(CTransaction(mtx)));
    result.pushKV("complete", fComplete);
    if (!vErrors.empty()) {
        result.pushKV("errors", vErrors);
    }
    return result;
}