Pages:
Author

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

hero member
Activity: 793
Merit: 1026
I just created this transaction
Code:
01000000
01
b25674cb772bc4a788a9da826609672175b9f02bab3b252446b2357f01115d9f
00000000
1976a9147db9fbceb81b5dc4cbcc84ab6b0cd9e57d1e392588ac
fffffff
01
204E000000000000
23
a8
20
9c0f28fc262f58e9ad1f021ab707662cad96c754ecf3ad43be5c26e49c081233
87
00000000
I tried to sign it with the corresponding private key of 12ZMT7Qn2rysM3XKxkSBrVfzdXXufoS13t and it failed why? I need help ASAP.

The input script is wrong.  1976a9147db9fbceb81b5dc4cbcc84ab6b0cd9e57d1e392588ac corresponds to the address 1CTnGM9uapUSg8wvdXkpJPG2nbfGcxytPF, but the input you are referencing is the address 12ZMT7Qn2rysM3XKxkSBrVfzdXXufoS13t, so you need to change the 1976.... to that address, which would be 1976a914111681ec5a5138c0e2348a346e90db822d2c70dc88ac.

Additionally, you understand you aren't required to SIGN anything for that output, right?  All somebody needs to do is know the reverse of that hash.  There is no signature required to claim that money.  If the data that creates that hash is a public key, you need to change

OP_SHA256 ... OP_EQUAL

to

OP_DUP OP_SHA256 ... OP_EQUALVERIFY OP_CHECKSIG

if you want a public key and its signature required.

Also, I would recommend OP_HASH256, aka double sha256, instead of a single sha256 for your output.  For all the same reasons normal bitcoin mining stuff does double sha256.  So change the a8 to aa and the hash to d90169532083120128c4e2c0e5ad29ee3d4aff5cb7d65a54384fddd65a6de727

(Although now with that hash being publicly known, it doesn't really matter, but in the future I'd recommend double sha256.)

Edit:  Sorry, I had only finished page 1, and didn't see other people had corrected the input error.
newbie
Activity: 2
Merit: 0
I wrote this tutorial awhile back on writing nonstandard transactions. I have done all sorts of weird ones.

http://pastedown.ctrl-c.us/#_kbv9v7Bt2tAXE4y_XJjerp3HYE.markdown
hero member
Activity: 935
Merit: 1002
(I think maybe you copy pasted something from earlier, or input something wrong into some tool you are using.)
Yes I did thank you very much.
Why can't all these tests be done on testnet?
Because the BTC that I get from signature campaigns is used for these kind of tests.
legendary
Activity: 1260
Merit: 1019
Yes.
The second error is (as said dabura667)
that the script for redeeming output #0 of
https://blockchain.info/tx/9f5d11017f35b24624253bab2bf0b9752167096682daa988a7c42b77cb7456b2
before signing (line #5)

should be
Code:
1976a914 111681ec5a5138c0e2348a346e90db822d2c70dc 88ac

not
Code:
1976a914 7db9fbceb81b5dc4cbcc84ab6b0cd9e57d1e3925 88ac
sr. member
Activity: 475
Merit: 252
I just created this transaction
Code:
01000000
01
b25674cb772bc4a788a9da826609672175b9f02bab3b252446b2357f01115d9f
00000000
1976a9147db9fbceb81b5dc4cbcc84ab6b0cd9e57d1e392588ac
fffffff
01
204E000000000000
23
a8
20
9c0f28fc262f58e9ad1f021ab707662cad96c754ecf3ad43be5c26e49c081233
87
00000000
I tried to sign it with the corresponding private key of 12ZMT7Qn2rysM3XKxkSBrVfzdXXufoS13t and it failed why? I need help ASAP.

https://blockchain.info/address/1CTnGM9uapUSg8wvdXkpJPG2nbfGcxytPF
Check the Hash 160 part of this address's page?
Look familiar?
Line 5 of your transaction is using the scriptpubkey for 1CTnGM9uapUSg8wvdXkpJPG2nbfGcxytPF for some reason...

(I think maybe you copy pasted something from earlier, or input something wrong into some tool you are using.)

Your transaction SHOULD be the following:
Code:
01000000
01
b25674cb772bc4a788a9da826609672175b9f02bab3b252446b2357f01115d9f
00000000
1976a914111681ec5a5138c0e2348a346e90db822d2c70dc88ac
fffffff
01
204E000000000000
23
a8
20
9c0f28fc262f58e9ad1f021ab707662cad96c754ecf3ad43be5c26e49c081233
87
00000000

Then you just need to be absolutely certain that the private key you're using to sign is the key for 12ZMT7Qn2rysM3XKxkSBrVfzdXXufoS13t and you should be good to go.

Note: however, your transaction has 0 fees attached... Though, looking at your mess of a transaction history, I won't bother... Why can't all these tests be done on testnet?
hero member
Activity: 935
Merit: 1002
Quote
I tried to sign it with the corresponding private key of 12ZMT7Qn2rysM3XKxkSBrVfzdXXufoS13t and it failed why? I need help ASAP.

There is at least one error in line #6
only 7 'f' but should be 8
Changed from 7 to 8 but still when I tried to sign it returned me the same hash(unsigned one).
legendary
Activity: 1260
Merit: 1019
Quote
I tried to sign it with the corresponding private key of 12ZMT7Qn2rysM3XKxkSBrVfzdXXufoS13t and it failed why? I need help ASAP.

There is at least one error in line #6
only 7 'f' but should be 8
hero member
Activity: 935
Merit: 1002
I just created this transaction
Code:
01000000
01
b25674cb772bc4a788a9da826609672175b9f02bab3b252446b2357f01115d9f
00000000
1976a9147db9fbceb81b5dc4cbcc84ab6b0cd9e57d1e392588ac
fffffff
01
204E000000000000
23
a8
20
9c0f28fc262f58e9ad1f021ab707662cad96c754ecf3ad43be5c26e49c081233
87
00000000
I tried to sign it with the corresponding private key of 12ZMT7Qn2rysM3XKxkSBrVfzdXXufoS13t and it failed why? I need help ASAP.
hero member
Activity: 793
Merit: 1026
Were you able to accomplish what you wanted to accomplish?  In this last post, the first input needs to sign the double-sha256 hash of:

Code:
0100000002ab39b37e4ab8d55dc043998d69c537c8c2fd6f588c12a81887d437bcf3261dac000000001976a914c44ceea4b4738e74483219e9af1435b7a0e8127788acffffffffab39b37e4ab8d55dc043998d69c537c8c2fd6f588c12a81887d437bcf3261dac0100000000ffffffff0100350c00000000001976a914c44ceea4b4738e74483219e9af1435b7a0e8127788ac0000000001000000

and the second key needs to sign the double-sha256 of

Code:
0100000002ab39b37e4ab8d55dc043998d69c537c8c2fd6f588c12a81887d437bcf3261dac0000000000ffffffffab39b37e4ab8d55dc043998d69c537c8c2fd6f588c12a81887d437bcf3261dac010000001976a9147db9fbceb81b5dc4cbcc84ab6b0cd9e57d1e392588acffffffff0100350c00000000001976a914c44ceea4b4738e74483219e9af1435b7a0e8127788ac0000000001000000

Notice that in both of them, the input that is not the one that's doing the signing is always set to 00, and then the signature type (SIGHASH_ALL aka 01) is appended to the end (01000000 -- aka 00000001 but reversed so the 01 is the left-most byte).

So the unsigned transaction that you are given to put on the website to sign is where all inputs are set to 00 and the signature type isn't on the end.  Which looks like this:

Code:
0100000002ab39b37e4ab8d55dc043998d69c537c8c2fd6f588c12a81887d437bcf3261dac0000000000ffffffffab39b37e4ab8d55dc043998d69c537c8c2fd6f588c12a81887d437bcf3261dac0100000000ffffffff0100350c00000000001976a914c44ceea4b4738e74483219e9af1435b7a0e8127788ac00000000

So if you sign that separately with each and then in each position swap the 00 with the sig+pubkey, which will likely be:

[8a or 8b, the length of the sig+pubkey combo] followed by
[47 or 48, the length of the signature]
[30.......01, the DER signature, which will be 71 or 72 bytes long, ending in 01 aka SIGHASH_ALL] followed by
[41, the length of the uncompressed pubkey] followed by
[04......., the uncompressed pubkey]

So you swap each 00 with each key's sig+key data in the format above.

You probably already know this, because the last code-quote in your last post there looks correct syntactically, but the signatures just don't verify against the tx.
hero member
Activity: 935
Merit: 1002
Went to bitcoin core typed createrawtransaction
Code:
"{\"1Jtwbwd8xtiU1tjbRyrhuMA5k6RFdHjVun\":0.008}"]createrawtransaction
"[
{\"txid\":\"ac1d26f3bc37d48718a8128c586ffdc2c837c5698d9943c05dd5b84a7eb339ab\",\"vout\":0},
{\"txid\":\"ac1d26f3bc37d48718a8128c586ffdc2c837c5698d9943c05dd5b84a7eb339ab\",\"vout\":1}
]"
"{\"1Jtwbwd8xtiU1tjbRyrhuMA5k6RFdHjVun\":0.008}"
Got
Code:
0100000002ab39b37e4ab8d55dc043998d69c537c8c2fd6f588c12a81887d437bcf3261dac0000000000ffffffffab39b37e4ab8d55dc043998d69c537c8c2fd6f588c12a81887d437bcf3261dac0100000000ffffffff0100350c00000000001976a914c44ceea4b4738e74483219e9af1435b7a0e8127788ac00000000
Went to coinb.in signed with one key copied the generated data and signed it with the other key, got
Code:
0100000002ab39b37e4ab8d55dc043998d69c537c8c2fd6f588c12a81887d437bcf3261dac000000008a47304402203a7bbd4960e7d09984de939e8a58c909342925bc4632256605e6a8769b85102202203d5ee29c7d3146312d49a5951e8d176d3db62cba37dda4fe293781b97b1b12a8014104d79737e9137e54a6ed4d3f6ccabb2a2232bc0020477c911f0d7d74db62d6f7b2f6fdd88457e6c408033edc7b12539584d42c8acaefff6347165f24f0abbcb9c2ffffffffab39b37e4ab8d55dc043998d69c537c8c2fd6f588c12a81887d437bcf3261dac010000008a47304402203a7bbd4960e7d09984de939e8a58c909342925bc4632256605e6a8769b85102202203d5ee29c7d3146312d49a5951e8d176d3db62cba37dda4fe293781b97b1b12a8014104d79737e9137e54a6ed4d3f6ccabb2a2232bc0020477c911f0d7d74db62d6f7b2f6fdd88457e6c408033edc7b12539584d42c8acaefff6347165f24f0abbcb9c2ffffffff0100350c00000000001976a914c44ceea4b4738e74483219e9af1435b7a0e8127788ac00000000
tried to send it and failed
Code:
Input signature 0 invalid.
Input signature 1 invalid.
I tried to replace the placeholder(in the first stage) from 0 to 1976a9147db9fbceb81b5dc4cbcc84ab6b0cd9e57d1e392588ac than the ending result was
Code:
0100000002ab39b37e4ab8d55dc043998d69c537c8c2fd6f588c12a81887d437bcf3261dac000000008a47304402207e3644cc77d35d91a3b8832fd848e9db8478148c46c879c5cc6bdbcba5cb431a022056cceebf27ae1018c48029050b9c54ad3858b75b64d651c2b1c9e35a7cfae210014104d79737e9137e54a6ed4d3f6ccabb2a2232bc0020477c911f0d7d74db62d6f7b2f6fdd88457e6c408033edc7b12539584d42c8acaefff6347165f24f0abbcb9c2ffffffffab39b37e4ab8d55dc043998d69c537c8c2fd6f588c12a81887d437bcf3261dac010000008b483045022100830735184d667729fbdb150a6042a5b7606d426fcd9f614014e6e351be2e13db022028f77a014556347be4a15a92c0ba96a5929b3e302c217e5a3a80f45568a32e09014104d79737e9137e54a6ed4d3f6ccabb2a2232bc0020477c911f0d7d74db62d6f7b2f6fdd88457e6c408033edc7b12539584d42c8acaefff6347165f24f0abbcb9c2ffffffff0100350c00000000001976a914c44ceea4b4738e74483219e9af1435b7a0e8127788ac00000000
but still got Input signature 0 invalid. What did I did wrong?

I was signing with coinb.in and no I will not try to sync it with bitcoin core as it would take me about 2(and maybe more) days to sync it(without turning the pc off)
legendary
Activity: 1260
Merit: 1019
Quote
Didn't understood it. Especially the part where you have to make a digest of the tx.

OK, I'll try to explain.
May be there will be errors in my explanation, because I do not want to check with a compiler all steps.
I was wrong in previous message. You should not remove scriptSig.

1) Just create a digest of your data - sha256 ( sha256 ( your-raw-transaction-in-binary-representation-concatenated-with-SIGHASH_ALL ) )
2) Take your favorite ECDSA library and sign this digest with your private keys
3) Create new scriptSig: OP_FALSE signature-of-privkey1 signature-of-privkey2.... signature-of-privkeyN
where every signature is concatenated with byte 0x01 (SIGHASH_ALL)
4) Append bip16 msig string to a scriptSig
5) replace scriptSig bytes 76a9147db9fbceb81b5dc4cbcc84ab6b0cd9e57d1e392588ac in your template with new scriptSig
hero member
Activity: 935
Merit: 1002
take the keys.
create digest of your transaction (remove scriptsig at all and do sha256^2)
the scriptsig will be
OP_FALSE, sig1, sig2... sigx, bip16
where hash160 (bip16) = f837bec6fc1610acc74b1089ab4ef060ecfe254a
Didn't understood it. Especially the part where you have to make a digest of the tx.
legendary
Activity: 1260
Merit: 1019
Quote
Um how does one sign this transaction [...] without using bitcoin core(yes I have all the 10 private keys)

all 10 keys of what?
of msig-address 3QKUHN3uCLqX3KSbFkut2EdoDynrxFs2s7 which is the output of
https://blockchain.info/tx/2b192c175cb46625e7b61129efb9ce5e6da47f44e0c0b020be9f77ba2380f4a0

take the keys.
create digest of your transaction (remove scriptsig at all and do sha256^2)
the scriptsig will be
OP_FALSE, sig1, sig2... sigx, bip16
where hash160 (bip16) = f837bec6fc1610acc74b1089ab4ef060ecfe254a
hero member
Activity: 935
Merit: 1002
Thank you very much. Let me know if you have any other questions about non-standard transactions.
Um how does one sign this transaction
Code:
0100000001a0f48023ba779fbe20b0c0e0447fa46d5eceb9ef2911b6e72566b45c172c192b000000001976a9147db9fbceb81b5dc4cbcc84ab6b0cd9e57d1e392588acffffffff0100350c000000000017a914f837bec6fc1610acc74b1089ab4ef060ecfe254a8700000000
without using bitcoin core(yes I have all the 10 private keys)
sr. member
Activity: 475
Merit: 252
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.

Since your bounty requirements were just to teach you how to make the non-standard output, and you have succeeded, I would like to ask that you deposit the bounty to my tip address in my sig.

Thank you.
I guess OP_TRUE won't differ much from the OP_EQUAL(sha-256) so I send you a full bounty. https://blockchain.info/tx/678fe4a407b2ea100b6ce7ad1eda0c692465260c3498d0b691ff529b0e1ef5b8

Thank you very much. Let me know if you have any other questions about non-standard transactions.
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.

Since your bounty requirements were just to teach you how to make the non-standard output, and you have succeeded, I would like to ask that you deposit the bounty to my tip address in my sig.

Thank you.
I guess OP_TRUE won't differ much from the OP_EQUAL(sha-256) so I send you a full bounty. https://blockchain.info/tx/678fe4a407b2ea100b6ce7ad1eda0c692465260c3498d0b691ff529b0e1ef5b8
sr. member
Activity: 475
Merit: 252
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.

Since your bounty requirements were just to teach you how to make the non-standard output, and you have succeeded, I would like to ask that you deposit the bounty to my tip address in my sig.

Thank you.
sr. member
Activity: 475
Merit: 252
Customs scripts are non-standard and won't be relayed by most of the network.  This can be bypassed by replacing the "output script" with a P2SH script including the HASH160 of your redemption script.
Wouldn't that be standard then?
And would this then work?
OP_DUP OP_HASH160 7db9fbceb81b5dc4cbcc84ab6b0cd9e57d1e3925 OP_EQUALVERIFY OP_CHECKSIG OP_SHA256 9c0f28fc262f58e9ad1f021ab707662cad96c754ecf3ad43be5c26e49c081233 OP_EQUALVERIFY
Nope. you would SHA256 hash the number 1, as if CHECKSIG is OK then it will leave OP_1 on the top of the stack.

You would also need something that checked if OPCHECKSIG gave a 1 or 0... which is why you should use OP_CHECKSIGVERIFY instead, as that will fail the script immediately if it fails, AND it won't leave a 1 on the stack.
hero member
Activity: 935
Merit: 1002
Not sure if that is exactly what DeathAndTaxes meant but I created
Code:
0100000001066bcd0e85ff55eb54c2421b8707db952c796237fb44bbcd39c8ea2769d11d90000000008a47304402203d10ece797b624a5296bdd6fb86216e4cfed0bd6c85ed99f16d48dec835ce53c022020962978a7bd9b7ee9beb45c8d80289c475a257e74ca5519b77de47818aa8ffe014104d79737e9137e54a6ed4d3f6ccabb2a2232bc0020477c911f0d7d74db62d6f7b2f6fdd88457e6c408033edc7b12539584d42c8acaefff6347165f24f0abbcb9c2ffffffff0100350c000000000023a9209c0f28fc262f58e9ad1f021ab707662cad96c754ecf3ad43be5c26e49c0812338700000000
I pushed it, it got relayed then tried to push the double-spending tx to f2pool and they accepted it. So it means that they still ignore it or didn't got the first tx.
legendary
Activity: 1260
Merit: 1019
detected

Code:
0100000001066BCD0E85FF55EB54C2421B8707DB952C796237FB44BBCD39C8EA2769D11D90000000008A47304402203D10ECE797B624A5296BDD6FB86216E4CFED0BD6C85ED99F16D48DEC835CE53C022020962978A7BD9B7EE9BEB45C8D80289C475A257E74CA5519B77DE47818AA8FFE014104D79737E9137E54A6ED4D3F6CCABB2A2232BC0020477C911F0D7D74DB62D6F7B2F6FDD88457E6C408033EDC7B12539584D42C8ACAEFFF6347165F24F0ABBCB9C2FFFFFFFF0100350C000000000023A9209C0F28FC262F58E9AD1F021AB707662CAD96C754ECF3AD43BE5C26E49C0812338700000000

"txid" : "ae26b54c5443278909d77983d03e535013d7e26906f5328a91c4fcb45f711210",
"version" : 1,
"locktime" : 0,
"vin" : [
{
"txid" : "901dd16927eac839cdbb44fb3762792c95db07871b42c254eb55ff850ecd6b06",
"vout" : 0,
[...]
"vout" : [
{
"value" : 0.00800000, // no miners fee again?
"n" : 0,
"scriptPubKey" : {
"asm" : "OP_HASH160 9c0f28fc262f58e9ad1f021ab707662cad96c754ecf3ad43be5c26e49c081233 OP_EQUAL", // UNSPENDABLE because hash160 can not be equal to 32-byte value
"hex" : "a9209c0f28fc262f58e9ad1f021ab707662cad96c754ecf3ad43be5c26e49c08123387",
"type" : "nonstandard"
Pages:
Jump to: