Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to sign raw hex tx generated by other software (www.coinb.in) #1811

Closed
antonylewis opened this issue May 24, 2016 · 9 comments
Closed

Comments

@antonylewis
Copy link

antonylewis commented May 24, 2016

It seems that coinb.in and Electrum create different raw transactions and neither can sign each other's raw tx.

Steps to reproduce:

  1. Make and fund a watch-only wallet:
    eg 1PrearGupCpnkFg3RGMTKrkwDDamuREpT3
    Here's the privkey: 5Jvq1Wt7CRG6Wv7gKGp4T1CzPzCYHSiHQeHE61zS1h5NeyUzLnU

Here's the tx with the UTxO I was trying to spend:
9f559d397f8a2ed52fb44193dcc4300b023253511d9493dd2975e36cc9794a23

In Electrum create a new tx:
Send 0.0002825 coins to: 3Fr4pxhgR8tBfmUdyRgdKSfQr4j4dvAsmw
Mining fee: 0.0000895
(this spends the entire UTxO)

You get this raw unsigned tx:
0100000001234a79c96ce37529dd93941d515332020b30c4dc9341b42fd52e8a7f399d559f000000001901ff16fd00fab685c8865dd3161d90fa471cfd65c67c6574c6ffffffff015a6e00000000000017a9149b47edb5dfdc24da15f73273a18246ea4969ac528700000000

Which is:
{
"lock_time":0,
"size":108,
"inputs":[
{
"prev_out":{
"index":0,
"hash":"9f559d397f8a2ed52fb44193dcc4300b023253511d9493dd2975e36cc9794a23"
},
"script":"01ff16fd00fab685c8865dd3161d90fa471cfd65c67c6574c6"
}
],
"version":1,
"vin_sz":1,
"hash":"a7d7c7b33f6fd2607749e19bb8792fb0950b5242d02e2c72b3609985e3a66a85",
"vout_sz":1,
"out":[
{
"script_string":"OP_HASH160 9b47edb5dfdc24da15f73273a18246ea4969ac52 OP_EQUAL",
"address":"3Fr4pxhgR8tBfmUdyRgdKSfQr4j4dvAsmw",
"value":28250,
"script":"a9149b47edb5dfdc24da15f73273a18246ea4969ac5287"
}
]
}

However using the same details, coinb.in generated this different raw unsigned tx:
0100000001234a79c96ce37529dd93941d515332020b30c4dc9341b42fd52e8a7f399d559f000000001976a914fab685c8865dd3161d90fa471cfd65c67c6574c688acffffffff015a6e00000000000017a9149b47edb5dfdc24da15f73273a18246ea4969ac528700000000
I used https://coinb.in/#newTransaction, typed in 1PrearGupCpnkFg3RGMTKrkwDDamuREpT3 and selected the one UTxO that was available)

Which is this:
{
"lock_time":0,
"size":108,
"inputs":[
{
"prev_out":{
"index":0,
"hash":"9f559d397f8a2ed52fb44193dcc4300b023253511d9493dd2975e36cc9794a23"
},
"script":"76a914fab685c8865dd3161d90fa471cfd65c67c6574c688ac"
}
],
"version":1,
"vin_sz":1,
"hash":"4a353f6a7580dd7c4f19fb140328f4378c2ae382f2f65cb88a85ca0e99c7ef5b",
"vout_sz":1,
"out":[
{
"script_string":"OP_HASH160 9b47edb5dfdc24da15f73273a18246ea4969ac52 OP_EQUAL",
"address":"3Fr4pxhgR8tBfmUdyRgdKSfQr4j4dvAsmw",
"value":28250,
"script":"a9149b47edb5dfdc24da15f73273a18246ea4969ac5287"
}
]
}

When I paste the coinb.in raw unsigned tx into Electrum (Tools -> Load Transaction -> from text), I get this:
Transaction unrelated to your wallet
Inputs:
9f559d39...c9794a23:0 unknown

I notice that the "scripts" in the "inputs" section are different, and so of course are the "hash"es... Was wondering why?

Just for fun I pushed both unsigned tx out via https://blockchain.info/pushtx
For the electrum generated one I got: OP_EQUALVERIFY: non-equal data
For the coinb.in generated one I got: Attempted OP_DUP on an empty stack

When I signed each tx respectively, the signed tx were identical:
Electrum signed:
0100000001234a79c96ce37529dd93941d515332020b30c4dc9341b42fd52e8a7f399d559f000000008b483045022100d36e01ebf1d5087f797638347e67f80836e9e154f0536d88b321c9f1f56ff36302206cf382ac6c564e9bdbb1ce5f3c706c0dd69ab6d64521de3c2e57a32faac2a5bf014104a1da3734a1c2e67f418c134bee3399dba1f624dfd3d3c1925ca81b9597e110c2fe9106f206595b17a0c0decb7d24d8cc7c2db20ad8d7127ab1f598734fba6bccffffffff015a6e00000000000017a9149b47edb5dfdc24da15f73273a18246ea4969ac528700000000
(tx id = b0ba95ffaf23137bc954225ee6e6d3f16fd6f68901ff3aae2ae46773b09bf457)

coinb.in signed:
0100000001234a79c96ce37529dd93941d515332020b30c4dc9341b42fd52e8a7f399d559f000000008b483045022100d36e01ebf1d5087f797638347e67f80836e9e154f0536d88b321c9f1f56ff36302206cf382ac6c564e9bdbb1ce5f3c706c0dd69ab6d64521de3c2e57a32faac2a5bf014104a1da3734a1c2e67f418c134bee3399dba1f624dfd3d3c1925ca81b9597e110c2fe9106f206595b17a0c0decb7d24d8cc7c2db20ad8d7127ab1f598734fba6bccffffffff015a6e00000000000017a9149b47edb5dfdc24da15f73273a18246ea4969ac528700000000
(tx id = b0ba95ffaf23137bc954225ee6e6d3f16fd6f68901ff3aae2ae46773b09bf457)

Here's the private key:

I originally documented this as a bug, but I'm not sure any more due to the difference in the input/script.

_Original issue report follows_
There seems to be an issue in Electrum 2.6.4 on OS X 10.10.5 where Electrum can't sign a a message although other software can.

Steps to reproduce:

  1. Create a new bitcoin address, eg:
    Add: 14HkryoBSjLn1mi97YzHZub1evykyn9BLq
    Pub: 036219c7055cf78eefa1f1ff7cb70b7215800a508cf1619507f4ada06bd37e1b2e
    Priv: L2DdzcBhTE6H2moZrzTzEXVPiWXxec3t9gXGNbWnKeqac317RCLY
    (This is a compressed set, but the issue still exists for uncompressed)

Fund it:
I funded it with this tx:
https://blockchain.info/tx/4cf2d34e766e935ed8925621e88763d311a66b328a175b0ca1121172d0cbfa29

  1. Get the keypair into Electrum by restoring a wallet and pasting the Private key (L2DdzcBhTE6H2moZrzTzEXVPiWXxec3t9gXGNbWnKeqac317RCLY). This gives you a 1-address wallet, non HD.
  2. Create a raw hex unsigned transaction which needs to be signed by that address. I used coinb.in to create this:
    010000000129facbd0721112a10c5b178a326ba611d36387e8215692d85e936e764ed3f24c000000001976a9142413a58b05595ff4c135af2bf460096a49c3c4ca88acffffffff01409c00000000000017a9147dcdd7e6a2c9edebbd677dc48ea25e0de099809f8700000000

You can see by decoding it using https://blockchain.info/decode-tx that this uses the funding tx 4cf2d34e766e935ed8925621e88763d311a66b328a175b0ca1121172d0cbfa29 [0] as its input:

{
"lock_time":0,
"size":108,
"inputs":[
{
"prev_out":{
"index":0,
"hash":"4cf2d34e766e935ed8925621e88763d311a66b328a175b0ca1121172d0cbfa29"
},
"script":"76a9142413a58b05595ff4c135af2bf460096a49c3c4ca88ac"
}
],
"version":1,
"vin_sz":1,
"hash":"0ae4c39a05f6ebcc5973483146ae456bf2d8e17336b981a908c9608adbbc4881",
"vout_sz":1,
"out":[
{
"script_string":"OP_HASH160 7dcdd7e6a2c9edebbd677dc48ea25e0de099809f OP_EQUAL",
"address":"3DACymd3MVEmyrSbJwZpDVnGbPAeL4KquP",
"value":40000,
"script":"a9147dcdd7e6a2c9edebbd677dc48ea25e0de099809f87"
}
]
}

  1. In Electrum do Tools -> Transactions -> Load from text; paste the hex transaction in.
    Bug: Electrum says "Transaction unrelated to your wallet" and in the Inputs box it says:
    4cf2d34e...d0cbfa29:0 unknown
    You can see that it has parsed the input tx hash, but it hasn't detected/calculated the address, and there is no "sign" button so the transaction can not be signed in Electrum.
    I was expecting the Inputs box to have the correct address 14HkryoBSjLn1mi97YzHZub1evykyn9BLq
  2. However, this hex is actually signable by the private key - go to https://coinb.in/#sign
    Paste in the private key L2DdzcBhTE6H2moZrzTzEXVPiWXxec3t9gXGNbWnKeqac317RCLY
    Paste in the unsigned tx 010000000129facbd0721112a10c5b178a326ba611d36387e8215692d85e936e764ed3f24c000000001976a9142413a58b05595ff4c135af2bf460096a49c3c4ca88acffffffff01409c00000000000017a9147dcdd7e6a2c9edebbd677dc48ea25e0de099809f8700000000

Click "submit" and you can see it's signable. (try with a different private key and the signed tx is too small and invalid when you try to broadcast it)

You get this signed message: 010000000129facbd0721112a10c5b178a326ba611d36387e8215692d85e936e764ed3f24c000000006b483045022100bf2a1ff725e6891ef20d072f778b42da1b1590202560bcf0223696eda3fa6ae8022018a03399d9ff0cd68585802ab7b8a67d4af35d9bd3b537ec58c51055c69f18bb0121036219c7055cf78eefa1f1ff7cb70b7215800a508cf1619507f4ada06bd37e1b2effffffff01409c00000000000017a9147dcdd7e6a2c9edebbd677dc48ea25e0de099809f8700000000

Which decodes using https://blockchain.info/decode-tx to this:
{
"lock_time":0,
"size":190,
"inputs":[
{
"prev_out":{
"index":0,
"hash":"4cf2d34e766e935ed8925621e88763d311a66b328a175b0ca1121172d0cbfa29"
},
"script":"483045022100bf2a1ff725e6891ef20d072f778b42da1b1590202560bcf0223696eda3fa6ae8022018a03399d9ff0cd68585802ab7b8a67d4af35d9bd3b537ec58c51055c69f18bb0121036219c7055cf78eefa1f1ff7cb70b7215800a508cf1619507f4ada06bd37e1b2e"
}
],
"version":1,
"vin_sz":1,
"hash":"c0d29750bd418cee7d3595ebad0fddaa7fea38a7c202d3ec7af7ad76962518df",
"vout_sz":1,
"out":[
{
"script_string":"OP_HASH160 7dcdd7e6a2c9edebbd677dc48ea25e0de099809f OP_EQUAL",
"address":"3DACymd3MVEmyrSbJwZpDVnGbPAeL4KquP",
"value":40000,
"script":"a9147dcdd7e6a2c9edebbd677dc48ea25e0de099809f87"
}
]
}

This was accepted by the network:
https://tradeblock.com/bitcoin/tx/c0d29750bd418cee7d3595ebad0fddaa7fea38a7c202d3ec7af7ad76962518df

@dabura667
Copy link
Contributor

There is no standard for storing / exchanging unsigned/partially signed transactions.

Until the transactions are signed, anything is fair game, since they're not valid transactions anyways.

@ecdsa
Copy link
Member

ecdsa commented May 29, 2016

probably related to 59d3910

@ecdsa
Copy link
Member

ecdsa commented May 29, 2016

@antonylewis can you check if that commit fixed your issue?

@ecdsa
Copy link
Member

ecdsa commented Aug 2, 2016

closing, no answer from OP

@ecdsa ecdsa closed this as completed Aug 2, 2016
@antonylewis
Copy link
Author

Sorry this was on my backlog but fell off. Will revisit when I can,
apologies.

On Tuesday, 2 August 2016, ThomasV notifications@github.com wrote:

closing, no answer from OP


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#1811 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AEMtFnAml3uTsFQAqooxi1d2CevXHDkYks5qbxh9gaJpZM4IllPw
.

Antony Lewis
+65 9296 4222
Skype: antonylewis
Tweet: @antony_btc
Blog: www.bitsonblocks.net

@off-bank
Copy link

Not fixed - same issue here: creating tx on coinprism. Input address "unknown" and no sign button.

@ecdsa
Copy link
Member

ecdsa commented Aug 19, 2016

@off-bank that's not the same issue.

@off-bank
Copy link

off-bank commented Aug 19, 2016

@ecdsa I believe it is the same issue, as the OP mentions "other software". If I create unsigned tx on coinprism, load raw to electrum (2.6.4), there would be no "sign" button. Input shows "unknown" for the (local) address.
Example of unsigned transaction created on Coinprism that I'm not able to sign in Electrum:

01000000015392c1cbc8c58e8ab433aaeb7e7ee44c06d6d0ce55cb0c8b761de5cae8987328000000001976a9148042e14b00f08c83957c07b0318ae6d5b2e20fdd88acffffffff0280841e00000000001976a9145470ab7467a09b69afc52a63aa95d5734ea9932c88ac207b0400000000001976a9148042e14b00f08c83957c07b0318ae6d5b2e20fdd88ac00000000

image

@XertroV
Copy link
Contributor

XertroV commented Nov 7, 2016

Yo, I had the same problem.

A wild solution appears

Here was my fix:

  • Generate unsigned tx from electrum
  • decode it, find it has a signature-esq-thing in there
  • copy out that bad-sig from the electrum tx
  • paste it in to the right place in my unsigned-tx (from coinb.in)
  • paste that new tx back into electrum
  • WOO now it recognises it

Here's the data:

My bad sig: (notice the 57 prefix which is necessary, also I got this by using bitcoin-cli decoderawtransaction, and then went back to the unsigned electrum tx to get the 57 prefix)

5701ff4c53ff0488b21e00000000000000000027cbd57fd104aadd3438f348c3a249b8e10bd554a2cbf96dffd6f0692b07c454029bd5e398db6e12298b16d164632cf6a2763d140b8780a20b11ec030e7e9473bc00000000

Pre-signed tx from coinb.in

01000000011f05dba7decf669f847e4cfdb8031fb0082355634bcf3cea969408ef17be54fc0100000000ffffffff02e0220200000000001976a91490eb848804f684c66b6e555ac1dc7c362690615c88ac0000000000000000256a234d61784b6179652d6b32303136612d75eebd046158ca1e8c39872f4fff582fe140750200000000

Now, f05dba7decf669f847e4cfdb8031fb0082355634bcf3cea969408ef17be54fc was the previous tx, and output 1 is what I want to sign.

In this case, immediately after that string (very early on) there are the bytes 0100000000ffffffff

  • 01000000 is the input number
  • 00 is the 'sig' from coinb.in
  • ffffffff is the sequence number

I used my bad sig from electrum and replaced it:

01000000011f05dba7decf669f847e4cfdb8031fb0082355634bcf3cea969408ef17be54fc010000005701ff4c53ff0488b21e00000000000000000027cbd57fd104aadd3438f348c3a249b8e10bd554a2cbf96dffd6f0692b07c454029bd5e398db6e12298b16d164632cf6a2763d140b8780a20b11ec030e7e9473bc00000000ffffffff02e0220200000000001976a91490eb848804f684c66b6e555ac1dc7c362690615c88ac0000000000000000256a234d61784b6179652d6b32303136612d75eebd046158ca1e8c39872f4fff582fe140750200000000

And viola electrum recognised it as unsigned and allowed me to sign and send.

I don't know if my bad-sig will work for you (try just pasting that in first) but this should help anyone down the line make this work.

Toporin pushed a commit to Toporin/electrum-satochip that referenced this issue Jul 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants