Bitcoin Forum
April 25, 2024, 01:15:13 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1] 2 »  All
  Print  
Author Topic: Pay2SH - Strange transactions?  (Read 2253 times)
hhanh00 (OP)
Sr. Member
****
Offline Offline

Activity: 467
Merit: 266


View Profile
October 21, 2014, 10:14:57 AM
 #1

There are a few Pay2SH transactions that I can't validate.
For example,
https://blockchain.info/tx/567a53d1ce19ce3d07711885168484439965501536d0d0294c5d46d46c10e53b

The script hash matches but the script uses OP_RIGHT.
Code:
OP_1 OP_RIGHT 6e879169907c9087

OP_RIGHT s a disabled op code. Shouldn't the script fail?
It's not the only example. We have 6 other scripts that use disabled opcodes and yet are part of the blockchain.

Another one, harder for me to understand
https://blockchain.info/tx/5df1375ffe61ac35ca178ebb0cab9ea26dedbd0e96005dfcee7e379fa513232f

Of all the P2SH cases in the blockchain, my tool only rejects this one. It looks like a standard 2 of 3 multisig. The 2nd signature is a SIGHASH_SINGLE but the first one is a regular SIGHASH_ALL. Yet, none of the provided public keys seems to match the first one either.
There must be something wrong with my tool but I don't see where.
I could run another client but it will take hours before it catches up to this point. A standalone verifier would be great. Because usually, the issue is in the way I built the transaction to sign. Is there such a tool available?

I tried decoderawtransaction - it doesn't give much information.

Code:
{
"txid" : "5df1375ffe61ac35ca178ebb0cab9ea26dedbd0e96005dfcee7e379fa513232f",
"version" : 1,
"locktime" : 0,
"vin" : [
{
"txid" : "b5b598de91787439afd5938116654e0b16b7a0d0f82742ba37564219c5afcbf9",
"vout" : 0,
"scriptSig" : {
"asm" : "30450221008dd619c563e527c47d9bd53534a770b102e40faa87f61433580e04e271ef2f960220029886434e18122b53d5decd25f1f4acb2480659fea20aabd856987ba3c3907e01 022b78b756e2258af13779c1a1f37ea6800259716ca4b7f0b87610e0bf3ab52a01",
"hex" : "4830450221008dd619c563e527c47d9bd53534a770b102e40faa87f61433580e04e271ef2f960220029886434e18122b53d5decd25f1f4acb2480659fea20aabd856987ba3c3907e0121022b78b756e2258af13779c1a1f37ea6800259716ca4b7f0b87610e0bf3ab52a01"
},
"sequence" : 4294967295
},
{
"txid" : "ab9805c6d57d7070d9a42c5176e47bb705023e6b67249fb6760880548298e742",
"vout" : 0,
"scriptSig" : {
"asm" : "0 3045022015bd0139bcccf990a6af6ec5c1c52ed8222e03a0d51c334df139968525d2fcd20221009f9efe325476eb64c3958e4713e9eefe49bf1d820ed58d2112721b134e2a1a5303 30460221008431bdfa72bc67f9d41fe72e94c88fb8f359ffa30b33c72c121c5a877d922e1002210089ef5fc22dd8bfc6bf9ffdb01a9862d27687d424d1fefbab9e9c7176844a187a01 52483045022015bd0139bcccf990a6af6ec5c1c52ed8222e03a0d51c334df139968525d2fcd20221009f9efe325476eb64c3958e4713e9eefe49bf1d820ed58d2112721b134e2a1a5303210378d430274f8c5ec1321338151e9f27f4c676a008bdf8638d07c0b6be9ab35c71210378d430274f8c5ec1321338151e9f27f4c676a008bdf8638d07c0b6be9ab35c7153ae",
"hex" : "00483045022015bd0139bcccf990a6af6ec5c1c52ed8222e03a0d51c334df139968525d2fcd20221009f9efe325476eb64c3958e4713e9eefe49bf1d820ed58d2112721b134e2a1a53034930460221008431bdfa72bc67f9d41fe72e94c88fb8f359ffa30b33c72c121c5a877d922e1002210089ef5fc22dd8bfc6bf9ffdb01a9862d27687d424d1fefbab9e9c7176844a187a014c9052483045022015bd0139bcccf990a6af6ec5c1c52ed8222e03a0d51c334df139968525d2fcd20221009f9efe325476eb64c3958e4713e9eefe49bf1d820ed58d2112721b134e2a1a5303210378d430274f8c5ec1321338151e9f27f4c676a008bdf8638d07c0b6be9ab35c71210378d430274f8c5ec1321338151e9f27f4c676a008bdf8638d07c0b6be9ab35c7153ae"
},
"sequence" : 4294967295
}
],
"vout" : [
{
"value" : 0.00100000,
"n" : 0,
"scriptPubKey" : {
"asm" : "OP_HASH160 d8dacdadb7462ae15cd906f1878706d0da8660e6 OP_EQUAL",
"hex" : "a914d8dacdadb7462ae15cd906f1878706d0da8660e687",
"reqSigs" : 1,
"type" : "scripthash",
"addresses" : [
"3MTdzi2J1qqge4MsGykL7K461JuSwNqwko"
]
}
}
]
}

Thanks for your help

1714050913
Hero Member
*
Offline Offline

Posts: 1714050913

View Profile Personal Message (Offline)

Ignore
1714050913
Reply with quote  #2

1714050913
Report to moderator
In order to get the maximum amount of activity points possible, you just need to post once per day on average. Skipping days is OK as long as you maintain the average.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1714050913
Hero Member
*
Offline Offline

Posts: 1714050913

View Profile Personal Message (Offline)

Ignore
1714050913
Reply with quote  #2

1714050913
Report to moderator
1714050913
Hero Member
*
Offline Offline

Posts: 1714050913

View Profile Personal Message (Offline)

Ignore
1714050913
Reply with quote  #2

1714050913
Report to moderator
trattrat
Full Member
***
Offline Offline

Activity: 210
Merit: 100


View Profile
October 21, 2014, 01:27:57 PM
 #2

Some miners will include strange transactions.

hhanh00 (OP)
Sr. Member
****
Offline Offline

Activity: 467
Merit: 266


View Profile
October 21, 2014, 01:48:54 PM
 #3

Are they allowed to include invalid transactions?

CIYAM
Legendary
*
Offline Offline

Activity: 1890
Merit: 1075


Ian Knowles - CIYAM Lead Developer


View Profile WWW
October 21, 2014, 01:49:49 PM
 #4

Are they allowed to include invalid transactions?

If they are invalid then other nodes would reject them - so I don't think that they could be *invalid*.

With CIYAM anyone can create 100% generated C++ web applications in literally minutes.

GPG Public Key | 1ciyam3htJit1feGa26p2wQ4aw6KFTejU
hhanh00 (OP)
Sr. Member
****
Offline Offline

Activity: 467
Merit: 266


View Profile
October 21, 2014, 01:51:47 PM
 #5

Cool but how can they be valid? They have disabled op codes.

amaclin
Legendary
*
Offline Offline

Activity: 1260
Merit: 1019


View Profile
October 21, 2014, 02:03:40 PM
 #6

Quote
OP_RIGHT s a disabled op code. Shouldn't the script fail?
Definitely must fail.
This is a bug on blockchain.info site
In fact the script is

Code:
51            // PUSH 1
0181         // PUSH -1
08 6e879169907c9087 // PUSH p2sh inner script

There are no disabled opcodes in this script
amaclin
Legendary
*
Offline Offline

Activity: 1260
Merit: 1019


View Profile
October 21, 2014, 02:15:13 PM
 #7

Quote
Another one, harder for me to understand
https://blockchain.info/tx/5df1375ffe61ac35ca178ebb0cab9ea26dedbd0e96005dfcee7e379fa513232f

Of all the P2SH cases in the blockchain, my tool only rejects this one. It looks like a standard 2 of 3 multisig. The 2nd signature is a SIGHASH_SINGLE but the first one is a regular SIGHASH_ALL. Yet, none of the provided public keys seems to match the first one either.
There must be something wrong with my tool but I don't see where.

My advise: take bitcoin-qt sources (local copy just for test this tx) and pass this transaction to the validation method under debugging.
Buffer Overflow
Legendary
*
Offline Offline

Activity: 1652
Merit: 1015



View Profile
October 21, 2014, 02:18:39 PM
 #8

I guess the miner had isStandard() flag disabled in their config for these transactions to be in the blockchain if they are nonstandard.

amaclin
Legendary
*
Offline Offline

Activity: 1260
Merit: 1019


View Profile
October 21, 2014, 02:20:47 PM
 #9

I guess the miner had isStandard() flag disabled in their config for these transactions to be in the blockchain if they are nonstandard.
First transaction mined by Eligius. This pool has its own IsStandard ( )
luv2drnkbr
Hero Member
*****
Offline Offline

Activity: 793
Merit: 1016



View Profile
October 21, 2014, 02:20:49 PM
 #10

Can somebody explain how 0x81 translates to -1?  I get the 0x01 code to push the 0x81 byte, but I don't understand why it's a -1.

amaclin
Legendary
*
Offline Offline

Activity: 1260
Merit: 1019


View Profile
October 21, 2014, 02:24:48 PM
 #11

Can somebody explain how 0x81 translates to -1?  I get the 0x01 code to push the 0x81 byte, but I don't understand why it's a -1.

The highest bit is sign.
0x81 = 0x80 + 0x01

BTW: 0x80 itself is "negative zero"
luv2drnkbr
Hero Member
*****
Offline Offline

Activity: 793
Merit: 1016



View Profile
October 21, 2014, 02:29:20 PM
 #12

How is that determined?  Is there a data format not listed on the wiki about scripts?

amaclin
Legendary
*
Offline Offline

Activity: 1260
Merit: 1019


View Profile
October 21, 2014, 02:33:49 PM
 #13

How is that determined?  Is there a data format not listed on the wiki about scripts?

Everything in wiki. Have you read it?

https://en.bitcoin.it/wiki/Script

Quote
The stacks hold byte vectors. When used as numbers, byte vectors are interpreted as little-endian variable-length integers with the most significant bit determining the sign of the integer. Thus 0x81 represents -1. 0x80 is another representation of zero (so called negative 0). Positive 0 is represented by a null-length vector. Byte vectors are interpreted as Booleans where False is represented by any representation of zero, and True is represented by any representation of non-zero.
luv2drnkbr
Hero Member
*****
Offline Offline

Activity: 793
Merit: 1016



View Profile
October 21, 2014, 02:36:50 PM
 #14

Whoops.  I scrolled past that, looking at op codes.  Thanks for the explanation!

hhanh00 (OP)
Sr. Member
****
Offline Offline

Activity: 467
Merit: 266


View Profile
October 21, 2014, 04:00:27 PM
 #15

Thanks, turned out my mistake was somewhere else.

Regarding the last script,

Code:
OP_FALSE 3045022015bd0139bcccf990a6af6ec5c1c52ed8222e03a0d51c334df139968525d2fcd20221009f9efe325476eb64c3958e4713e9eefe49bf1d820ed58d2112721b134e2a1a5303 
30460221008431bdfa72bc67f9d41fe72e94c88fb8f359ffa30b33c72c121c5a877d922e1002210089ef5fc22dd8bfc6bf9ffdb01a9862d27687d424d1fefbab9e9c7176844a187a01
52483045022015bd0139bcccf990a6af6ec5c1c52ed8222e03a0d51c334df139968525d2fcd20221009f9efe325476eb64c3958e4713e9eefe49bf1d820ed58d2112721b134e2a1a5303210378d430274f8c5ec1321338151e9f27f4c676a008bdf8638d07c0b6be9ab35c71210378d430274f8c5ec1321338151e9f27f4c676a008bdf8638d07c0b6be9ab35c7153ae

The first signature is in the redeem script and has to be removed before it is inserted into the transaction to sign. I was missing this part since for a standard tx, the signature is in the input script.

Nicolas Dorier
Hero Member
*****
Offline Offline

Activity: 714
Merit: 619


View Profile
October 24, 2014, 05:28:35 PM
Last edit: October 24, 2014, 05:42:50 PM by Nicolas Dorier
 #16

The 2nd input of https://blockchain.info/tx/5df1375ffe61ac35ca178ebb0cab9ea26dedbd0e96005dfcee7e379fa513232f is

Quote
0 3045022015bd0139bcccf990a6af6ec5c1c52ed8222e03a0d51c334df139968525d2fcd20221009 f9efe325476eb64c3958e4713e9eefe49bf1d820ed58d2112721b134e2a1a5303 30460221008431bdfa72bc67f9d41fe72e94c88fb8f359ffa30b33c72c121c5a877d922e1002210 089ef5fc22dd8bfc6bf9ffdb01a9862d2
With redeem script being

Quote
2 3045022015bd0139bcccf990a6af6ec5c1c52ed8222e03a0d51c334df139968525d2fcd20221009 f9efe325476eb64c3958e4713e9eefe49bf1d820ed58d2112721b134e2a1a5303 0378d430274f8c5ec1321338151e9f27f4c676a008bdf8638d07c0b6be9ab35c71 0378d430274f8c5ec1321338151e9f27f4c676a008bdf8638d07c0b6be9ab35c71 3 OP_CHECKMULTISIG}   NBitcoin.Script

In other words, a p2sh multi sig. Blockchain is bugged.

C# code with NBitcoin :
Quote
var tx = new BlockrTransactionRepository().Get(new uint256("5df1375ffe61ac35ca178ebb0cab9ea26dedbd0e96005dfcee7e379fa513232f"));

Console.WriteLine(tx.Inputs[1].ScriptSig);
var redeemScript = new PayToScriptHashTemplate()
{
   VerifyRedeemScript = false
}.ExtractScriptSigParameters(tx.Inputs[1].ScriptSig).RedeemScript;
Console.WriteLine(redeemScript);

The funny thing is that the redeemScript is not correct. It is a 2 - 3 except that there is only one correctly formed public key. This make it non redeemable.

UPDATE : It was indeed spent. Investigating this miracle.
UPDATE 2 : My fault, there is 2 valid public key but one invalid one. Which means the spender stuffed data in the redeem. Smiley

Bitcoin address 15sYbVpRh6dyWycZMwPdxJWD4xbfxReeHe
amaclin
Legendary
*
Offline Offline

Activity: 1260
Merit: 1019


View Profile
October 24, 2014, 06:29:16 PM
 #17

Quote
UPDATE 2 : My fault, there is 2 valid public key but one invalid one. Which means the spender stuffed data in the redeem. Smiley

Update 3: there is one public key used twice Smiley
Quote
2 3045022015bd0139bcccf990a6af6ec5c1c52ed8222e03a0d51c334df139968525d2fcd20221009 f9efe325476eb64c3958e4713e9eefe49bf1d820ed58d2112721b134e2a1a5303
0378d430274f8c5ec1321338151e9f27f4c676a008bdf8638d07c0b6be9ab35c71 0378d430274f8c5ec1321338151e9f27f4c676a008bdf8638d07c0b6be9ab35c71 3 OP_CHECKMULTISIG
hhanh00 (OP)
Sr. Member
****
Offline Offline

Activity: 467
Merit: 266


View Profile
October 25, 2014, 06:40:46 AM
 #18

Someone should do a best of the blockchain. Some whacked scripts are in there.  Grin

Buffer Overflow
Legendary
*
Offline Offline

Activity: 1652
Merit: 1015



View Profile
October 25, 2014, 08:13:22 AM
 #19

Someone should do a best of the blockchain. Some whacked scripts are in there.  Grin

Try this one:
https://blockchain.info/tx/e411dbebd2f7d64dafeef9b14b5c59ec60c36779d43f850e5e347abee1e1a455

Nicolas Dorier
Hero Member
*****
Offline Offline

Activity: 714
Merit: 619


View Profile
October 25, 2014, 10:50:53 AM
 #20


Maybe this one might is an old attempt at DDOS when the number of sig operation were not limited ? (OP_CHECKSIG do not return from the script, so every op is evaluated)

... maybe most likely a bug, I think OP_CHECKSIG consume the stack so the other one should not be able to execute.

Bitcoin address 15sYbVpRh6dyWycZMwPdxJWD4xbfxReeHe
Pages: [1] 2 »  All
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!