Author

Topic: Error while sending transaction with own script (Read 216 times)

brand new
Activity: 0
Merit: 0
September 06, 2018, 12:50:32 PM
#4
I also face the same issue and take a help of Hp Support Assistant to know the proper reason they told me that there is some coding issue but I can't find them. Can anyone guide me? to solve this properly.
newbie
Activity: 4
Merit: 0
I see this input script:
Code:
4C141F8B0800FFC1765400038D78055C545DF3FF5D4A4C141F8B0800FFC1765400038D78055C545DF3FF5D4A4C141F8B0800FFC1765400038D78055C545DF3FF5D4AA94C141C18EB2E89217B39A344622D3EAF2368F220674788A94C141C18EB2E89217B39A344622D3EAF2368F220674788A94C141C18EB2E89217B39A344622D3EAF2368F220674787

4C is OP_PUSHDATA, saying next byte is # of bytes that go onto stack. Next byte is 14, which is decimal 20 bytes on stack... you say you want to push DATA1 (520 bytes) on stack?
520 bytes is hex 0x208, so maybe you want to say PUSHDATA 0x208 <520 bytes>?
520 bytes written from the source of the script. But I use three identical parts of 20 bytes to make it easier. They are also the same to make it easier to replace the hash because it's not entirely clear how to get the hash160. I know that first I need to hash in sha256 and then in RIPEMD160 but there are different values depending on the case of letters after hashing in sha256 and I do not know what case exactly is needed. For example hash160 of OP_TRUE should be da1745e9b549bd0bfa1a569971c77eba30cd5a4b but when I'm hashing 51 with sha-256 I get 031b4af5197ec30a926f48cf40e11a7dbc470048a21e4003b7a3c07c5dab1baa ripemd160 of which d3212ee812e38323ebb60b193c5d54bd55728b38 and what's wrong?



And: "Data push larger than necessary" indicates a situation, where you use 2 opcodes, whereas a single one would be fully sufficient. Hence when pushing 20 bytes (hex 14) to stack, a single command "0x14" is sufficient (https://en.bitcoin.it/wiki/Script).
From another thread, I copied this comment into one of my scripts:
# 1.) OP_PUSHDATA1 and even OP_PUSHDATA2 are allowed inside P2SH scripts fine.
# However, there is another policy in Bitcoin Core to require that all pushes
# are minimal in standard transactions. That means you can only use
# OP_PUSHDATA1 when a direct push is not possible (up to 75 bytes), and only
# use OP_PUSHDATA2 when an OP_PUSHDATA1 is not possible (up to 255 bytes).
This is very useful, thank you.
But for now I have transaction:
Quote
020000000001019e1ab6b4683d58a37f969991304798bbbf7687599f057de0ae61f92945fd12160 000000085141f8b0800ffc1765400038d78055c545df3ff5d4a141f8b0800ffc1765400038d7805 5c545df3ff5d4a141f8b0800ffc1765400038d78055c545df3ff5d4a45a9147348ade0b3cbbc86a 50396bfdccb047525ee890288a9147348ade0b3cbbc86a50396bfdccb047525ee890288a9147348 ade0b3cbbc86a50396bfdccb047525ee890287ffffffff02801d2c040000000017a9141a75cd53e 9740caadbf83cbefdd087cdceb978a48760F590000000000017a914ceb069bfa77f4a589e63eb4a d022ef122100453887024830450221008cf6b0c4741be13e058e33123b337836da4eb487dde98da 9adc7a26cf3b7b6f10220369d85d178a2af9b34af8104c46822b353e59371ebe8310e1095ad96f9 c128cc012102ada9884dbd1e8bd90968ba66256f017cd77d83595027f7929ae3537f98c92d4a000 00000
Input script of which
Quote
141f8b0800ffc1765400038d78055c545df3ff5d4a141f8b0800ffc1765400038d78055c545df3f f5d4a141f8b0800ffc1765400038d78055c545df3ff5d4a45a9147348ade0b3cbbc86a50396bfdc cb047525ee890288a9147348ade0b3cbbc86a50396bfdccb047525ee890288a9147348ade0b3cbb c86a50396bfdccb047525ee890287
In this script I perform: OP_PUSHDATA < Data 1 (20 bytes) >OP_PUSHDATA < Data 2 (20 bytes) > OP_PUSHDATA < Data 3 (20 bytes) > OP_PUSHDATA < RedeemScript > where RedeemScript pattern as in first my message. And for now I get error code=-26, message=16: mandatory-script-verify-flag-failed (Script evaluated without error but finished with a false/empty top stack element).

Also I have one more question. As I understand hash of RedeemScript should be equal output of previous transaction. So in my case should I firstly create transaction with output which equals of hash160(a9147348ade0b3cbbc86a50396bfdccb047525ee890288a9147348ade0b3cbbc86a50396bfdccb0 47525ee890288a9147348ade0b3cbbc86a50396bfdccb047525ee890287)?
sr. member
Activity: 257
Merit: 343
I see this input script:
Code:
4C141F8B0800FFC1765400038D78055C545DF3FF5D4A4C141F8B0800FFC1765400038D78055C545DF3FF5D4A4C141F8B0800FFC1765400038D78055C545DF3FF5D4AA94C141C18EB2E89217B39A344622D3EAF2368F220674788A94C141C18EB2E89217B39A344622D3EAF2368F220674788A94C141C18EB2E89217B39A344622D3EAF2368F220674787

4C is OP_PUSHDATA, saying next byte is # of bytes that go onto stack. Next byte is 14, which is decimal 20 bytes on stack... you say you want to push DATA1 (520 bytes) on stack?
520 bytes is hex 0x208, so maybe you want to say PUSHDATA 0x208 <520 bytes>?

And: "Data push larger than necessary" indicates a situation, where you use 2 opcodes, whereas a single one would be fully sufficient. Hence when pushing 20 bytes (hex 14) to stack, a single command "0x14" is sufficient (https://en.bitcoin.it/wiki/Script).

From another thread, I copied this comment into one of my scripts:
# 1.) OP_PUSHDATA1 and even OP_PUSHDATA2 are allowed inside P2SH scripts fine.
# However, there is another policy in Bitcoin Core to require that all pushes
# are minimal in standard transactions. That means you can only use
# OP_PUSHDATA1 when a direct push is not possible (up to 75 bytes), and only
# use OP_PUSHDATA2 when an OP_PUSHDATA1 is not possible (up to 255 bytes).
newbie
Activity: 4
Merit: 0
I want to send transaction with some data with using p2sh.
But when I inserting my own script in a transaction I'm getting error from my bitcoind client: "code=-26, message=16: mandatory-script-verify-flag-failed (Data push larger than necessary)".
Script has been written according to the Working Paper Data Insertion in Bitcoin's Blockchain. Which says that I can store with P2SH with using this script:
Quote
Input Script: OP_PUSHDATA < Data 1 (520 bytes) > OP_PUSHDATA < Data 2 (520 bytes) > OP_PUSHDATA < Data 3 (520 bytes) > < RedeemScript >
Redeem Script: OP HASH160  OP_PUSHDATA< Data3Hash > OP EQUALVERIFY OP HASH160 OP_PUSHDATA< Data2Hash > OP EQUALVERIFY OP HASH160 OP_PUSHDATA < Data1Hash > OP [/sup]EQUAL

This is example of my signed raw transaction with script written according to that manner. And I'm trying to insert less than 520 bytes, only 20.
Quote
020000000001019e1ab6b4683d58a37f969991304798bbbf7687599f057de0ae61f92945fd12160 00000008a4c141f8b0800ffc1765400038d78055c545df3ff5d4a4c141f8b0800ffc1765400038d 78055c545df3ff5d4a4c141f8b0800ffc1765400038d78055c545df3ff5d4aa94c141c18eb2e892 17b39a344622d3eaf2368f220674788a94c141c18eb2e89217b39a344622d3eaf2368f220674788 a94c141c18eb2e89217b39a344622d3eaf2368f220674787ffffffff02BB51D9000000000017a91 4182fd008c33ac992bda3bac7e09297ebe8639aca87800bb2030000000017a914182fd008c33ac9 92bda3bac7e09297ebe8639aca87024730440220110ff8ea143c0e1b14da35103ee285be9c0729a 79a1e70c543627da58c07947c02204afd8d5a29d50d3519735b33ada00a09fbf379e424b137f547 d3f5cd9db24f62012102ada9884dbd1e8bd90968ba66256f017cd77d83595027f7929ae3537f98c 92d4a00000000

I'll be thankful for any help and sorry for my English. 
Jump to: