Pages:
Author

Topic: Is this BIP65 sample script standard? (Read 4703 times)

legendary
Activity: 1890
Merit: 1072
Ian Knowles - CIYAM Lead Developer
January 04, 2016, 04:23:55 AM
#65
The following tx uses the "secret reveal" method which doesn't use the CLTV op so it can be issued as soon as the P2SH address is funded (hence locktime is zero).

Code:
{
    "txid" : "1dc407204055e72bdc2bc9579a8827b89a51e8a677c4d46b7ae1a32a4c2280d9",
    "version" : 1,
    "locktime" : 0,
    "vin" : [
        {
            "txid" : "e8d0014d1bcefa75df448cd30e0225978bf4efec1c1f44b6763ce671aced6b49",
            "vout" : 0,
            "scriptSig" : {
                "asm" : "3045022100f384542d66de1a19d5b1181b9894e14d44f34b83e9a190c0c43046486fbb2d9e02205bb2b9795e4f35c40aa38275a900c
a01ea5f7d7747fcdb657b0c656a130d20cb01 02681362f33ab4c48884c5f7f5aaf5011d53f0584cf0b257c6c3aff8b0b08241b3 31323334353637383930 76a820
c775e7b757ede630cd0aa1113bd102661ab38829ca52a6422ab782862f26864687637576a9145e6199a3c0ad658480247a0f30e314aee23db1eb88ac67017fb17576
a9145e6199a3c0ad658480247a0f30e314aee23db1eb88ac68",
                "hex" : "483045022100f384542d66de1a19d5b1181b9894e14d44f34b83e9a190c0c43046486fbb2d9e02205bb2b9795e4f35c40aa38275a90
0ca01ea5f7d7747fcdb657b0c656a130d20cb012102681362f33ab4c48884c5f7f5aaf5011d53f0584cf0b257c6c3aff8b0b08241b30a313233343536373839304c5
e76a820c775e7b757ede630cd0aa1113bd102661ab38829ca52a6422ab782862f26864687637576a9145e6199a3c0ad658480247a0f30e314aee23db1eb88ac67017
fb17576a9145e6199a3c0ad658480247a0f30e314aee23db1eb88ac68"
            },
            "sequence" : 0
        }
    ],
    "vout" : [
        {
            "value" : 50.00000000,
            "n" : 0,
            "scriptPubKey" : {
                "asm" : "OP_DUP OP_HASH160 5e6199a3c0ad658480247a0f30e314aee23db1eb OP_EQUALVERIFY OP_CHECKSIG",
                "hex" : "76a9145e6199a3c0ad658480247a0f30e314aee23db1eb88ac",
                "reqSigs" : 1,
                "type" : "pubkeyhash",
                "addresses" : [
                    "mp7zjTrEszZezRBM1cUmTvaK2zf3MuDAHt"
                ]
            }
        }
    ]
}
legendary
Activity: 1890
Merit: 1072
Ian Knowles - CIYAM Lead Developer
January 03, 2016, 04:48:54 AM
#64
Finally I got the regtest version to work!!

Code:
{
    "txid" : "5fcebe8baf36c6936485465dedbc22934e7b29164dc4379bcab5c66b53ba5571",
    "version" : 1,
    "locktime" : 353,
    "vin" : [
        {
            "txid" : "1a0af915d3585fa627927b8d74ebc6b1c15ba01179d25b7ebc0a18bfdb003732",
            "vout" : 0,
            "scriptSig" : {
                "asm" : "304402206a780b785554c3f486a64e734d8cc019baf5e3203a8225894aa207ce5ecedf4902206ac5ed47274f1bb3e8d03fc838ee01a
f158a30197500f7bb554645cbc7ae53e301",
                "hex" : "47304402206a780b785554c3f486a64e734d8cc019baf5e3203a8225894aa207ce5ecedf4902206ac5ed47274f1bb3e8d03fc838ee0
1af158a30197500f7bb554645cbc7ae53e301"
            },
            "sequence" : 4294967294
        },
        {
            "txid" : "d779110252411719dac10d06bba948287a254754d8fd970737350932021e8563",
            "vout" : 0,
            "scriptSig" : {
                "asm" : "3045022100a8f068a234814ff39bed454ba0fcea57542410af4730bbe6ea71cef3fff1bc80022078406403872928398378d05192541
128e5cf069168d03cd03082aef06941014b01",
                "hex" : "483045022100a8f068a234814ff39bed454ba0fcea57542410af4730bbe6ea71cef3fff1bc80022078406403872928398378d051925
41128e5cf069168d03cd03082aef06941014b01"
            },
            "sequence" : 4294967294
        }
    ],
    "vout" : [
        {
            "value" : 50.00000000,
            "n" : 0,
            "scriptPubKey" : {
                "asm" : "OP_HASH160 fda3b60118555482c3463148bf18ff12e1f29c2c OP_EQUAL",
                "hex" : "a914fda3b60118555482c3463148bf18ff12e1f29c2c87",
                "reqSigs" : 1,
                "type" : "scripthash",
                "addresses" : [
                    "2NGNM4erqJ14dNdq5QhJorunWZqPY4danqv"
                ]
            }
        }
    ]
}

And this is the redeem tx (using CLTV):
Code:
{
    "txid" : "7fd77a5f62081e113147a31550b6262febd2e3273165c3fb6a59c814d0a97796",
    "version" : 1,
    "locktime" : 252,
    "vin" : [
        {
            "txid" : "5fcebe8baf36c6936485465dedbc22934e7b29164dc4379bcab5c66b53ba5571",
            "vout" : 0,
            "scriptSig" : {
                "asm" : "30440220429b09433f70c16b26021bd19f71a7d30087c3bbd7e1255cfda7c00fdc126bed02207219634bd0f66eee1b73e60552bbf17
7f278ba856b99100bdc610b5da720168501 02681362f33ab4c48884c5f7f5aaf5011d53f0584cf0b257c6c3aff8b0b08241b3 76a820c775e7b757ede630cd0aa11
13bd102661ab38829ca52a6422ab782862f26864687637576a9145e6199a3c0ad658480247a0f30e314aee23db1eb88ac67017fb17576a9145e6199a3c0ad6584802
47a0f30e314aee23db1eb88ac68",
                "hex" : "4730440220429b09433f70c16b26021bd19f71a7d30087c3bbd7e1255cfda7c00fdc126bed02207219634bd0f66eee1b73e60552bbf
177f278ba856b99100bdc610b5da7201685012102681362f33ab4c48884c5f7f5aaf5011d53f0584cf0b257c6c3aff8b0b08241b34c5e76a820c775e7b757ede630c
d0aa1113bd102661ab38829ca52a6422ab782862f26864687637576a9145e6199a3c0ad658480247a0f30e314aee23db1eb88ac67017fb17576a9145e6199a3c0ad6
58480247a0f30e314aee23db1eb88ac68"
            },
            "sequence" : 0
        }
    ],
    "vout" : [
        {
            "value" : 50.00000000,
            "n" : 0,
            "scriptPubKey" : {
                "asm" : "OP_DUP OP_HASH160 5e6199a3c0ad658480247a0f30e314aee23db1eb OP_EQUALVERIFY OP_CHECKSIG",
                "hex" : "76a9145e6199a3c0ad658480247a0f30e314aee23db1eb88ac",
                "reqSigs" : 1,
                "type" : "pubkeyhash",
                "addresses" : [
                    "mp7zjTrEszZezRBM1cUmTvaK2zf3MuDAHt"
                ]
            }
        }
    ]
}

The P2SH redeem script is as follows:
Code:
OP_DUP
OP_SHA256
c775e7b757ede630cd0aa1113bd102661ab38829ca52a6422ab782862f268646
OP_EQUAL
OP_IF
OP_DROP
OP_DUP
OP_HASH160
5e6199a3c0ad658480247a0f30e314aee23db1eb
OP_EQUALVERIFY
OP_CHECKSIG
OP_ELSE
7f
OP_NOP2
OP_DROP
OP_DUP
OP_HASH160
5e6199a3c0ad658480247a0f30e314aee23db1eb
OP_EQUALVERIFY
OP_CHECKSIG
OP_ENDIF

The two address hashes were intentionally made the same to simplify testing - for practical usage they would be different (one for Alice and one for Bob).
legendary
Activity: 1260
Merit: 1019
January 03, 2016, 04:02:17 AM
#63
I am starting to agree that "testnet" is actually not at all useful for testing. Sad
testnet on https://test.webbtc.com/ is not synchronized.
the last block is 2015-11-10 07:21
sr. member
Activity: 719
Merit: 250
January 03, 2016, 01:48:49 AM
#62
I sometimes get this error message from webbtc when attempting to use its testnet3 script pages. It seemed to be the most reliable script tool available, but I don't trust it anymore. After you suggested trying alternatives I found 41e834bc7d8266e50d271af204ebfc0ea7db4a204607fbad5bee1bd96fc7c6bb on other testnet3 block explorers.

legendary
Activity: 1890
Merit: 1072
Ian Knowles - CIYAM Lead Developer
January 03, 2016, 01:23:29 AM
#61
Strange as the tx 41e834bc7d8266e50d271af204ebfc0ea7db4a204607fbad5bee1bd96fc7c6bb can be found on other testnet3 block explorers.

I am starting to agree that "testnet" is actually not at all useful for testing. Sad

The trouble I'm having with "regtest" is the initial P2SH payment. I am sending to what I think should be a valid testnet/regtest P2SH address 2MyPZMFn1fbyo3udjFQwvutmMheV3t2S1GQ but the payment tx to it looks like this:

Code:
{
    "txid" : "f2c870cda40f8f2134fa6d52ab5629055949f0f7b4e554956934be813dec6807",
    "version" : 1,
    "locktime" : 0,
    "vin" : [
        {
            "coinbase" : "01660101",
            "sequence" : 4294967295
        }
    ],
    "vout" : [
        {
            "value" : 50.00000000,
            "n" : 0,
            "scriptPubKey" : {
                "asm" : "02f0d1b577793c518bf5c3b94f6c0a14637b3d883da7e5f80c6511167e1825bdd1 OP_CHECKSIG",
                "hex" : "2102f0d1b577793c518bf5c3b94f6c0a14637b3d883da7e5f80c6511167e1825bdd1ac",
                "reqSigs" : 1,
                "type" : "pubkey",
                "addresses" : [
                    "mioQggSG7tw6M3ixQcvWYWXmcbDEMYBZz7"
                ]
            }
        }
    ]
}

So instead of this:
OP_HASH160 OP_EQUAL

it has done this:
02f0d1b577793c518bf5c3b94f6c0a14637b3d883da7e5f80c6511167e1825bdd1 OP_CHECKSIG

WTF?
sr. member
Activity: 719
Merit: 250
January 03, 2016, 01:02:15 AM
#60
I cut and pasted your transaction from here into the webbtc page for relaying transactions to testnet3. The page said there was an error because the transaction context was invalid, and rule "prev_out" failed to validate.

I think I basically have the correct raw tx but still Bitcoin won't allow me to send it.

Code:
0100000001bbc6c76fd91bee5badfb0746204adba70efceb04f21a270de566827dbc34e84100000000cc47304402204d5c2b9a9a5a9e467a77d87c0de310c1fa1be7
7f9ff36f640c730a04597046d702207d9388d3d5edb4249215d69e01cc112ab4d1a6dc8c720a5fc2bb2e3c71c4ba87012102d1570ab314b7b32ffe76f31232805a72
7d05119958d14b0b8aff9df5709676884c6076a820c775e7b757ede630cd0aa1113bd102661ab38829ca52a6422ab782862f26864687637576a91401d7295f243a3a
6d26516b54e4e6f51278d376b588ac6703ac9a09b17576a914b6a7c89a6774de8c88d0b7a4043a6645983a479588ac68000000000120a10700000000001976a9148a
7dd4d0e29f50f989dd2b97d463d706a7ef0c7b88ac809c0900





This is the transaction relaying page link, and the error message.

https://test.webbtc.com/relay_tx

Quote
Error: Transaction context invalid.

Rule "prev_out" failed to validate:
Prev out 41e834bc7d8266e50d271af204ebfc0ea7db4a204607fbad5bee1bd96fc7c6bb:0 not found.

Although I searched webbtc for 41e834bc7d8266e50d271af204ebfc0ea7db4a204607fbad5bee1bd96fc7c6bb it couldn't find it.
legendary
Activity: 1890
Merit: 1072
Ian Knowles - CIYAM Lead Developer
January 02, 2016, 06:12:28 AM
#59
Well - I've tried doing this with regtest but unfortunately there seems to be a problem.

Raw tx is as follows:
Code:
010000000194fb5e28b96182167b73934863fdc6cc23502f2574fdca8230b187fcc768171400000000cb4830450221008854a06bb9fd2fc81e9fe01666481e0fc297
d790e34ed9e801895c1ec101f67b02203692fc017ee22da4259260a71c87e89d15d6b0450f2b531859fc99c748b1aad6012102681362f33ab4c48884c5f7f5aaf501
1d53f0584cf0b257c6c3aff8b0b08241b34c5e76a820c775e7b757ede630cd0aa1113bd102661ab38829ca52a6422ab782862f26864687637576a9145e6199a3c0ad
658480247a0f30e314aee23db1eb88ac6701ffb17576a9145e6199a3c0ad658480247a0f30e314aee23db1eb88ac68000000000100f2052a010000001976a9145e61
99a3c0ad658480247a0f30e314aee23db1eb88acff000000

and decoded:
Code:
{
    "txid" : "f6ed82fd7f704bd06c93b9504217ea82209d458595e53f702ad3eb30b528109a",
    "version" : 1,
    "locktime" : 255,
    "vin" : [
        {
            "txid" : "141768c7fc87b13082cafd74252f5023ccc6fd634893737b168261b9285efb94",
            "vout" : 0,
            "scriptSig" : {
                "asm" : "30450221008854a06bb9fd2fc81e9fe01666481e0fc297d790e34ed9e801895c1ec101f67b02203692fc017ee22da4259260a71c87e
89d15d6b0450f2b531859fc99c748b1aad601 02681362f33ab4c48884c5f7f5aaf5011d53f0584cf0b257c6c3aff8b0b08241b3 76a820c775e7b757ede630cd0aa
1113bd102661ab38829ca52a6422ab782862f26864687637576a9145e6199a3c0ad658480247a0f30e314aee23db1eb88ac6701ffb17576a9145e6199a3c0ad65848
0247a0f30e314aee23db1eb88ac68",
                "hex" : "4830450221008854a06bb9fd2fc81e9fe01666481e0fc297d790e34ed9e801895c1ec101f67b02203692fc017ee22da4259260a71c8
7e89d15d6b0450f2b531859fc99c748b1aad6012102681362f33ab4c48884c5f7f5aaf5011d53f0584cf0b257c6c3aff8b0b08241b34c5e76a820c775e7b757ede63
0cd0aa1113bd102661ab38829ca52a6422ab782862f26864687637576a9145e6199a3c0ad658480247a0f30e314aee23db1eb88ac6701ffb17576a9145e6199a3c0a
d658480247a0f30e314aee23db1eb88ac68"
            },
            "sequence" : 0
        }
    ],
    "vout" : [
        {
            "value" : 50.00000000,
            "n" : 0,
            "scriptPubKey" : {
                "asm" : "OP_DUP OP_HASH160 5e6199a3c0ad658480247a0f30e314aee23db1eb OP_EQUALVERIFY OP_CHECKSIG",
                "hex" : "76a9145e6199a3c0ad658480247a0f30e314aee23db1eb88ac",
                "reqSigs" : 1,
                "type" : "pubkeyhash",
                "addresses" : [
                    "mp7zjTrEszZezRBM1cUmTvaK2zf3MuDAHt"
                ]
            }
        }
    ]
}

I can even issue a "signrawtransaction" and I get this:
Code:
{
    "hex" : "010000000194fb5e28b96182167b73934863fdc6cc23502f2574fdca8230b187fcc7681714000000004948304502210089efd7a1beef7bc3eebde1c
874e0f9092419b2e06b6e0643113d82e532b3e22402207f1350abc802da40a274dfb25969819225c9f61ed2852e4106616a6df3dd17fa01000000000100f2052a010
000001976a9145e6199a3c0ad658480247a0f30e314aee23db1eb88acff000000",
    "complete" : true
}

which all looks fine - but when I attempt to send it I get this:
Code:
error: {"code":-26,"message":"16: mandatory-script-verify-flag-failed (Non-canonical DER signature)"}

Sad
jr. member
Activity: 41
Merit: 2
January 02, 2016, 03:36:24 AM
#58
I wonder if the CLTV is not deployed in testnet yet

It could well be that not enough of the testnet peers have upgraded - I think the next step is to play with -regtest rather than -testnet (so you are mining your own blocks).


That's why I quitted using testnet (and people do not stop asking me why I do the tests in mainnet).
I emailed Josh Cincinnati from blockcypher.com and he said it would be better to run the test in our own testnet, or we can also use their testnet.

https://medium.com/blockcypher-blog/testnet-is-not-for-testing-5afa78b1394
legendary
Activity: 1890
Merit: 1072
Ian Knowles - CIYAM Lead Developer
January 02, 2016, 03:13:53 AM
#57
I wonder if the CLTV is not deployed in testnet yet

It could well be that not enough of the testnet peers have upgraded - I think the next step is to play with -regtest rather than -testnet (so you are mining your own blocks).
jr. member
Activity: 41
Merit: 2
January 02, 2016, 01:47:28 AM
#56
If I issue a signrawtransaction with (basically) the same tx I see this:

Code:
{
    "hex" : "0100000001bbc6c76fd91bee5badfb0746204adba70efceb04f21a270de566827dbc34e84100000000cc473044022015c6fca1fb3e8244cfd9a90d1
348d387cb6e8792102be79ecf97cee0246b73b802201162c3acd0a1f915ee46bbf0ec4ee7ab49365c4e48c33502575c2f46298f7249012102d1570ab314b7b32ffe7
6f31232805a727d05119958d14b0b8aff9df5709676884c6076a820c775e7b757ede630cd0aa1113bd102661ab38829ca52a6422ab782862f26864687637576a9140
1d7295f243a3a6d26516b54e4e6f51278d376b588ac6703ac9a09b17576a914b6a7c89a6774de8c88d0b7a4043a6645983a479588ac68000000000120a1070000000
0001976a9148a7dd4d0e29f50f989dd2b97d463d706a7ef0c7b88ac289c0900",
    "complete" : false,
    "errors" : [
        {
            "txid" : "41e834bc7d8266e50d271af204ebfc0ea7db4a204607fbad5bee1bd96fc7c6bb",
            "vout" : 0,
            "scriptSig" : "473044022015c6fca1fb3e8244cfd9a90d1348d387cb6e8792102be79ecf97cee0246b73b802201162c3acd0a1f915ee46bbf0ec4
ee7ab49365c4e48c33502575c2f46298f7249012102d1570ab314b7b32ffe76f31232805a727d05119958d14b0b8aff9df5709676884c6076a820c775e7b757ede63
0cd0aa1113bd102661ab38829ca52a6422ab782862f26864687637576a91401d7295f243a3a6d26516b54e4e6f51278d376b588ac6703ac9a09b17576a914b6a7c89
a6774de8c88d0b7a4043a6645983a479588ac68",
            "sequence" : 0,
            "error" : "Script evaluated without error but finished with a false/empty top stack element"
        }
    ]
}

The question is whether the complete being false is due to an invalid sig or due to the script eval error.


I crafted a tx pair similar to yours (same cltv block and same locktime) in testnet, I think it is correct but it won't be sent to the network.
This is the rawtx
Code:
0100000001de320e8cc248e7fe8fc7e57ec70b0d1bf3a44122f634bf443a2a8fceb39b63c001000000cc473044022026d86fa3239733e866bc4187e6a13813e7db68cb39aceb3837054f7340a1a62002200f5fd9f7c6a0a9d92b4233faac4bb9642584818da737dd51cae4951e01d7839501210260274c034ffc8dc6a2ceb1ff5f31031c593d7005bd286f03c9cadb1bc662961b4c6076a820c775e7b757ede630cd0aa1113bd102661ab38829ca52a6422ab782862f26864687637576a9149d8fe65f4bccb39d510c45ae3bcf9cf0a3a22b0e88ac6703ac9a09b17576a9147abb3052f7090c5379d2af382c84eeab0658488188ac68010000000180c3c901000000001976a9147abb3052f7090c5379d2af382c84eeab0658488188ac289c0900

I wonder if the CLTV is not deployed in testnet yet
legendary
Activity: 1890
Merit: 1072
Ian Knowles - CIYAM Lead Developer
January 01, 2016, 12:43:15 PM
#55
If I issue a signrawtransaction with (basically) the same tx I see this:

Code:
{
    "hex" : "0100000001bbc6c76fd91bee5badfb0746204adba70efceb04f21a270de566827dbc34e84100000000cc473044022015c6fca1fb3e8244cfd9a90d1
348d387cb6e8792102be79ecf97cee0246b73b802201162c3acd0a1f915ee46bbf0ec4ee7ab49365c4e48c33502575c2f46298f7249012102d1570ab314b7b32ffe7
6f31232805a727d05119958d14b0b8aff9df5709676884c6076a820c775e7b757ede630cd0aa1113bd102661ab38829ca52a6422ab782862f26864687637576a9140
1d7295f243a3a6d26516b54e4e6f51278d376b588ac6703ac9a09b17576a914b6a7c89a6774de8c88d0b7a4043a6645983a479588ac68000000000120a1070000000
0001976a9148a7dd4d0e29f50f989dd2b97d463d706a7ef0c7b88ac289c0900",
    "complete" : false,
    "errors" : [
        {
            "txid" : "41e834bc7d8266e50d271af204ebfc0ea7db4a204607fbad5bee1bd96fc7c6bb",
            "vout" : 0,
            "scriptSig" : "473044022015c6fca1fb3e8244cfd9a90d1348d387cb6e8792102be79ecf97cee0246b73b802201162c3acd0a1f915ee46bbf0ec4
ee7ab49365c4e48c33502575c2f46298f7249012102d1570ab314b7b32ffe76f31232805a727d05119958d14b0b8aff9df5709676884c6076a820c775e7b757ede63
0cd0aa1113bd102661ab38829ca52a6422ab782862f26864687637576a91401d7295f243a3a6d26516b54e4e6f51278d376b588ac6703ac9a09b17576a914b6a7c89
a6774de8c88d0b7a4043a6645983a479588ac68",
            "sequence" : 0,
            "error" : "Script evaluated without error but finished with a false/empty top stack element"
        }
    ]
}

The question is whether the complete being false is due to an invalid sig or due to the script eval error.
legendary
Activity: 1890
Merit: 1072
Ian Knowles - CIYAM Lead Developer
January 01, 2016, 12:27:13 PM
#54
Looks like 629420 to me too.

So if the block number isn't the issue then is the sig invalid?

(current testnet3 block is 629899 and that raw tx's nLockTime is 629888)
legendary
Activity: 4018
Merit: 1299
January 01, 2016, 12:26:13 PM
#53
Hmm... I wonder if the problem is the CLTV value itself:

Code:
["ac9a09"]

What block number is that (am a bit tired and really starting to hate Satoshi for using little-endian)?


Looks like 629420 to me too.
staff
Activity: 3374
Merit: 6530
Just writing some code
January 01, 2016, 12:24:27 PM
#52
Hmm... I wonder if the problem is the CLTV value itself:

Code:
["ac9a09"]

What block number is that (am a bit tired and really starting to hate Satoshi for using little-endian)?

That looks like it is block number 629420.
legendary
Activity: 1890
Merit: 1072
Ian Knowles - CIYAM Lead Developer
January 01, 2016, 10:39:14 AM
#51
Hmm... I wonder if the problem is the CLTV value itself:

Code:
["ac9a09"]

What block number is that (am a bit tired and really starting to hate Satoshi for using little-endian)?
legendary
Activity: 1890
Merit: 1072
Ian Knowles - CIYAM Lead Developer
January 01, 2016, 10:21:18 AM
#50
I think I basically have the correct raw tx but still Bitcoin won't allow me to send it.

Code:
0100000001bbc6c76fd91bee5badfb0746204adba70efceb04f21a270de566827dbc34e84100000000cc47304402204d5c2b9a9a5a9e467a77d87c0de310c1fa1be7
7f9ff36f640c730a04597046d702207d9388d3d5edb4249215d69e01cc112ab4d1a6dc8c720a5fc2bb2e3c71c4ba87012102d1570ab314b7b32ffe76f31232805a72
7d05119958d14b0b8aff9df5709676884c6076a820c775e7b757ede630cd0aa1113bd102661ab38829ca52a6422ab782862f26864687637576a91401d7295f243a3a
6d26516b54e4e6f51278d376b588ac6703ac9a09b17576a914b6a7c89a6774de8c88d0b7a4043a6645983a479588ac68000000000120a10700000000001976a9148a
7dd4d0e29f50f989dd2b97d463d706a7ef0c7b88ac809c0900

the decoded version of this:
Code:
{
    "txid" : "ed4861442c7f3fd1c066ce93e335349914750f2c6cdf8778f7a71cec7422aebe",
    "version" : 1,
    "locktime" : 629888,
    "vin" : [
        {
            "txid" : "41e834bc7d8266e50d271af204ebfc0ea7db4a204607fbad5bee1bd96fc7c6bb",
            "vout" : 0,
            "scriptSig" : {
                "asm" : "304402204d5c2b9a9a5a9e467a77d87c0de310c1fa1be77f9ff36f640c730a04597046d702207d9388d3d5edb4249215d69e01cc112
ab4d1a6dc8c720a5fc2bb2e3c71c4ba8701 02d1570ab314b7b32ffe76f31232805a727d05119958d14b0b8aff9df570967688 76a820c775e7b757ede630cd0aa11
13bd102661ab38829ca52a6422ab782862f26864687637576a91401d7295f243a3a6d26516b54e4e6f51278d376b588ac6703ac9a09b17576a914b6a7c89a6774de8
c88d0b7a4043a6645983a479588ac68",
                "hex" : "47304402204d5c2b9a9a5a9e467a77d87c0de310c1fa1be77f9ff36f640c730a04597046d702207d9388d3d5edb4249215d69e01cc1
12ab4d1a6dc8c720a5fc2bb2e3c71c4ba87012102d1570ab314b7b32ffe76f31232805a727d05119958d14b0b8aff9df5709676884c6076a820c775e7b757ede630c
d0aa1113bd102661ab38829ca52a6422ab782862f26864687637576a91401d7295f243a3a6d26516b54e4e6f51278d376b588ac6703ac9a09b17576a914b6a7c89a6
774de8c88d0b7a4043a6645983a479588ac68"
            },
            "sequence" : 0
        }
    ],
    "vout" : [
        {
            "value" : 0.00500000,
            "n" : 0,
            "scriptPubKey" : {
                "asm" : "OP_DUP OP_HASH160 8a7dd4d0e29f50f989dd2b97d463d706a7ef0c7b OP_EQUALVERIFY OP_CHECKSIG",
                "hex" : "76a9148a7dd4d0e29f50f989dd2b97d463d706a7ef0c7b88ac",
                "reqSigs" : 1,
                "type" : "pubkeyhash",
                "addresses" : [
                    "mt9EHSSeERgWKNqYfdmkpa4Mjb4EXr4QY2"
                ]
            }
        }
    ]
}

You can also debug it here: https://webbtc.com/script if you copy and paste this into the Input Script:

Code:
3045022100922dd91ae97909ee6cfa19976e3d072d24521e0e3717d6c1634e190d43131922022064b992db3588651c717777d579c74787daf5d24b3b9651ea4cb38544ff50604501
02d1570ab314b7b32ffe76f31232805a727d05119958d14b0b8aff9df570967688
76a820c775e7b757ede630cd0aa1113bd102661ab38829ca52a6422ab782862f26864687637576a91401d7295f243a3a6d26516b54e4e6f51278d376b588ac6703ac9a09b17576a914b6a7c89a6774de8c88d0b7a4043a6645983a479588ac68

and the following into the Output Script:
Code:
OP_HASH160 5817f2d63208327c21da272a3bb037c3d9ec0269 OP_EQUAL

The error I'm getting when trying to send this raw transaction is as follows:

Code:
error: {"code":-26,"message":"16: mandatory-script-verify-flag-failed (Script evaluated without error but finished with a false/empty top stack element)"}

legendary
Activity: 1890
Merit: 1072
Ian Knowles - CIYAM Lead Developer
December 31, 2015, 11:43:46 PM
#49
I don't really understand the question. Do you mean you cannot produce a valid signature by using your tool? I checked the rawtx you created and indeed the problem is within the signature. webbtc verifies this as well.

I have written code that signs "standard P2PKH" transactions here: https://github.com/ciyam/ciyam/blob/master/src/crypto_keys.cpp#L805 and if you look closely you'll see c_empty_sig_script (which is "00") being placed where the sig later goes (why I was mucking around with the extra 00 above) and also this:

Code:
 signing_info_suffix += c_hash_code_type_all;

which appends "01000000" (only to what is signed rather than what is actually the raw tx).

Basically to manually do a sig I'll need to apply the same approach to non-standard txs (nothing too hard - just some modifications really).

I was actually hoping to just use bitcoin-cli rather than to have to write code though but it's beginning to look like signrawtransaction is not able to do what I am wanting it to.
jr. member
Activity: 41
Merit: 2
December 31, 2015, 05:23:54 PM
#48
I am guessing if I can work out the format that is suitable for signing (which will have that 00 and I think requires another 01000000 to be added at the end of the inputs from memory) then I can manually sign it and then try and send the tx.

Anyone can for sure tell me the hex input for signing?


I don't really understand the question. Do you mean you cannot produce a valid signature by using your tool? I checked the rawtx you created and indeed the problem is within the signature. webbtc verifies this as well.
legendary
Activity: 1890
Merit: 1072
Ian Knowles - CIYAM Lead Developer
December 31, 2015, 11:02:50 AM
#47
I am guessing if I can work out the format that is suitable for signing (which will have that 00 and I think requires another 01000000 to be added at the end of the inputs from memory) then I can manually sign it and then try and send the tx.

Anyone can for sure tell me the hex input for signing?
legendary
Activity: 1890
Merit: 1072
Ian Knowles - CIYAM Lead Developer
December 31, 2015, 10:57:58 AM
#46
Unfortunately no such luck:

Code:
{
    "hex" : "0100000001bbc6c76fd91bee5badfb0746204adba70efceb04f21a270de566827dbc34e84100000000842102d1570ab314b7b32ffe76f31232805a7
27d05119958d14b0b8aff9df5709676884c6076a820c775e7b757ede630cd0aa1113bd102661ab38829ca52a6422ab782862f26864687637576a91401d7295f243a3
a6d26516b54e4e6f51278d376b588ac6703ac9a09b17576a914b6a7c89a6774de8c88d0b7a4043a6645983a479588ac68000000000140420f00000000001976a9145
817f2d63208327c21da272a3bb037c3d9ec026988acac9a0900",
    "complete" : false,
    "errors" : [
        {
            "txid" : "41e834bc7d8266e50d271af204ebfc0ea7db4a204607fbad5bee1bd96fc7c6bb",
            "vout" : 0,
            "scriptSig" : "2102d1570ab314b7b32ffe76f31232805a727d05119958d14b0b8aff9df5709676884c6076a820c775e7b757ede630cd0aa1113bd
102661ab38829ca52a6422ab782862f26864687637576a91401d7295f243a3a6d26516b54e4e6f51278d376b588ac6703ac9a09b17576a914b6a7c89a6774de8c88d
0b7a4043a6645983a479588ac68",
            "sequence" : 0,
            "error" : "Operation not valid with the current stack size"
        }
    ]
}

using the version with the extra 00 at the start of the inputs produces this:
Code:
{
    "hex" : "0100000001bbc6c76fd91bee5badfb0746204adba70efceb04f21a270de566827dbc34e8410000000085002102d1570ab314b7b32ffe76f31232805
a727d05119958d14b0b8aff9df5709676884c6076a820c775e7b757ede630cd0aa1113bd102661ab38829ca52a6422ab782862f26864687637576a91401d7295f243
a3a6d26516b54e4e6f51278d376b588ac6703ac9a09b17576a914b6a7c89a6774de8c88d0b7a4043a6645983a479588ac68000000000140420f00000000001976a91
45817f2d63208327c21da272a3bb037c3d9ec026988acac9a0900",
    "complete" : false,
    "errors" : [
        {
            "txid" : "41e834bc7d8266e50d271af204ebfc0ea7db4a204607fbad5bee1bd96fc7c6bb",
            "vout" : 0,
            "scriptSig" : "002102d1570ab314b7b32ffe76f31232805a727d05119958d14b0b8aff9df5709676884c6076a820c775e7b757ede630cd0aa1113
bd102661ab38829ca52a6422ab782862f26864687637576a91401d7295f243a3a6d26516b54e4e6f51278d376b588ac6703ac9a09b17576a914b6a7c89a6774de8c8
8d0b7a4043a6645983a479588ac68",
            "sequence" : 0,
            "error" : "Script evaluated without error but finished with a false/empty top stack element"
        }
    ]
}
Pages:
Jump to: