<p>You get this error because Bitcoin has tried to validate the script, and failed, because not all of the signatures necessary were added in the previous <code>signrawtransaction</code>. You can also tell this because <code>complete</code> is false.</p>

<p>You need to take it to clients that have the other keys necessary, and run <code>signrawtransaction</code> on the transaction there too.</p>

CC BY-SA 3.0
2015-08-31T03:49:20.287Z
To further clarify, for future viewers, you can tell that the tx is partly signed by running the returned hash though `decoderawtransaction` and noting that you now have content in the vin scriptsig field. It really should have a message saying it was partly signed, but it doesn't.
Drazisil
CC BY-SA 3.0
2017-03-31T15:40:55.407Z
@Drazisil Why do I get content in the scriptsig of vin?
Shabahat M. Ayubi
CC BY-SA 3.0
2015-08-31T03:40:23.160Z
2015-08-31T03:40:23.160Z
Nick ODell
<p>I've been running into a lot of trouble getting a transaction to spend coins in a multisig address.</p>

<p>I create the raw transaction
When I go to sign, I get "Operation not valid with the correct stack size"</p>

<p>I'm using core, and the codes are here.</p>

<p>First, check if it's good.</p>

<pre><code>bitcoin-cli decoderawtransaction 0100000001d2aba456546be8f5223802112637e484c5d94118dfe560fa23de06fb37e621dd0000000000ffffffff01107a0700000000001976a914a4f29e1c8f592021fd79eda1be85c96a9a8d349a88ac00000000
{
    "txid" : "e71006c60dbfa2793710d5cf866d1b6b89ba80bc41634031d927738c40ae8228",
    "version" : 1,
    "locktime" : 0,
    "vin" : [
        {
            "txid" : "dd21e637fb06de23fa60e5df1841d9c584e4372611023822f5e86b5456a4abd2",
            "vout" : 0,
            "scriptSig" : {
                "asm" : "",
                "hex" : ""
            },
            "sequence" : 4294967295
        }
    ],
    "vout" : [
        {
            "value" : 0.00490000,
            "n" : 0,
            "scriptPubKey" : {
                "asm" : "OP_DUP OP_HASH160 a4f29e1c8f592021fd79eda1be85c96a9a8d349a OP_EQUALVERIFY OP_CHECKSIG",
                "hex" : "76a914a4f29e1c8f592021fd79eda1be85c96a9a8d349a88ac",
                "reqSigs" : 1,
                "type" : "pubkeyhash",
                "addresses" : [
                    "1G3ATq31k5SrGdqucXKqA9dHbzS3wJHzbc"
                ]
            }
        }
    ]
}
</code></pre>

<p>And then we go to sign.</p>

<pre><code>bitcoin-cli signrawtransaction 0100000001d2aba456546be8f5223802112637e484c5d94118dfe560fa23de06fb37e621dd0000000000ffffffff01107a0700000000001976a914a4f29e1c8f592021fd79eda1be85c96a9a8d349a88ac00000000
{
    "hex" : "0100000001d2aba456546be8f5223802112637e484c5d94118dfe560fa23de06fb37e621dd000000009200483045022100eaae5737ab000f614ce73da11ba456b4467cf640ed881fd1fa90183d1d28c2e8022066c78bf750ae0a175f6ef116ecc3e4a0c18eda1aff9c951952f8f6e45a3521ad0147522102908921b30aa37fe6e522c528cca0ebcda9f0df4019301fa45bc3b3c7df60245a2103559dc92d6e44a98080d487e585b93278106249a166795584ae554a4275f059b752aeffffffff01107a0700000000001976a914a4f29e1c8f592021fd79eda1be85c96a9a8d349a88ac00000000",
    "complete" : false,
    "errors" : [
        {
            "txid" : "dd21e637fb06de23fa60e5df1841d9c584e4372611023822f5e86b5456a4abd2",
            "vout" : 0,
            "scriptSig" : "00483045022100eaae5737ab000f614ce73da11ba456b4467cf640ed881fd1fa90183d1d28c2e8022066c78bf750ae0a175f6ef116ecc3e4a0c18eda1aff9c951952f8f6e45a3521ad0147522102908921b30aa37fe6e522c528cca0ebcda9f0df4019301fa45bc3b3c7df60245a2103559dc92d6e44a98080d487e585b93278106249a166795584ae554a4275f059b752ae",
            "sequence" : 4294967295,
            "error" : "Operation not valid with the current stack size"
        }
    ]
}
</code></pre>

<p>I'm using <a href="https://gist.githubusercontent.com/gavinandresen/3966071/raw/ca21870c190ba0e90c1a30673e790ef5acd207d2/TwoOfThree.sh">https://gist.githubusercontent.com/gavinandresen/3966071/raw/ca21870c190ba0e90c1a30673e790ef5acd207d2/TwoOfThree.sh</a> for reference.</p>

CC BY-SA 3.0
2015-08-31T02:41:25.853Z
Do you have all of the keys necessary to spend this output? This looks like it signed with some of the keys, but you need another.
Nick ODell
CC BY-SA 3.0
2015-08-31T02:49:43.753Z
Is that what it means? I didnt even think that it signed part, it seems to give no sign of partial success. yes, i only have one of the required keys, but what part of that shows it partly signed?
Drazisil
CC BY-SA 3.0
2015-08-31T02:50:18.890Z
Well, it's longer.
Nick ODell
CC BY-SA 3.0
2015-08-31T03:04:55.733Z
Thank you so much! Please, write up an answer and I will accept. What genius decided to code such a user-unfriendlt 'success'
Drazisil
<bitcoin-core><raw-transaction><p2sh>
How do you spend a P2SH transaction?
Drazisil
# How do you spend a P2SH transaction?

(Asked by: username_0 on 2015-08-31)

I've been running into a lot of trouble getting a transaction to spend coins in a multisig address.
I create the raw transaction
When I go to sign, I get "Operation not valid with the correct stack size"
I'm using core, and the codes are here.
First, check if it's good.
bitcoin-cli decoderawtransaction 0100000001d2aba456546be8f5223802112637e484c5d94118dfe560fa23de06fb37e621dd0000000000ffffffff01107a0700000000001976a914a4f29e1c8f592021fd79eda1be85c96a9a8d349a88ac00000000
{
    "txid" : "e71006c60dbfa2793710d5cf866d1b6b89ba80bc41634031d927738c40ae8228",
    "version" : 1,
    "locktime" : 0,
    "vin" : [
        {
            "txid" : "dd21e637fb06de23fa60e5df1841d9c584e4372611023822f5e86b5456a4abd2",
            "vout" : 0,
            "scriptSig" : {
                "asm" : "",
                "hex" : ""
            },
            "sequence" : 4294967295
        }
    ],
    "vout" : [
        {
            "value" : 0.00490000,
            "n" : 0,
            "scriptPubKey" : {
                "asm" : "OP_DUP OP_HASH160 a4f29e1c8f592021fd79eda1be85c96a9a8d349a OP_EQUALVERIFY OP_CHECKSIG",
                "hex" : "76a914a4f29e1c8f592021fd79eda1be85c96a9a8d349a88ac",
                "reqSigs" : 1,
                "type" : "pubkeyhash",
                "addresses" : [
                    "1G3ATq31k5SrGdqucXKqA9dHbzS3wJHzbc"
                ]
            }
        }
    ]
}

And then we go to sign.
bitcoin-cli signrawtransaction 0100000001d2aba456546be8f5223802112637e484c5d94118dfe560fa23de06fb37e621dd0000000000ffffffff01107a0700000000001976a914a4f29e1c8f592021fd79eda1be85c96a9a8d349a88ac00000000
{
    "hex" : "0100000001d2aba456546be8f5223802112637e484c5d94118dfe560fa23de06fb37e621dd000000009200483045022100eaae5737ab000f614ce73da11ba456b4467cf640ed881fd1fa90183d1d28c2e8022066c78bf750ae0a175f6ef116ecc3e4a0c18eda1aff9c951952f8f6e45a3521ad0147522102908921b30aa37fe6e522c528cca0ebcda9f0df4019301fa45bc3b3c7df60245a2103559dc92d6e44a98080d487e585b93278106249a166795584ae554a4275f059b752aeffffffff01107a0700000000001976a914a4f29e1c8f592021fd79eda1be85c96a9a8d349a88ac00000000",
    "complete" : false,
    "errors" : [
        {
            "txid" : "dd21e637fb06de23fa60e5df1841d9c584e4372611023822f5e86b5456a4abd2",
            "vout" : 0,
            "scriptSig" : "00483045022100eaae5737ab000f614ce73da11ba456b4467cf640ed881fd1fa90183d1d28c2e8022066c78bf750ae0a175f6ef116ecc3e4a0c18eda1aff9c951952f8f6e45a3521ad0147522102908921b30aa37fe6e522c528cca0ebcda9f0df4019301fa45bc3b3c7df60245a2103559dc92d6e44a98080d487e585b93278106249a166795584ae554a4275f059b752ae",
            "sequence" : 4294967295,
            "error" : "Operation not valid with the current stack size"
        }
    ]
}

I'm using https://gist.githubusercontent.com/gavinandresen/3966071/raw/ca21870c190ba0e90c1a30673e790ef5acd207d2/TwoOfThree.sh for reference.

**Tags:** bitcoin-core, raw-transaction, p2sh

> **Comments:**
> **username_1**: Do you have all of the keys necessary to spend this output? This looks like it signed with some of the keys, but you need another.  
> **username_0**: Is that what it means? I didnt even think that it signed part, it seems to give no sign of partial success. yes, i only have one of the required keys, but what part of that shows it partly signed?  
> **username_1**: Well, it's longer.  
> **username_0**: Thank you so much! Please, write up an answer and I will accept. What genius decided to code such a user-unfriendlt 'success'  

---

## 1 answers

### Answer by username_1 on 2015-08-31. Score: 8 | Accepted answer

You get this error because Bitcoin has tried to validate the script, and failed, because not all of the signatures necessary were added in the previous `signrawtransaction`. You can also tell this because `complete` is false.

You need to take it to clients that have the other keys necessary, and run `signrawtransaction` on the transaction there too.

> **Comments:**
> **username_0**: To further clarify, for future viewers, you can tell that the tx is partly signed by running the returned hash though `decoderawtransaction` and noting that you now have content in the vin scriptsig field. It really should have a message saying it was partly signed, but it doesn't.  
> **username_2**: @username_0 Why do I get content in the scriptsig of vin?  

---

