Pages:
Author

Topic: [WTB]Tutorial on how to make non-standard outputs - page 3. (Read 4661 times)

sr. member
Activity: 475
Merit: 252
Code:
01000000 // version
01 // number of inputs
9f9b54077ebaf05f41c38a22fd2269a481089c922c5cf6b4a241cbf28e29e683 // hash of the tx you gave me, reversed
00000000 // your input was first, so index is 0
00 // this is just here for when you sign. placeholder.
ffffffff // this is sequence for nLockTime
01 // this is output count
18310c0000000000 // This says the output is worth 0.00799 BTC (leaving 0.00001 BTC in fees, because the input is worth 0.008 BTC)
23 // The length of the output is 35 bytes
a8 // OP_SHA256
20 // push 32 bytes on the stack
931d236179670b00348f87bea4199fe18297f0ef26da02c7542bd54d5b7836d8 // this is the 32 bytes that are pushed (your hash) REPLACE WITH A HASH OF SOMETHING ONLY YOU KNOW!
87 // OP_EQUAL
00000000 // nLockTime... leave at 0

clumped all together.

Code:
01000000019f9b54077ebaf05f41c38a22fd2269a481089c922c5cf6b4a241cbf28e29e6830000000000ffffffff0118310c000000000023a820931d236179670b00348f87bea4199fe18297f0ef26da02c7542bd54d5b7836d88700000000

This is what you use for signrawtransaction.

I will replace the sha256 hash with XXX so you can see where to put it.

Code:
01000000019f9b54077ebaf05f41c38a22fd2269a481089c922c5cf6b4a241cbf28e29e6830000000000ffffffff0118310c000000000023a820XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX8700000000
hero member
Activity: 935
Merit: 1002
Didn't really understood. Can you make a formula like for example on OP_RETURN it's
Code:
0100000001AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABB00000000ffffffff0100000000000000004e6a4cCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC00000000
and how do I do it on https://blockchain.info/address/1CTnGM9uapUSg8wvdXkpJPG2nbfGcxytPF
sr. member
Activity: 475
Merit: 252
Step 1: Follow the OP_RETURN tutorial up until you get to the part where you are making the OP_RETURN output. (as everything else is the same)
Step 2: Prepare your hash. (so figure out what you will hash, hash it, and get the hash in hex)
Step 3: Create the output as follows:

Code:
23   // the number 35 in hex... this means "THE OUTPUT SCRIPT IS 35 BYTES TOTAL"

a8   // This is the OP for OP_SHA256.... do not confuse with OP_HASH256 (which is 2 sha256s in a row)
20   // the number 32 in hex... means "PUSH 32 BYTES ONTO STACK"
931d236179670b00348f87bea4199fe18297f0ef26da02c7542bd54d5b7836d8   // My SHA256 hash of the secret I will need to redeem it.
87  // This is OP_EQUAL

Also, one note: The scriptlen is in VarInt format
https://en.bitcoin.it/wiki/Protocol_specification#Variable_length_integer

However, pushdata inside the actual script is in PUSHDATA OP format:
(Up to 75 bytes is just that number in hex, above that you need to add a byte before the length and represent it in a little endian multi-byte integer.)
https://en.bitcoin.it/wiki/Script#Constants


Here's how to redeem:

My secret was gibberish:
Code:
adfladsfhuifo8ry8fh4u4et4e5tsg415et458s43etg41s35e4g3541r35g143sg54s385g41s535e1g435s4g;.:;,[@snrltgnjslenjrgklsnleignilsnklgnslnglk

But I need this in hex format, so I convert each ASCII byte to hex to get:
Code:
6164666c61647366687569666f38727938666834753465743465357473673431356574343538733433657467343173333565346733353431723335673134337367353473333835673431733533356531673433357334673b2e3a3b2c5b40736e726c74676e6a736c656e6a72676b6c736e6c6569676e696c736e6b6c676e736c6e676c6b

That's 132 bytes total.

So my input script that spends the output would be:
Code:
86  // This input script is 134 bytes long... VarInt is one byte up to fc.

4c84  // 4c is "the next byte is a PUSHDATA byte.... 84 is "132" in hex...
6164666c61647366687569666f38727938666834753465743465357473673431356574343538733433657467343173333565346733353431723335673134337367353473333835673431733533356531673433357334673b2e3a3b2c5b40736e726c74676e6a736c656e6a72676b6c736e6c6569676e696c736e6b6c676e736c6e676c6b  // My secret
hero member
Activity: 935
Merit: 1002
Moved from Services to Development & Technical Discussion.
hero member
Activity: 935
Merit: 1002
Hi I would like to buy a step by step tutorial on how to make OP_TRUE and OP_EQUAL(tx like this https://blockchain.info/tx/a4bfa8ab6435ae5f25dae9d89e4eb67dfa94283ca751f393c1ddc5a837bbc31b) non-standard outputs on bitcoind or bitcoinqt debug window(raw transaction).An example of how to make OP_RETURN tutorial https://bitcointalksearch.org/topic/m.5302717

Will pay a little amount of 0.01BTC for it.
Pages:
Jump to: