BTCPrivate / BitcoinPrivate-legacy

Bitcoin Private is a Bitcoin and Zclassic fork which uses ZK-SNARK technology for privacy and fungibility.
Other
283 stars 132 forks source link

Error importing P2WPKH-P2SH Bitcoin Private Key #124

Closed jmarcott86 closed 6 years ago

jmarcott86 commented 6 years ago

Describe the issue

I have a BTC wallet using Segwit P2WPKH-P2SH addresses, and I'm unable to import these keys into the full node wallet. I get an "Invalid private key encoding" error message. I am able to import these keys into the Electrum-btcp wallet and it shows the correct balance, but I'm unable to spend these coins as they need to be shielded first, being coinbase outputs.

Can you reliably reproduce the issue?

Yes

If so, please list the steps to reproduce below:

  1. Run the btcpd full node
  2. Attempt to import a P2WPKH-P2SH Bitcoin Private Key using 'btcp-cli importprivkey "privatekey"'

Expected behaviour

The private key should be imported into the wallet and the coinbase transaction credited to that address during the fork should be discovered and spendable

Actual behaviour + errors

The wallet fails to import the private key with the following error:

error code: -5 error message: Invalid private key encoding

version of Bitcoin Private you were using: Bitcoin Private Daemon version v1.0.10-1-965bdbe

Ayms commented 6 years ago

You can consider using https://github.com/Ayms/bitcoin-transactions

See also https://bitcointalk.org/index.php?topic=2827163.msg31273044#msg31273044 (simple examples, same applies for p2sh/multisig addresses)

jmarcott86 commented 6 years ago

Awesome, so your tool just creates the raw transaction and lets you broadcast it to a node without needing to go through the wallet? Thanks, I'll have to take a look.

Ayms commented 6 years ago

Yes

122 looks to be the same

jmarcott86 commented 6 years ago

Actually, from what I can see your tool wouldn't work for me. It doesn't support zk-snarks transactions, and in order to spend coinbase outputs I need to shield them first. I'll have to wait until they add support for Bitcoin segwit addresses in the core wallet.

Ayms commented 6 years ago

Actually, from what I can see your tool wouldn't work for me. It doesn't support zk-snarks transactions, and in order to spend coinbase outputs I need to shield them first. I'll have to wait until they add support for Bitcoin segwit addresses in the core wallet.

Not sure what you are referring to, all transactions are the same, there are no zk-snarks transactions neither shielded ones

AH1111 commented 6 years ago

So how to get the xprv keys from the electrum BTC wallet on a pc...... when I search for xprv all I see is the following.
image

AH1111 commented 6 years ago

I have the xpub keys so that I can use them to use a multisig wallet, but the xprv is what I don't have

Ayms commented 6 years ago

Did you try https://iancoleman.io/bip39/ ? (do it offline of course)

You need to find the private keys corresponding to the multisig redeem script of the output you want to spend (see https://github.com/Ayms/bitcoin-transactions#multisig-wallets-2)

If you have move the coins on ZCL or BTC it's more easy to get the redeem script, you can see it in the transactions

Maybe email me if you want

Ayms commented 6 years ago

Actually, from what I can see your tool wouldn't work for me. It doesn't support zk-snarks transactions, and in order to spend coinbase outputs I need to shield them first. I'll have to wait until they add support for Bitcoin segwit addresses in the core wallet.

Not sure what you are referring to, all transactions are the same, there are no zk-snarks transactions neither shielded ones

@jmarcott86 My mistake here, indeed the tool does not support shielded txs, not sure if it does worth implementing it, I thought it was rarely used

AH1111 commented 6 years ago

Man, this is so confusing.....and we have done alot in this space with masternodes etc.....so we aren't idiots.......but I cannot figure out how or if it is possible to get the xprv's from my wife's Electrum BTC wallet, the wallet that she set up as 2fa........I cannot believe how difficult this is for me. I just don't think I'm going to be able to ever claim this BTCP and every time we open an issue ticket on github it is answered and they close it as if we have solved the problem. WE ARE NOT PROGRAMMERS. Can you help?

I followed your example mentioned above about extracting Bitcoin Gold from the electrum thinking it might be similar. We've created a wallet that is not 2fa protected and not password protected and we can see the coins and it says [2fa] at the title and we didn't worry about that.....and then we went and looked for the .dat file and can't find it. We are using a mac. that is as far as we can get.

On Mon, Mar 5, 2018 at 6:01 AM, Aymeric Vitte notifications@github.com wrote:

Did you try https://iancoleman.io/bip39/ ? (do it offline of course)

You need to find the private keys corresponding to the multisig redeem script of the output you want to spend (see https://github.com/Ayms/ bitcoin-transactions#multisig-wallets-2)

If you have move the coins on ZCL or BTC it's more easy to get the redeem script, you can see it in the transactions

Maybe email me if you want

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/BTCPrivate/BitcoinPrivate/issues/124#issuecomment-370384609, or mute the thread https://github.com/notifications/unsubscribe-auth/AiYxNqpAF531qtp4xHIBSCakGQG19jPdks5tbRskgaJpZM4SbG2r .

jmarcott86 commented 6 years ago

@AH1111 Please keep your questions in your own tickets. This isn't the repo for the electrum wallet anyway. For that you want https://github.com/BTCPrivate/electrum-btcp.

Now, I'm assuming you're trying to follow the instructions here, right? https://support.btcprivate.org/445098-Common-Post-Fork-Issues-READ-FIRST---BTCP---Mar-4th-2018

That's telling you do go in your appdata folder (C:\Users{yourusername}\AppData\Roaming\Electrum\wallets) and find your wallet file and open it up in notepad. If you have a password set and have encrypted your wallet, it'll just be gibberish. In that case, you need to go to the change password dialog, enter your current password, and leave both the "new password" and "confirm password" boxes blank. This'll remove the encryption, and when you open the wallet file in notepad you should see it start with { "addr_history": {

From there, you can search for the xprv key. You should be able to use this to create a new BTCP wallet. I guess you'll need to get the second xprv key from your wife's wallet as well, since you'll need both of them to be able to spend the coins.

AH1111 commented 6 years ago

Sorry, didn't realize I was on someone else's ticket. I was just responding to an email that Aymerric Vitte sent me. Thanks.

On Mon, Mar 5, 2018 at 9:13 PM, jmarcott86 notifications@github.com wrote:

@AH1111 https://github.com/ah1111 Please keep your questions in your own tickets. This isn't the repo for the electrum wallet anyway. For that you want https://github.com/BTCPrivate/electrum-btcp.

Now, I'm assuming you're trying to follow the instructions here, right? https://support.btcprivate.org/445098-Common-Post-Fork- Issues-READ-FIRST---BTCP---Mar-4th-2018

That's telling you do go in your appdata folder (C:\Users{yourusername}\ AppData\Roaming\Electrum\wallets) and find your wallet file and open it up in notepad. If you have a password set and have encrypted your wallet, it'll just be gibberish. In that case, you need to go to the change password dialog, enter your current password, and leave both the "new password" and "confirm password" boxes blank. This'll remove the encryption, and when you open the wallet file in notepad you should see it start with { "addr_history": {

From there, you can search for the xprv key. You should be able to use this to create a new BTCP wallet. I guess you'll need to get the second xprv key from your wife's wallet as well, since you'll need both of them to be able to spend the coins.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/BTCPrivate/BitcoinPrivate/issues/124#issuecomment-370636936, or mute the thread https://github.com/notifications/unsubscribe-auth/AiYxNqvY9PjgL5jEx_MXxNXeNckl6Zjdks5tbfDMgaJpZM4SbG2r .

Ayms commented 6 years ago

@AH1111 github sent the email... if you reply to it, it will be posted here... I suppose that you have fixed the issue, I can help to a certain extent (then you can email me in private) but I am not an Electrum expert at all and probably all that we can find to solve the very same issue will allow you to solve it

ch4ot1c commented 6 years ago

@jmarcott86 please reopen this if you need further assistance. I think your question is legitimate but would like more detail. AH1111 has been helped & resolved; I worked with him yesterday.