SignRawTransaction - What is scriptPubKey and redeemScript? [SOLVED] 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: Jonathan

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!
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.