<p>Well, I managed to solve this issue by manually modifying the transaction in javascript before calling coinbin's <code>sign</code> method. I've filed an issue with details <a href="https://github.com/OutCast3k/coinbin/issues/73" rel="nofollow noreferrer">here</a>. This is how I ended up solving the issue in Javascript (this is kind of a hack, I just specify the same redeemScript for each input, which works for my specific usecase): </p>

<pre><code>var rawtx2 = "01000000021a1f40dba3ab5c208b165d47bdcf2aadc517c4f2b90b781eab53dadcb35d61200100000000ffffffff05ec447a886d8711db0d5f4cbf1f61956cf227c82c5594ee195bb179e86faa910100000000ffffffff0138c70000000000001976a91472a2a94468e42593656cc9803c7a48c1863fc3e588ac00000000";


(function partialSignMultisig(window) {
    var coinjs = window.coinjs;
    var wifkey = "&lt;WIFKEYHERE&gt;";
    var script = rawtx2;
    var redeemScript = "5221020150ce6954f0cdcc2c5d57cf249f25eab0eed23e39549c4f06bcb42a37f308ce2102224aca2849ddad9c663c0bcfdac5ce3ca06f784ac8eca83404a4ea4ac61dbe7d52ae";

    var tx = coinjs.transaction();
    var t = tx.deserialize(script);

        // Manually specify scripts for inputs ..
    for (var i = 0; i &lt; t.ins.length; i++) {
        t.ins[i].script = coinjs.script(redeemScript);
    }

    var signed = t.sign(wifkey);
    console.log( signed );


})(window);
</code></pre>

CC BY-SA 3.0
2017-01-08T23:16:50.200Z
2017-01-08T23:16:50.200Z
motatoes
<p>I'm trying to generate a 2-of-2 multisig address:</p>

<ul>
<li><code>pubkey1</code> and <code>privkey1</code> on coinb.in</li>
<li><code>pubkey2</code> and <code>privkey2</code> a bitcoin core client</li>
<li>I use <code>createmultisig 2 '''["&lt;pubkey1&gt;", "&lt;pubkey2&gt;']'''</code> on the core to generate the 2-of-2 multisig address.</li>
</ul>

<p>. </p>

<pre><code>{
  "address": "38RmRDRp4YedPXdh9Vu82akPRtXwvsPeRp",
  "redeemScript": "5221020150ce6954f0cdcc2c5d57cf249f25eab0eed23e39549c4f06bcb42a37f308ce2102224aca2849ddad9c663c0bcfdac5ce3ca06f784ac8eca83404a4ea4ac61dbe7d52ae"
}
</code></pre>

<p>I transferred 0.00001BTC to that address in txid <a href="https://blockchain.info/tx/20615db3dcda53ab1e780bb9f2c417c5ad2acfbd475d168b205caba3db401f1a" rel="nofollow noreferrer">20615db3dcda53ab1e780bb9f2c417c5ad2acfbd475d168b205caba3db401f1a</a>  and my goal is to spend this amount from the multisig address:</p>

<ul>
<li>I created a raw transaction on the bitcoincore: </li>
</ul>

<p>.</p>

<pre><code>createrawtransaction '''[{ "txid": "20615db3dcda53ab1e780bb9f2c417c5ad2acfbd475d168b205caba3db401f1a", "vout": 1 }]''' '''{ "1BT8tmV9Exfrx7FUjNvLQaUBgpZJaHyXMT": 0.00000900  }'''
</code></pre>

<ul>
<li>I attempt to sign this transaction on coinb.in with <code>privkey2</code>:</li>
</ul>

<p><a href="https://i.sstatic.net/TLggj.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/TLggj.png" alt="coinb.in signature"></a></p>

<ul>
<li>I attempt to sign the second transaction on the core:</li>
</ul>

<p>.</p>

<pre><code>signrawtransaction "01000000011a1f40dba3ab5c208b165d47bdcf2aadc517c4f2b90b781eab53dadcb35d6120010000006b483045022100d4367946074622b6e22a936adbded609fba5d2501c603b630d3e2edadcb5bcc402203ac6693fbf2ac7ac4d4234ef19be348b6511a0fcdf5991cb26ac2b695876534c0121020150ce6954f0cdcc2c5d57cf249f25eab0eed23e39549c4f06bcb42a37f308ceffffffff0184030000000000001976a91472a2a94468e42593656cc9803c7a48c1863fc3e588ac00000000" 
'''[
     {
       "txid": "20615db3dcda53ab1e780bb9f2c417c5ad2acfbd475d168b205caba3db401f1a", 
       "vout": 1, 
       "scriptPubKey": "a91449e688475c78033674b8a645f4339fe41366251587", 
       "redeemScript": "5221020150ce6954f0cdcc2c5d57cf249f25eab0eed23e39549c4f06bcb42a37f308ce2102224aca2849ddad9c663c0bcfdac5ce3ca06f784ac8eca83404a4ea4ac61dbe7d52ae"}
]'''
'''["privkey2"]'''
</code></pre>

<p><strong>Output</strong> </p>

<pre><code>{
  "hex": "01000000011a1f40dba3ab5c208b165d47bdcf2aadc517c4f2b90b781eab53dadcb35d6120010000009200473044022015ededd076573807b25a4e7facef5ad132683d54ffde8d28c1dbcab4be8e852e02204a063aec61cf6e1eee4825b9f19566a06f87db02913b283f9281a133127002030100475221020150ce6954f0cdcc2c5d57cf249f25eab0eed23e39549c4f06bcb42a37f308ce2102224aca2849ddad9c663c0bcfdac5ce3ca06f784ac8eca83404a4ea4ac61dbe7d52aeffffffff0184030000000000001976a91472a2a94468e42593656cc9803c7a48c1863fc3e588ac00000000",
  "complete": false,
  "errors": [
    {
      "txid": "20615db3dcda53ab1e780bb9f2c417c5ad2acfbd475d168b205caba3db401f1a",
      "vout": 1,
      "scriptSig": "00473044022015ededd076573807b25a4e7facef5ad132683d54ffde8d28c1dbcab4be8e852e02204a063aec61cf6e1eee4825b9f19566a06f87db02913b283f9281a133127002030100475221020150ce6954f0cdcc2c5d57cf249f25eab0eed23e39549c4f06bcb42a37f308ce2102224aca2849ddad9c663c0bcfdac5ce3ca06f784ac8eca83404a4ea4ac61dbe7d52ae",
      "sequence": 4294967295,
      "error": "Script evaluated without error but finished with a false/empty top stack element"
    }
  ]
}
</code></pre>

<p>What am I doing wrong? Unfortunately I can't specify the <code>pubkeyscript</code> or <code>redeemscrit</code> to coinb.in, so could this be the reason why the signatures are not validating?</p>

<p><strong>Note:</strong> I can sign the transaction successfully on bitcoin core when I specify both private keys in the command.</p>

CC BY-SA 3.0
2017-01-08T17:36:40.857Z
Why can't you provide the `redeemscript` to coinb.in? On the create transaction tab you can paste in the redeemscript instead of an input address.
m1xolyd1an
CC BY-SA 3.0
2017-01-08T18:05:24.737Z
Indeed I think that's the root of the issue .. Coinbin does not allow me to specify a redeem script while signing a transaction ... Note that when I sign the transaction on the core first and then do the second signature on coinbin it works !!
motatoes
<multi-signature>
Partially sign a transaction with coinb.in
motatoes
# Partially sign a transaction with coinb.in

(Asked by: username_0 on 2017-01-08)

I'm trying to generate a 2-of-2 multisig address:

pubkey1 and privkey1 on coinb.in
pubkey2 and privkey2 a bitcoin core client
I use createmultisig 2 '''["", "']''' on the core to generate the 2-of-2 multisig address.

. 
{
  "address": "38RmRDRp4YedPXdh9Vu82akPRtXwvsPeRp",
  "redeemScript": "5221020150ce6954f0cdcc2c5d57cf249f25eab0eed23e39549c4f06bcb42a37f308ce2102224aca2849ddad9c663c0bcfdac5ce3ca06f784ac8eca83404a4ea4ac61dbe7d52ae"
}

I transferred 0.00001BTC to that address in txid 20615db3dcda53ab1e780bb9f2c417c5ad2acfbd475d168b205caba3db401f1a  and my goal is to spend this amount from the multisig address:

I created a raw transaction on the bitcoincore: 

.
createrawtransaction '''[{ "txid": "20615db3dcda53ab1e780bb9f2c417c5ad2acfbd475d168b205caba3db401f1a", "vout": 1 }]''' '''{ "1BT8tmV9Exfrx7FUjNvLQaUBgpZJaHyXMT": 0.00000900  }'''


I attempt to sign this transaction on coinb.in with privkey2:



I attempt to sign the second transaction on the core:

.
signrawtransaction "01000000011a1f40dba3ab5c208b165d47bdcf2aadc517c4f2b90b781eab53dadcb35d6120010000006b483045022100d4367946074622b6e22a936adbded609fba5d2501c603b630d3e2edadcb5bcc402203ac6693fbf2ac7ac4d4234ef19be348b6511a0fcdf5991cb26ac2b695876534c0121020150ce6954f0cdcc2c5d57cf249f25eab0eed23e39549c4f06bcb42a37f308ceffffffff0184030000000000001976a91472a2a94468e42593656cc9803c7a48c1863fc3e588ac00000000" 
'''[
     {
       "txid": "20615db3dcda53ab1e780bb9f2c417c5ad2acfbd475d168b205caba3db401f1a", 
       "vout": 1, 
       "scriptPubKey": "a91449e688475c78033674b8a645f4339fe41366251587", 
       "redeemScript": "5221020150ce6954f0cdcc2c5d57cf249f25eab0eed23e39549c4f06bcb42a37f308ce2102224aca2849ddad9c663c0bcfdac5ce3ca06f784ac8eca83404a4ea4ac61dbe7d52ae"}
]'''
'''["privkey2"]'''

Output 
{
  "hex": "01000000011a1f40dba3ab5c208b165d47bdcf2aadc517c4f2b90b781eab53dadcb35d6120010000009200473044022015ededd076573807b25a4e7facef5ad132683d54ffde8d28c1dbcab4be8e852e02204a063aec61cf6e1eee4825b9f19566a06f87db02913b283f9281a133127002030100475221020150ce6954f0cdcc2c5d57cf249f25eab0eed23e39549c4f06bcb42a37f308ce2102224aca2849ddad9c663c0bcfdac5ce3ca06f784ac8eca83404a4ea4ac61dbe7d52aeffffffff0184030000000000001976a91472a2a94468e42593656cc9803c7a48c1863fc3e588ac00000000",
  "complete": false,
  "errors": [
    {
      "txid": "20615db3dcda53ab1e780bb9f2c417c5ad2acfbd475d168b205caba3db401f1a",
      "vout": 1,
      "scriptSig": "00473044022015ededd076573807b25a4e7facef5ad132683d54ffde8d28c1dbcab4be8e852e02204a063aec61cf6e1eee4825b9f19566a06f87db02913b283f9281a133127002030100475221020150ce6954f0cdcc2c5d57cf249f25eab0eed23e39549c4f06bcb42a37f308ce2102224aca2849ddad9c663c0bcfdac5ce3ca06f784ac8eca83404a4ea4ac61dbe7d52ae",
      "sequence": 4294967295,
      "error": "Script evaluated without error but finished with a false/empty top stack element"
    }
  ]
}

What am I doing wrong? Unfortunately I can't specify the pubkeyscript or redeemscrit to coinb.in, so could this be the reason why the signatures are not validating?
Note: I can sign the transaction successfully on bitcoin core when I specify both private keys in the command.

**Tags:** multi-signature

> **Comments:**
> **username_1**: Why can't you provide the `redeemscript` to coinb.in? On the create transaction tab you can paste in the redeemscript instead of an input address.  
> **username_0**: Indeed I think that's the root of the issue .. Coinbin does not allow me to specify a redeem script while signing a transaction ... Note that when I sign the transaction on the core first and then do the second signature on coinbin it works !!  

---

## 1 answers

### Answer by username_0 on 2017-01-08. Score: 0 | Accepted answer

Well, I managed to solve this issue by manually modifying the transaction in javascript before calling coinbin's sign method. I've filed an issue with details here. This is how I ended up solving the issue in Javascript (this is kind of a hack, I just specify the same redeemScript for each input, which works for my specific usecase): 
var rawtx2 = "01000000021a1f40dba3ab5c208b165d47bdcf2aadc517c4f2b90b781eab53dadcb35d61200100000000ffffffff05ec447a886d8711db0d5f4cbf1f61956cf227c82c5594ee195bb179e86faa910100000000ffffffff0138c70000000000001976a91472a2a94468e42593656cc9803c7a48c1863fc3e588ac00000000";


(function partialSignMultisig(window) {
    var coinjs = window.coinjs;
    var wifkey = "";
    var script = rawtx2;
    var redeemScript = "5221020150ce6954f0cdcc2c5d57cf249f25eab0eed23e39549c4f06bcb42a37f308ce2102224aca2849ddad9c663c0bcfdac5ce3ca06f784ac8eca83404a4ea4ac61dbe7d52ae";

    var tx = coinjs.transaction();
    var t = tx.deserialize(script);

        // Manually specify scripts for inputs ..
    for (var i = 0; i < t.ins.length; i++) {
        t.ins[i].script = coinjs.script(redeemScript);
    }

    var signed = t.sign(wifkey);
    console.log( signed );


})(window);


---

