<p>First of all, take a look at <a href="https://gist.github.com/gavinandresen/3966071" rel="nofollow">https://gist.github.com/gavinandresen/3966071</a>.  That's a script that creates two raw transactions: one to fund a multisig address, and another to spend the funds.  It shows each of the steps necessary to create and spend from a multisig address.  Unfortunately, the script doesn't do a good job of explaining where the parameters come from.  I'll try to explain the parameters you need.</p>

<p>As you guessed, hexstring is the output from createrawtransaction, and transaction id is the ID of the transaction that sent the coins to the multisig address.  redeemScript is easy.  When you first generated the multisig address, the command returned both the address and the redeemScript.  If you don't have that value, you can recreate the multisig address with the same public keys and you'll see it in the output.  scriptPubKey is the one I'm not sure about.  I think I know what it is, but I don't have bitcoind in front of me so I can't be sure.  If you decode the raw transaction that send coins to the multisig address, you'll see one or two outputs, one of which sends coins to the multisig address.  (The other output sends the rest of the coins to a change address.)  There will be a scriptPubKey section in that output.  Copy the hex string from that section and use it as the scriptPubKey parameter.</p>

<p>Once you have those parameters, you can sign the raw transaction and send it.  If it doesn't work, leave a comment here and I'll try to work it out when I get home.</p>

CC BY-SA 3.0
2014-02-20T19:30:21.020Z
thank you for clarifying, I edited the original post to clarify the steps I have taken and while I was using the wrong redeemScript, I am still not getting the desired output.
Bitcoin Dev Wannabee
CC BY-SA 3.0
2014-02-20T15:48:33.047Z
2014-02-20T15:48:33.047Z
Jonathan
<p>Let me talk about how I got to the situation I'm in right now. I am using PHP and the JSON library to control bitcoind. And doing so.....</p>

<p>I created a multisignature address requiring 2 of 3 signatures with createmultisig.</p>

<p>I then sent funds to the multisignature address and was able to confirm the transactions sent to this address with using getrawtransaction and decoderawtransaction. </p>

<p>Next, I wanted to release those funds to a specific address (because I control all the keys, this is just a test run)</p>

<p>So I created a raw transaction in which I entered the transaction ID that I used for one of the transactions to send funds to the multisignature wallet. I also added the desired address and amount. After this, it spit out a raw transaction hex. </p>

<p>My next step is to sign the raw transaction. This is where I am stuck. </p>

<p>The parameters for signrawtransaction are confusing to me, and I need it explained to me as if I was 5 years old. </p>

<p><code>
hexstring - assuming this is the hex string that createrawtransaction spit out</p>

<p>transaction id - is this the transaction id from when I transferred in the amount to the multisig wallet?</p>

<p>scriptPubKey - no idea what this is</p>

<p>redeemScript - no idea what this is
</code></p>

<p>I grabbed scriptPubKey and redeemScript from the transaction I used to transfer funds into the multisig wallet, but the resulting output was the exact input of the hex string, so it is obviously not signing it correctly. I am not sure what these 2 paramters are. </p>

<p>Can somebody please help me with this. I need it explained to me like I am retarded because none of the explanations I have read online have helped.</p>

<p>Thanks.</p>

<p>EDIT to RE: Jonathan</p>

<p>Here is what I have done so far.</p>

<p>1) Created a multisig address using 3 public keys that I generated.
I took note of the private keys as well, and the outputted multisig address (ABC) and redeemScript (redeem1)</p>

<p>2) Sent coins to the multisig address and by searching through the blockchain found that the transactions exist. I had multiple transaction IDs, to send to this address but I am focusing on one that I am trying to use as an output. We will call it (txid1). In txid1, when I called getrawtransaction, it also had a 46 byte hexed pubkey attached to the output, I will call that (pubkey1)</p>

<p>3) Next I created a raw transaction which included the paramters;</p>

<p>txid1, vout=0, address (address to spend to) and amount (matches the same amount transferred to the multsig address with txid1) and it spits out a hexstring, which I will call (hex1)</p>

<p>4) SignRawTransaction - here is where I am stuck.
The parameters it asks for are; </p>

<p> [{"txid":txid,"vout":n,"scriptPubKey":hex, "redeemScript":hex},...] [,...] </p>

<p>So I am inputting signrawtransaction(hex1, ["txid"=>txid1, "vout"=>0, "scriptPubKey"=>pubkey1, "redeemScript"=>redeem1, array(oneofmyprivatekeys))</p>

<p>But the resulting output is just the hex1, without a single change to it. I am not getting any error messages, just an outputed string identical to hex1. </p>

<p>Can you give me an idea of what I am doing wrong? Thank you so much!</p>

CC BY-SA 3.0
2014-02-20T20:48:44.427Z
The issue is that I was using the wrong redeem script.
I had created two muli-signature addresses with similar names and got them mixed up
Bitcoin Dev Wannabee
CC BY-SA 3.0
2014-03-22T21:13:14.750Z
StackExchange is not a forum, please do not add "[SOLVED]" "tags" to question titles. See the [help] entries for [when someone answers](https://bitcoin.stackexchange.com/help/someone-answers) and/or for [self answering](https://bitcoin.stackexchange.com/help/self-answer).
dchapes
<multi-signature><signature><raw-transaction>
SignRawTransaction - What is scriptPubKey and redeemScript? [SOLVED]
Bitcoin Dev Wannabee
# SignRawTransaction - What is scriptPubKey and redeemScript? [SOLVED]

(Asked by: username_0 on 2014-02-20)

Let me talk about how I got to the situation I'm in right now. I am using PHP and the JSON library to control bitcoind. And doing so.....

I created a multisignature address requiring 2 of 3 signatures with createmultisig.

I then sent funds to the multisignature address and was able to confirm the transactions sent to this address with using getrawtransaction and decoderawtransaction.

Next, I wanted to release those funds to a specific address (because I control all the keys, this is just a test run)

So I created a raw transaction in which I entered the transaction ID that I used for one of the transactions to send funds to the multisignature wallet. I also added the desired address and amount. After this, it spit out a raw transaction hex.

My next step is to sign the raw transaction. This is where I am stuck.

The parameters for signrawtransaction are confusing to me, and I need it explained to me as if I was 5 years old.

`hexstring - assuming this is the hex string that createrawtransaction spit out`

transaction id - is this the transaction id from when I transferred in the amount to the multisig wallet?

scriptPubKey - no idea what this is

redeemScript - no idea what this is

I grabbed scriptPubKey and redeemScript from the transaction I used to transfer funds into the multisig wallet, but the resulting output was the exact input of the hex string, so it is obviously not signing it correctly. I am not sure what these 2 paramters are.

Can somebody please help me with this. I need it explained to me like I am retarded because none of the explanations I have read online have helped.

Thanks.

EDIT to RE: username_2

Here is what I have done so far.

1) Created a multisig address using 3 public keys that I generated.
I took note of the private keys as well, and the outputted multisig address (ABC) and redeemScript (redeem1)

2) Sent coins to the multisig address and by searching through the blockchain found that the transactions exist. I had multiple transaction IDs, to send to this address but I am focusing on one that I am trying to use as an output. We will call it (txid1). In txid1, when I called getrawtransaction, it also had a 46 byte hexed pubkey attached to the output, I will call that (pubkey1)

3) Next I created a raw transaction which included the paramters;

txid1, vout=0, address (address to spend to) and amount (matches the same amount transferred to the multsig address with txid1) and it spits out a hexstring, which I will call (hex1)

4) SignRawTransaction - here is where I am stuck.
The parameters it asks for are;

[{"txid":txid,"vout":n,"scriptPubKey":hex, "redeemScript":hex},...] [,...]

So I am inputting signrawtransaction(hex1, ["txid"=>txid1, "vout"=>0, "scriptPubKey"=>pubkey1, "redeemScript"=>redeem1, array(oneofmyprivatekeys))

But the resulting output is just the hex1, without a single change to it. I am not getting any error messages, just an outputed string identical to hex1.

Can you give me an idea of what I am doing wrong? Thank you so much!

**Tags:** multi-signature, signature, raw-transaction

> **Comments:**
> **username_0**: The issue is that I was using the wrong redeem script. I had created two muli-signature addresses with similar names and got them mixed up  
> **username_1**: StackExchange is not a forum, please do not add "[SOLVED]" "tags" to question titles. See the [help] entries for [when someone answers](https://username_0.stackexchange.com/help/someone-answers) and/or for [self answering](https://username_0.stackexchange.com/help/self-answer).  

---

## 1 answers

### Answer by username_2 on 2014-02-20. Score: 3

First of all, take a look at <https://gist.github.com/gavinandresen/3966071>. That's a script that creates two raw transactions: one to fund a multisig address, and another to spend the funds. It shows each of the steps necessary to create and spend from a multisig address. Unfortunately, the script doesn't do a good job of explaining where the parameters come from. I'll try to explain the parameters you need.

As you guessed, hexstring is the output from createrawtransaction, and transaction id is the ID of the transaction that sent the coins to the multisig address. redeemScript is easy. When you first generated the multisig address, the command returned both the address and the redeemScript. If you don't have that value, you can recreate the multisig address with the same public keys and you'll see it in the output. scriptPubKey is the one I'm not sure about. I think I know what it is, but I don't have bitcoind in front of me so I can't be sure. If you decode the raw transaction that send coins to the multisig address, you'll see one or two outputs, one of which sends coins to the multisig address. (The other output sends the rest of the coins to a change address.) There will be a scriptPubKey section in that output. Copy the hex string from that section and use it as the scriptPubKey parameter.

Once you have those parameters, you can sign the raw transaction and send it. If it doesn't work, leave a comment here and I'll try to work it out when I get home.

> **Comments:**
> **username_0**: thank you for clarifying, I edited the original post to clarify the steps I have taken and while I was using the wrong redeemScript, I am still not getting the desired output.  

---

