<p>I try to provide a (partial) answer: I thin you are not doing anything wrong... there are two ways of creating multisig tx. The "old" way as with your link from blocktrail, and the "new" way as per your following text. The old way had two or three disadvantages: it bloats the blockchain from the beginning, the fees are high at the beginning, and it discloses the possible signer's pubkeys. In this case the 3 non compressed pubkeys have each 65 bytes, so 200 bytes on the blockchain...</p>

<p>The new multisig via a P2SH construct basically hashes the spending logic (also called the <strong>redeem script</strong>: 2    3 CHECKMULTISIG), and base58check encoded provides a "P2SH address" (beginning with a "3"). This hash is then only 20 Bytes long, non-reversible (you can't see which are the pubkeys), and the fee for bringing this tx to the blockchain remain low. Of course, at the very end, the spending this tx requires to disclose and pay the higher fees. </p>

<p>Unless you don't have a very, very specific use case, do you think it is impossible to use the newer logic? 
I found further description in Andreas book "Mastering Bitcoin" in Chapter 7, page 149ff - it is also online available. </p>

CC BY-SA 3.0
2017-11-11T22:55:43.763Z
pebwindkraft, thank you so much for the answer. I have mentioned very very specific use case, so if you can navigate me how to create bitcoin transaction with multisig-output (with array of P2PKH addresses) using
createrawtransaction-method (or with php/js/.../language) - please do it ).
Unfortunately I did not found this info in Mastering Bitcoin.
Daniil Kamenskiy
CC BY-SA 3.0
2017-11-12T14:39:40.970Z
this looks more difficult than I thought. Keyword is probably "raw multisig", quickly searching through the forum reveals an answer from Pieter (https://bitcoin.stackexchange.com/questions/46447/with-what-number-do-multisig-addresses-non-p2sh-start/46448#46448), which discourages the usage of raw multisig. Probably BIP11 provide more info. This post https://bitcoin.stackexchange.com/questions/3712/how-can-i-create-a-multi-signature-2-of-3-transaction/10593#10593 mentions the use of an "SX Library", but I have never checked any libraries for this...
pebwindkraft
CC BY-SA 3.0
2017-11-12T14:40:54.247Z
and here is the link to the first edition from Andreas: http://chimera.labs.oreilly.com/books/1234000001802/ch05.html#multisig and bitcoin has this link: https://bitcoinj.github.io/working-with-contracts
pebwindkraft
CC BY-SA 3.0
2017-11-11T20:48:16.713Z
2017-11-11T20:48:16.713Z
pebwindkraft
<p>I need to send money in one transaction to 2 addresses so that any of them can spend it.
In other words - I need to create same transaction as here
<a href="https://www.blocktrail.com/BTC/tx/6e2c5b6b2a926a7da2415ae55c701e83d6e7bc46bad9bc23b5f9c7ef1ae26998" rel="nofollow noreferrer">https://www.blocktrail.com/BTC/tx/6e2c5b6b2a926a7da2415ae55c701e83d6e7bc46bad9bc23b5f9c7ef1ae26998</a>
(
hex of raw transaction is </p>

<pre><code>010000000227ed8477b4d0ab4d52bc31e0639f2f58665d9f7aff0a2aab229bba51af28ea5b000000008a4730440220279b45f812ebd1004ee041eb75a3f42657dce19bdba06b30b2d1b70f45e2590602201b06ecbbbf6fae0a3455d98ac2924cd6dc3022425a2f08c60ffb46e96dbdc8e9014104a84d304aa8963fbd36287e674f109827b6d6ea60d57a7d9357df03be1fcedb2c47475ca128b1a50408b7f584041ffd52d6b19aba5256e99dcdbbe2ed7373775dfffffffff302a856316c80cfbb5735c7a1fd5caad5b856206e2855e6f98bad5959778620010000008a47304402203b163fb30bf53c15e1b7d4ab8af17c3e79193f12d29b17d0a68afac8dc07f07b0220364d304ee4d3fcba82729ba5b011f99636e5633f66f5af224fd8ec5cd1850a44014104a84d304aa8963fbd36287e674f109827b6d6ea60d57a7d9357df03be1fcedb2c47475ca128b1a50408b7f584041ffd52d6b19aba5256e99dcdbbe2ed7373775dffffffff028096980000000000c9524104478f498fe3f6872a9559ae0fd5975bc44f500eed955a835027962099c333536f60b4e60383e6e1081efa0a76df1ef0aefb4da87ff0c8f12dab5da2969fc7b24e41044f09a164267c635c6991f7a96bc7901d035c07161a0074d719be723f6a9c50bc72b900092cffec5f3c3484dae35d04a5a2fa2e75f3a99e17577537c1227b44ba4104971e5b8b222fe47f742fa07d3327d36a6cd37088656ce29842ed82e1dc8bffaa81848b3219359fdf9d8b590d3af85cfff2d06d4b19fde5ed560b2c9caa5dd65653ae40196604000000001976a9148c1b30a7b5f8bd87c1cd8b8c4cb4f74345f1978a88ac00000000
</code></pre>

<p>)
with multisig type of scriptPubKey of output and array of destination addresses with 2 P2PKH (no 1 P2SH!) items.</p>

<p>curl --user USERNAME:PASSWORD --data-binary '{"method":"getrawtransaction","id":"a2e8f6b0-5c03-4315-a067-050a9adb6dfc","params":["6e2c5b6b2a926a7da2415ae55c701e83d6e7bc46bad9bc23b5f9c7ef1ae26998",1]}' "<a href="http://127.0.0.1:18833" rel="nofollow noreferrer">http://127.0.0.1:18833</a>"</p>

<blockquote>
  <p>{"result":{"hex":"010000000227ed8477b4d0ab4d52bc31e0639f2f58665d9f7aff0a2aab229bba51af28ea5b000000008a4730440220279b45f812ebd1004ee041eb75a3f42657dce19bdba06b30b2d1b70f45e2590602201b06ecbbbf6fae0a3455d98ac2924cd6dc3022425a2f08c60ffb46e96dbdc8e9014104a84d304aa8963fbd36287e674f109827b6d6ea60d57a7d9357df03be1fcedb2c47475ca128b1a50408b7f584041ffd52d6b19aba5256e99dcdbbe2ed7373775dfffffffff302a856316c80cfbb5735c7a1fd5caad5b856206e2855e6f98bad5959778620010000008a47304402203b163fb30bf53c15e1b7d4ab8af17c3e79193f12d29b17d0a68afac8dc07f07b0220364d304ee4d3fcba82729ba5b011f99636e5633f66f5af224fd8ec5cd1850a44014104a84d304aa8963fbd36287e674f109827b6d6ea60d57a7d9357df03be1fcedb2c47475ca128b1a50408b7f584041ffd52d6b19aba5256e99dcdbbe2ed7373775dffffffff028096980000000000c9524104478f498fe3f6872a9559ae0fd5975bc44f500eed955a835027962099c333536f60b4e60383e6e1081efa0a76df1ef0aefb4da87ff0c8f12dab5da2969fc7b24e41044f09a164267c635c6991f7a96bc7901d035c07161a0074d719be723f6a9c50bc72b900092cffec5f3c3484dae35d04a5a2fa2e75f3a99e17577537c1227b44ba4104971e5b8b222fe47f742fa07d3327d36a6cd37088656ce29842ed82e1dc8bffaa81848b3219359fdf9d8b590d3af85cfff2d06d4b19fde5ed560b2c9caa5dd65653ae40196604000000001976a9148c1b30a7b5f8bd87c1cd8b8c4cb4f74345f1978a88ac00000000","txid":"6e2c5b6b2a926a7da2415ae55c701e83d6e7bc46bad9bc23b5f9c7ef1ae26998","hash":"6e2c5b6b2a926a7da2415ae55c701e83d6e7bc46bad9bc23b5f9c7ef1ae26998","size":612,"vsize":612,"version":1,"locktime":0,"vin":[{"txid":"5bea28af51ba9b22ab2a0aff7a9f5d66582f9f63e031bc524dabd0b47784ed27","vout":0,"scriptSig":{"asm":"30440220279b45f812ebd1004ee041eb75a3f42657dce19bdba06b30b2d1b70f45e2590602201b06ecbbbf6fae0a3455d98ac2924cd6dc3022425a2f08c60ffb46e96dbdc8e9[ALL]
  04a84d304aa8963fbd36287e674f109827b6d6ea60d57a7d9357df03be1fcedb2c47475ca128b1a50408b7f584041ffd52d6b19aba5256e99dcdbbe2ed7373775d","hex":"4730440220279b45f812ebd1004ee041eb75a3f42657dce19bdba06b30b2d1b70f45e2590602201b06ecbbbf6fae0a3455d98ac2924cd6dc3022425a2f08c60ffb46e96dbdc8e9014104a84d304aa8963fbd36287e674f109827b6d6ea60d57a7d9357df03be1fcedb2c47475ca128b1a50408b7f584041ffd52d6b19aba5256e99dcdbbe2ed7373775d"},"sequence":4294967295},{"txid":"2086775959ad8bf9e655286e2056b8d5aa5cfda1c73557bbcf806c3156a802f3","vout":1,"scriptSig":{"asm":"304402203b163fb30bf53c15e1b7d4ab8af17c3e79193f12d29b17d0a68afac8dc07f07b0220364d304ee4d3fcba82729ba5b011f99636e5633f66f5af224fd8ec5cd1850a44[ALL]
  04a84d304aa8963fbd36287e674f109827b6d6ea60d57a7d9357df03be1fcedb2c47475ca128b1a50408b7f584041ffd52d6b19aba5256e99dcdbbe2ed7373775d","hex":"47304402203b163fb30bf53c15e1b7d4ab8af17c3e79193f12d29b17d0a68afac8dc07f07b0220364d304ee4d3fcba82729ba5b011f99636e5633f66f5af224fd8ec5cd1850a44014104a84d304aa8963fbd36287e674f109827b6d6ea60d57a7d9357df03be1fcedb2c47475ca128b1a50408b7f584041ffd52d6b19aba5256e99dcdbbe2ed7373775d"},"sequence":4294967295}],"vout":[{"value":0.10000000,"n":0,"scriptPubKey":{"asm":"2
  04478f498fe3f6872a9559ae0fd5975bc44f500eed955a835027962099c333536f60b4e60383e6e1081efa0a76df1ef0aefb4da87ff0c8f12dab5da2969fc7b24e
  044f09a164267c635c6991f7a96bc7901d035c07161a0074d719be723f6a9c50bc72b900092cffec5f3c3484dae35d04a5a2fa2e75f3a99e17577537c1227b44ba
  04971e5b8b222fe47f742fa07d3327d36a6cd37088656ce29842ed82e1dc8bffaa81848b3219359fdf9d8b590d3af85cfff2d06d4b19fde5ed560b2c9caa5dd656
  3
  OP_CHECKMULTISIG","hex":"524104478f498fe3f6872a9559ae0fd5975bc44f500eed955a835027962099c333536f60b4e60383e6e1081efa0a76df1ef0aefb4da87ff0c8f12dab5da2969fc7b24e41044f09a164267c635c6991f7a96bc7901d035c07161a0074d719be723f6a9c50bc72b900092cffec5f3c3484dae35d04a5a2fa2e75f3a99e17577537c1227b44ba4104971e5b8b222fe47f742fa07d3327d36a6cd37088656ce29842ed82e1dc8bffaa81848b3219359fdf9d8b590d3af85cfff2d06d4b19fde5ed560b2c9caa5dd65653ae","reqSigs":2,"type":"multisig","addresses":["1NiA6V8Ges2vEkSx11X5oo2aCyTsCv3XH3","18am8jUnBqru2jtQpQbE4LCywBWUPUooP1","1Fr1wwdwoNH3F7zFAvcWJte5vsacto3EXC"]}},{"value":0.73800000,"n":1,"scriptPubKey":{"asm":"OP_DUP
  OP_HASH160 8c1b30a7b5f8bd87c1cd8b8c4cb4f74345f1978a OP_EQUALVERIFY
  OP_CHECKSIG","hex":"76a9148c1b30a7b5f8bd87c1cd8b8c4cb4f74345f1978a88ac","reqSigs":1,"type":"pubkeyhash","addresses":["1DmpB4AxC8tee5cMNhEjxg4xcaXw9cmAen"]}}],"blockhash":"0000000000000a96fe9d4d61b19127548bfeb40f2aa972c41b7bf8dc09e2967b","confirmations":326412,"time":1329692179,"blocktime":1329692179},"error":null,"id":"a2e8f6b0-5c03-4315-a067-050a9adb6dfc"}</p>
</blockquote>

<p>How we can see:</p>

<p><strong>"type":"multisig","addresses":["1NiA6V8Ges2vEkSx11X5oo2aCyTsCv3XH3","18am8jUnBqru2jtQpQbE4LCywBWUPUooP1","1Fr1wwdwoNH3F7zFAvcWJte5vsacto3EXC"]</strong></p>

<p>I need same result - array of several P2PKH addresses and multisig type.</p>

<p>But <a href="https://bitcoin.org/en/developer-reference#createrawtransaction" rel="nofollow noreferrer">https://bitcoin.org/en/developer-reference#createrawtransaction</a> method does not allow directly set array of addresses for 1 output
in transaction - only 1 address.</p>

<hr>

<p>I created transactions with P2SH address, which was created with createmultisig function:</p>

<p>user@workstation:/home/username$ bitcoin-cli createmultisig 1 '''["1BdxBor4JG76RKLAwJZfHC58fWbgidYukz","1MN3cT9Ro927h4kgpSZ5V7SfYjrwTysXv7"]'''
{
  "address": "3Jc4v7eo9rptPj4277c9cCjgJmWSQmBiwj",
  "redeemScript": "512102f2221ec0e4baa45633a1f10d41cb199d943ec448368b90d9c7982095fd926ffa2102a9132ba9b227c62cf02deaff00e974fd9bfbe96ed1947d9bf8c7af40c5c22dd752ae"
}</p>

<p>and after</p>

<p>bitcoin-cli createrawtransaction '''[{"txid" : "4989efcec28faedc86ee309a0cb1ba1319987d5c214fcb39d709538576e79342","vout" : 1,"sequence":1}]''' '{ "3Jc4v7eo9rptPj4277c9cCjgJmWSQmBiwj": 0.00005500,"12S42ZEw2741DHrivgZHLfX8M58mxb7bFy": 0.01102678}' 
after signed transaction and sent into the network</p>

<p>hash of transaction: </p>

<p>d1789305f1ae4a39c045e0c67a024048cda0990297dc863e4caac546c6c32b86</p>

<p>raw: </p>

<pre><code>02000000014293e776855309d739cb4f215c7d981913bab10c9a30ee86dcae8fc2ceef8949010000006a47304402200c7a7e89dc37a457c9070b928619b0ebed9b9a8fcbe1ec0ae9a06ecd695279eb0220015f1898c527e38319818f9939822b0ade1c1c508cf7d1215bf2b99905b1fcff01210267af6c6bf4ae6e37f019fbfbc7df70acf48663adbf19161bd874f3babd6bf15c01000000027c1500000000000017a914b98a8e7f0375003d5537ff8489fcf9c4ad98f2358756d31000000000001976a9140fb50d2ec6bb62bd690bb55142101ca28a678be188ac00000000
</code></pre>

<p>But in the result of json-rpc method getrawtransaction I see 
"scriptPubKey":
{
"asm":"OP_HASH160 b98a8e7f0375003d5537ff8489fcf9c4ad98f235 OP_EQUAL",
"hex":"a914b98a8e7f0375003d5537ff8489fcf9c4ad98f23587",
"reqSigs":1,
"type":"scripthash",
"addresses":["3Jc4v7eo9rptPj4277c9cCjgJmWSQmBiwj"]
}</p>

<p>meanwhile I need type: "multisig" and array of several P2PKH addresses, no 1 P2SH address.</p>

<hr>

<p>Another attemption: I used addmultisigaddress function
user@workstation:/home/username$ bitcoin-cli addmultisigaddress 2 '["1BdxBor4JG76RKLAwJZfHC58fWbgidYukz","1MN3cT9Ro927h4kgpSZ5V7SfYjrwTysXv7"]'
3P6sVMdtiqSwPuruSMguJQmmvFba3groVh</p>

<p>user@workstation:/home/username$ bitcoin-cli validateaddress 3P6sVMdtiqSwPuruSMguJQmmvFba3groVh
{
  "isvalid": true,
  "address": "3P6sVMdtiqSwPuruSMguJQmmvFba3groVh",
  "scriptPubKey": "a914eadd957f6e1c6f4e71f9bd0a8632d8e3a61af43f87",
  "ismine": true,
  "iswatchonly": false,
  "isscript": true,
  "script": "multisig",
  "hex": "522102f2221ec0e4baa45633a1f10d41cb199d943ec448368b90d9c7982095fd926ffa2102a9132ba9b227c62cf02deaff00e974fd9bfbe96ed1947d9bf8c7af40c5c22dd752ae",
  "addresses": [
    "1BdxBor4JG76RKLAwJZfHC58fWbgidYukz",
    "1MN3cT9Ro927h4kgpSZ5V7SfYjrwTysXv7"
  ],
  "sigsrequired": 2,
  "account": ""
}
bitcoin-cli createrawtransaction '''[{"txid" : "d1789305f1ae4a39c045e0c67a024048cda0990297dc863e4caac546c6c32b86","vout" : 1,"sequence":1}]''' '{ "3P6sVMdtiqSwPuruSMguJQmmvFba3groVh": 0.00005500,"12S42ZEw2741DHrivgZHLfX8M58mxb7bFy": 0.01}' 
after signed transaction and sent into the network</p>

<p>hash of transaction: </p>

<p>cbf1bba98082f23889f79364ae146b6cbbfb1767a20c0e2bc210fee43561ee1d</p>

<p>raw: </p>

<blockquote>
  <p>0200000001862bc3c646c5aa4c3e86dc970299a0cd4840027ac6e045c0394aaef1059378d1010000006a47304402205ad43bb4c6e07387a62d5c1859f48869b21cd069fe9bda93b05466e0da42228102202d3d894fae7a11b3369c5616eebbc6b3ae00001ed71f0b0d8e3324ef2d8e5c9101210267af6c6bf4ae6e37f019fbfbc7df70acf48663adbf19161bd874f3babd6bf15c01000000027c1500000000000017a914eadd957f6e1c6f4e71f9bd0a8632d8e3a61af43f8740420f00000000001976a9140fb50d2ec6bb62bd690bb55142101ca28a678be188ac00000000</p>
</blockquote>

<p>But in the result of json-rpc method getrawtransaction I see again
scriptPubKey":
{
"asm":"OP_HASH160 eadd957f6e1c6f4e71f9bd0a8632d8e3a61af43f OP_EQUAL",
"hex":"a914eadd957f6e1c6f4e71f9bd0a8632d8e3a61af43f87",
"reqSigs":1,
"type":"scripthash",
"addresses":["3P6sVMdtiqSwPuruSMguJQmmvFba3groVh"]
}</p>

<p>meanwhile I need type: "multisig" and array of several P2PKH addresses, no 1 P2SH address.</p>

<hr>

<p>What I am doing wrong?</p>

<multi-signature><output>
How to create raw bitcoin transaction with multisig type of output scriptPubKey
Daniil Kamenskiy
# How to create raw bitcoin transaction with multisig type of output scriptPubKey

(Asked by: username_0 on 2017-11-11)

I need to send money in one transaction to 2 addresses so that any of them can spend it.
In other words - I need to create same transaction as here
<https://www.blocktrail.com/BTC/tx/6e2c5b6b2a926a7da2415ae55c701e83d6e7bc46bad9bc23b5f9c7ef1ae26998>
(
hex of raw transaction is

```
010000000227ed8477b4d0ab4d52bc31e0639f2f58665d9f7aff0a2aab229bba51af28ea5b000000008a4730440220279b45f812ebd1004ee041eb75a3f42657dce19bdba06b30b2d1b70f45e2590602201b06ecbbbf6fae0a3455d98ac2924cd6dc3022425a2f08c60ffb46e96dbdc8e9014104a84d304aa8963fbd36287e674f109827b6d6ea60d57a7d9357df03be1fcedb2c47475ca128b1a50408b7f584041ffd52d6b19aba5256e99dcdbbe2ed7373775dfffffffff302a856316c80cfbb5735c7a1fd5caad5b856206e2855e6f98bad5959778620010000008a47304402203b163fb30bf53c15e1b7d4ab8af17c3e79193f12d29b17d0a68afac8dc07f07b0220364d304ee4d3fcba82729ba5b011f99636e5633f66f5af224fd8ec5cd1850a44014104a84d304aa8963fbd36287e674f109827b6d6ea60d57a7d9357df03be1fcedb2c47475ca128b1a50408b7f584041ffd52d6b19aba5256e99dcdbbe2ed7373775dffffffff028096980000000000c9524104478f498fe3f6872a9559ae0fd5975bc44f500eed955a835027962099c333536f60b4e60383e6e1081efa0a76df1ef0aefb4da87ff0c8f12dab5da2969fc7b24e41044f09a164267c635c6991f7a96bc7901d035c07161a0074d719be723f6a9c50bc72b900092cffec5f3c3484dae35d04a5a2fa2e75f3a99e17577537c1227b44ba4104971e5b8b222fe47f742fa07d3327d36a6cd37088656ce29842ed82e1dc8bffaa81848b3219359fdf9d8b590d3af85cfff2d06d4b19fde5ed560b2c9caa5dd65653ae40196604000000001976a9148c1b30a7b5f8bd87c1cd8b8c4cb4f74345f1978a88ac00000000

```

)
with multisig type of scriptPubKey of output and array of destination addresses with 2 P2PKH (no 1 P2SH!) items.

curl --user USERNAME:PASSWORD --data-binary '{"method":"getrawtransaction","id":"a2e8f6b0-5c03-4315-a067-050a9adb6dfc","params":["6e2c5b6b2a926a7da2415ae55c701e83d6e7bc46bad9bc23b5f9c7ef1ae26998",1]}' "<http://127.0.0.1:18833>"

> {"result":{"hex":"010000000227ed8477b4d0ab4d52bc31e0639f2f58665d9f7aff0a2aab229bba51af28ea5b000000008a4730440220279b45f812ebd1004ee041eb75a3f42657dce19bdba06b30b2d1b70f45e2590602201b06ecbbbf6fae0a3455d98ac2924cd6dc3022425a2f08c60ffb46e96dbdc8e9014104a84d304aa8963fbd36287e674f109827b6d6ea60d57a7d9357df03be1fcedb2c47475ca128b1a50408b7f584041ffd52d6b19aba5256e99dcdbbe2ed7373775dfffffffff302a856316c80cfbb5735c7a1fd5caad5b856206e2855e6f98bad5959778620010000008a47304402203b163fb30bf53c15e1b7d4ab8af17c3e79193f12d29b17d0a68afac8dc07f07b0220364d304ee4d3fcba82729ba5b011f99636e5633f66f5af224fd8ec5cd1850a44014104a84d304aa8963fbd36287e674f109827b6d6ea60d57a7d9357df03be1fcedb2c47475ca128b1a50408b7f584041ffd52d6b19aba5256e99dcdbbe2ed7373775dffffffff028096980000000000c9524104478f498fe3f6872a9559ae0fd5975bc44f500eed955a835027962099c333536f60b4e60383e6e1081efa0a76df1ef0aefb4da87ff0c8f12dab5da2969fc7b24e41044f09a164267c635c6991f7a96bc7901d035c07161a0074d719be723f6a9c50bc72b900092cffec5f3c3484dae35d04a5a2fa2e75f3a99e17577537c1227b44ba4104971e5b8b222fe47f742fa07d3327d36a6cd37088656ce29842ed82e1dc8bffaa81848b3219359fdf9d8b590d3af85cfff2d06d4b19fde5ed560b2c9caa5dd65653ae40196604000000001976a9148c1b30a7b5f8bd87c1cd8b8c4cb4f74345f1978a88ac00000000","txid":"6e2c5b6b2a926a7da2415ae55c701e83d6e7bc46bad9bc23b5f9c7ef1ae26998","hash":"6e2c5b6b2a926a7da2415ae55c701e83d6e7bc46bad9bc23b5f9c7ef1ae26998","size":612,"vsize":612,"version":1,"locktime":0,"vin":[{"txid":"5bea28af51ba9b22ab2a0aff7a9f5d66582f9f63e031bc524dabd0b47784ed27","vout":0,"scriptSig":{"asm":"30440220279b45f812ebd1004ee041eb75a3f42657dce19bdba06b30b2d1b70f45e2590602201b06ecbbbf6fae0a3455d98ac2924cd6dc3022425a2f08c60ffb46e96dbdc8e9[ALL]
> 04a84d304aa8963fbd36287e674f109827b6d6ea60d57a7d9357df03be1fcedb2c47475ca128b1a50408b7f584041ffd52d6b19aba5256e99dcdbbe2ed7373775d","hex":"4730440220279b45f812ebd1004ee041eb75a3f42657dce19bdba06b30b2d1b70f45e2590602201b06ecbbbf6fae0a3455d98ac2924cd6dc3022425a2f08c60ffb46e96dbdc8e9014104a84d304aa8963fbd36287e674f109827b6d6ea60d57a7d9357df03be1fcedb2c47475ca128b1a50408b7f584041ffd52d6b19aba5256e99dcdbbe2ed7373775d"},"sequence":4294967295},{"txid":"2086775959ad8bf9e655286e2056b8d5aa5cfda1c73557bbcf806c3156a802f3","vout":1,"scriptSig":{"asm":"304402203b163fb30bf53c15e1b7d4ab8af17c3e79193f12d29b17d0a68afac8dc07f07b0220364d304ee4d3fcba82729ba5b011f99636e5633f66f5af224fd8ec5cd1850a44[ALL]
> 04a84d304aa8963fbd36287e674f109827b6d6ea60d57a7d9357df03be1fcedb2c47475ca128b1a50408b7f584041ffd52d6b19aba5256e99dcdbbe2ed7373775d","hex":"47304402203b163fb30bf53c15e1b7d4ab8af17c3e79193f12d29b17d0a68afac8dc07f07b0220364d304ee4d3fcba82729ba5b011f99636e5633f66f5af224fd8ec5cd1850a44014104a84d304aa8963fbd36287e674f109827b6d6ea60d57a7d9357df03be1fcedb2c47475ca128b1a50408b7f584041ffd52d6b19aba5256e99dcdbbe2ed7373775d"},"sequence":4294967295}],"vout":[{"value":0.10000000,"n":0,"scriptPubKey":{"asm":"2
> 04478f498fe3f6872a9559ae0fd5975bc44f500eed955a835027962099c333536f60b4e60383e6e1081efa0a76df1ef0aefb4da87ff0c8f12dab5da2969fc7b24e
> 044f09a164267c635c6991f7a96bc7901d035c07161a0074d719be723f6a9c50bc72b900092cffec5f3c3484dae35d04a5a2fa2e75f3a99e17577537c1227b44ba
> 04971e5b8b222fe47f742fa07d3327d36a6cd37088656ce29842ed82e1dc8bffaa81848b3219359fdf9d8b590d3af85cfff2d06d4b19fde5ed560b2c9caa5dd656
> 3
> OP\_CHECKMULTISIG","hex":"524104478f498fe3f6872a9559ae0fd5975bc44f500eed955a835027962099c333536f60b4e60383e6e1081efa0a76df1ef0aefb4da87ff0c8f12dab5da2969fc7b24e41044f09a164267c635c6991f7a96bc7901d035c07161a0074d719be723f6a9c50bc72b900092cffec5f3c3484dae35d04a5a2fa2e75f3a99e17577537c1227b44ba4104971e5b8b222fe47f742fa07d3327d36a6cd37088656ce29842ed82e1dc8bffaa81848b3219359fdf9d8b590d3af85cfff2d06d4b19fde5ed560b2c9caa5dd65653ae","reqSigs":2,"type":"multisig","addresses":["1NiA6V8Ges2vEkSx11X5oo2aCyTsCv3XH3","18am8jUnBqru2jtQpQbE4LCywBWUPUooP1","1Fr1wwdwoNH3F7zFAvcWJte5vsacto3EXC"]}},{"value":0.73800000,"n":1,"scriptPubKey":{"asm":"OP\_DUP
> OP\_HASH160 8c1b30a7b5f8bd87c1cd8b8c4cb4f74345f1978a OP\_EQUALVERIFY
> OP\_CHECKSIG","hex":"76a9148c1b30a7b5f8bd87c1cd8b8c4cb4f74345f1978a88ac","reqSigs":1,"type":"pubkeyhash","addresses":["1DmpB4AxC8tee5cMNhEjxg4xcaXw9cmAen"]}}],"blockhash":"0000000000000a96fe9d4d61b19127548bfeb40f2aa972c41b7bf8dc09e2967b","confirmations":326412,"time":1329692179,"blocktime":1329692179},"error":null,"id":"a2e8f6b0-5c03-4315-a067-050a9adb6dfc"}

How we can see:

**"type":"multisig","addresses":["1NiA6V8Ges2vEkSx11X5oo2aCyTsCv3XH3","18am8jUnBqru2jtQpQbE4LCywBWUPUooP1","1Fr1wwdwoNH3F7zFAvcWJte5vsacto3EXC"]**

I need same result - array of several P2PKH addresses and multisig type.

But <https://bitcoin.org/en/developer-reference#createrawtransaction> method does not allow directly set array of addresses for 1 output
in transaction - only 1 address.

---

I created transactions with P2SH address, which was created with createmultisig function:

user@workstation:/home/username$ bitcoin-cli createmultisig 1 '''["1BdxBor4JG76RKLAwJZfHC58fWbgidYukz","1MN3cT9Ro927h4kgpSZ5V7SfYjrwTysXv7"]'''
{
"address": "3Jc4v7eo9rptPj4277c9cCjgJmWSQmBiwj",
"redeemScript": "512102f2221ec0e4baa45633a1f10d41cb199d943ec448368b90d9c7982095fd926ffa2102a9132ba9b227c62cf02deaff00e974fd9bfbe96ed1947d9bf8c7af40c5c22dd752ae"
}

and after

bitcoin-cli createrawtransaction '''[{"txid" : "4989efcec28faedc86ee309a0cb1ba1319987d5c214fcb39d709538576e79342","vout" : 1,"sequence":1}]''' '{ "3Jc4v7eo9rptPj4277c9cCjgJmWSQmBiwj": 0.00005500,"12S42ZEw2741DHrivgZHLfX8M58mxb7bFy": 0.01102678}'
after signed transaction and sent into the network

hash of transaction:

d1789305f1ae4a39c045e0c67a024048cda0990297dc863e4caac546c6c32b86

raw:

```
02000000014293e776855309d739cb4f215c7d981913bab10c9a30ee86dcae8fc2ceef8949010000006a47304402200c7a7e89dc37a457c9070b928619b0ebed9b9a8fcbe1ec0ae9a06ecd695279eb0220015f1898c527e38319818f9939822b0ade1c1c508cf7d1215bf2b99905b1fcff01210267af6c6bf4ae6e37f019fbfbc7df70acf48663adbf19161bd874f3babd6bf15c01000000027c1500000000000017a914b98a8e7f0375003d5537ff8489fcf9c4ad98f2358756d31000000000001976a9140fb50d2ec6bb62bd690bb55142101ca28a678be188ac00000000

```

But in the result of json-rpc method getrawtransaction I see
"scriptPubKey":
{
"asm":"OP\_HASH160 b98a8e7f0375003d5537ff8489fcf9c4ad98f235 OP\_EQUAL",
"hex":"a914b98a8e7f0375003d5537ff8489fcf9c4ad98f23587",
"reqSigs":1,
"type":"scripthash",
"addresses":["3Jc4v7eo9rptPj4277c9cCjgJmWSQmBiwj"]
}

meanwhile I need type: "multisig" and array of several P2PKH addresses, no 1 P2SH address.

---

Another attemption: I used addmultisigaddress function
user@workstation:/home/username$ bitcoin-cli addmultisigaddress 2 '["1BdxBor4JG76RKLAwJZfHC58fWbgidYukz","1MN3cT9Ro927h4kgpSZ5V7SfYjrwTysXv7"]'
3P6sVMdtiqSwPuruSMguJQmmvFba3groVh

user@workstation:/home/username$ bitcoin-cli validateaddress 3P6sVMdtiqSwPuruSMguJQmmvFba3groVh
{
"isvalid": true,
"address": "3P6sVMdtiqSwPuruSMguJQmmvFba3groVh",
"scriptPubKey": "a914eadd957f6e1c6f4e71f9bd0a8632d8e3a61af43f87",
"ismine": true,
"iswatchonly": false,
"isscript": true,
"script": "multisig",
"hex": "522102f2221ec0e4baa45633a1f10d41cb199d943ec448368b90d9c7982095fd926ffa2102a9132ba9b227c62cf02deaff00e974fd9bfbe96ed1947d9bf8c7af40c5c22dd752ae",
"addresses": [
"1BdxBor4JG76RKLAwJZfHC58fWbgidYukz",
"1MN3cT9Ro927h4kgpSZ5V7SfYjrwTysXv7"
],
"sigsrequired": 2,
"account": ""
}
bitcoin-cli createrawtransaction '''[{"txid" : "d1789305f1ae4a39c045e0c67a024048cda0990297dc863e4caac546c6c32b86","vout" : 1,"sequence":1}]''' '{ "3P6sVMdtiqSwPuruSMguJQmmvFba3groVh": 0.00005500,"12S42ZEw2741DHrivgZHLfX8M58mxb7bFy": 0.01}'
after signed transaction and sent into the network

hash of transaction:

cbf1bba98082f23889f79364ae146b6cbbfb1767a20c0e2bc210fee43561ee1d

raw:

> 0200000001862bc3c646c5aa4c3e86dc970299a0cd4840027ac6e045c0394aaef1059378d1010000006a47304402205ad43bb4c6e07387a62d5c1859f48869b21cd069fe9bda93b05466e0da42228102202d3d894fae7a11b3369c5616eebbc6b3ae00001ed71f0b0d8e3324ef2d8e5c9101210267af6c6bf4ae6e37f019fbfbc7df70acf48663adbf19161bd874f3babd6bf15c01000000027c1500000000000017a914eadd957f6e1c6f4e71f9bd0a8632d8e3a61af43f8740420f00000000001976a9140fb50d2ec6bb62bd690bb55142101ca28a678be188ac00000000

But in the result of json-rpc method getrawtransaction I see again
scriptPubKey":
{
"asm":"OP\_HASH160 eadd957f6e1c6f4e71f9bd0a8632d8e3a61af43f OP\_EQUAL",
"hex":"a914eadd957f6e1c6f4e71f9bd0a8632d8e3a61af43f87",
"reqSigs":1,
"type":"scripthash",
"addresses":["3P6sVMdtiqSwPuruSMguJQmmvFba3groVh"]
}

meanwhile I need type: "multisig" and array of several P2PKH addresses, no 1 P2SH address.

---

What I am doing wrong?

**Tags:** multi-signature, output


---

## 1 answers

### Answer by username_1 on 2017-11-11. Score: 1

I try to provide a (partial) answer: I thin you are not doing anything wrong... there are two ways of creating multisig tx. The "old" way as with your link from blocktrail, and the "new" way as per your following text. The old way had two or three disadvantages: it bloats the blockchain from the beginning, the fees are high at the beginning, and it discloses the possible signer's pubkeys. In this case the 3 non compressed pubkeys have each 65 bytes, so 200 bytes on the blockchain...

The new multisig via a P2SH construct basically hashes the spending logic (also called the **redeem script**: 2 3 CHECKMULTISIG), and base58check encoded provides a "P2SH address" (beginning with a "3"). This hash is then only 20 Bytes long, non-reversible (you can't see which are the pubkeys), and the fee for bringing this tx to the blockchain remain low. Of course, at the very end, the spending this tx requires to disclose and pay the higher fees.

Unless you don't have a very, very specific use case, do you think it is impossible to use the newer logic?
I found further description in Andreas book "Mastering Bitcoin" in Chapter 7, page 149ff - it is also online available.

> **Comments:**
> **username_0**: username_1, thank you so much for the answer. I have mentioned very very specific use case, so if you can navigate me how to create bitcoin transaction with multisig-output (with array of P2PKH addresses) using createrawtransaction-method (or with php/js/.../language) - please do it ). Unfortunately I did not found this info in Mastering Bitcoin.  
> **username_1**: this looks more difficult than I thought. Keyword is probably "raw multisig", quickly searching through the forum reveals an answer from Pieter (https://bitcoin.stackexchange.com/questions/46447/with-what-number-do-multisig-addresses-non-p2sh-start/46448#46448), which discourages the usage of raw multisig. Probably BIP11 provide more info. This post https://bitcoin.stackexchange.com/questions/3712/how-can-i-create-a-multi-signature-2-of-3-transaction/10593#10593 mentions the use of an "SX Library", but I have never checked any libraries for this...  
> **username_1**: and here is the link to the first edition from Andreas: http://chimera.labs.oreilly.com/books/1234000001802/ch05.html#multisig and bitcoin has this link: https://bitcoinj.github.io/working-with-contracts  

---

