Bitcoin Forum
June 29, 2024, 11:54:54 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: How to transfer/import a segwit (P2SH-P2WPKH) address (and private key) from Arm  (Read 398 times)
RaviMoll (OP)
Newbie
*
Offline Offline

Activity: 14
Merit: 1


View Profile
January 02, 2018, 08:59:01 PM
 #1

How to transfer/import a segwit (P2SH-P2WPKH) address (and private key) from Armory to Bitcoin Core?

How can I transfer & import the private key of a segwit (P2SH-P2WPKH) address from Armory into Bitcoin core?

I searched quite a fair bit and couldn't manage to do it.

I can export the private key (Base58) from Armory just fine, but when I import that into Bitcoin core (through the console) it gives me a legacy "1" address that doesn't correspond to my segwit address.

It seems I need to use the command "addwitnessaddress", but I do not know which legacy "1" address I should specify, nor how to find it.


What am I doing wrong here, and how could I do that?
PhoenixFire
Member
**
Offline Offline

Activity: 270
Merit: 36


View Profile
January 02, 2018, 11:26:21 PM
 #2

I take it you've tried using the output address from the import as the address for addwitnessaddress?
Unless I've done something wrong while testing that, that doesn't work either. Core's segwit support in 0.15.x is not quite ready yet from what I've read - Going on discussion from their github I'm pretty sure 0.16 will offer compatibility with standard P2SH-P2WPKH, though.
RaviMoll (OP)
Newbie
*
Offline Offline

Activity: 14
Merit: 1


View Profile
January 02, 2018, 11:43:13 PM
 #3

Yes, I've done that, and it simply gave me another segwit (3-) address, which was not my original segwit address.  The way I understand it (and I might be wrong) is that Core can generate a segwit address from a legacy (1-, P2PKH) address, and that's what "addwitnessaddress" does.

So it seems to me that I have to find the "original" legacy (P2PKH) address that Armory used to generate a segwit address?  But I couldn't find it anywhere within Armory.

I am pretty sure that it is possible to import segwit (P2SH-P2WPKH) addresses into Bitcoin Core, based on the conversation between goatpig and achow101 here:  https://bitcointalk.org/index.php?topic=2605402.0
PhoenixFire
Member
**
Offline Offline

Activity: 270
Merit: 36


View Profile
January 02, 2018, 11:53:54 PM
 #4

So it seems to me that I have to find the "original" legacy (P2PKH) address that Armory used to generate a segwit address?  But I couldn't find it anywhere within Armory.
Right, but that isn't how Armory generates the addresses nor, as far as I know, how the standard works. There isn't normally a corresponding legacy address for each segwit address. Core's addwitnessaddress is a bit of a stopgap until proper support is there, which may only be a few weeks away.

Happy to be corrected here.

Are you wanting to move your coins and are basically stuck without a working Armory setup currently?
RaviMoll (OP)
Newbie
*
Offline Offline

Activity: 14
Merit: 1


View Profile
January 03, 2018, 12:02:02 AM
 #5

Are you wanting to move your coins and are basically stuck without a working Armory setup currently?

No, Armory works fine.  I actually believe it is the best available wallet at the moment.

I want to do this for 2 main reasons:
1- To be sure to be able to successfully export my keys/addresses and access coins in case I run into an issue with Armory in the future.  That is, to not be 100% dependent (or "stuck") on a single system, or a single point of failure.
2- To be able to export specific keys/addresses into other bitcoin forks' clients (after having emptied those keys, obviously).

PhoenixFire
Member
**
Offline Offline

Activity: 270
Merit: 36


View Profile
January 03, 2018, 12:21:10 AM
 #6

Are you wanting to move your coins and are basically stuck without a working Armory setup currently?

No, Armory works fine.  I actually believe it is the best available wallet at the moment.

I want to do this for 2 main reasons:
1- To be sure to be able to successfully export my keys/addresses and access coins in case I run into an issue with Armory in the future.  That is, to not be 100% dependent (or "stuck") on a single system, or a single point of failure.
2- To be able to export specific keys/addresses into other bitcoin forks' clients (after having emptied those keys, obviously).

Good to hear!

Sound reasoning, most come in here after a problem has reared its head rather than before.
For Core, honestly 0.16 should resolve the issue.
But for now you might be able to try Electrum. I know by default it opts for bech32 addresses and native (rather than nested) segwit, but I swear I read that it can use/import P2SH-P2WPKH with a bit of poking.


Word of warning on your second point, if an adversary gets ahold of one of your private keys AND has your root public key they can generate backwards and forward on the chain to get the other private keys within that wallet too. Make sure your empty that wallet, not just the keys.
Relevant posts from goatpig here and here.
RaviMoll (OP)
Newbie
*
Offline Offline

Activity: 14
Merit: 1


View Profile
January 03, 2018, 12:47:35 AM
 #7

Are you wanting to move your coins and are basically stuck without a working Armory setup currently?

No, Armory works fine.  I actually believe it is the best available wallet at the moment.

I want to do this for 2 main reasons:
1- To be sure to be able to successfully export my keys/addresses and access coins in case I run into an issue with Armory in the future.  That is, to not be 100% dependent (or "stuck") on a single system, or a single point of failure.
2- To be able to export specific keys/addresses into other bitcoin forks' clients (after having emptied those keys, obviously).

Good to hear!

Sound reasoning, most come in here after a problem has reared its head rather than before.
For Core, honestly 0.16 should resolve the issue.
But for now you might be able to try Electrum. I know by default it opts for bech32 addresses and native (rather than nested) segwit, but I swear I read that it can use/import P2SH-P2WPKH with a bit of poking.


Word of warning on your second point, if an adversary gets ahold of one of your private keys AND has your root public key they can generate backwards and forward on the chain to get the other private keys within that wallet too. Make sure your empty that wallet, not just the keys.
Relevant posts from goatpig here and here.

That's a very important piece of information I didn't know.  Thank you for that.  Cycling wallets (and not only keys), and obviously making proper backups, is an important step to do beforehand then.

I prefer to avoid using Electrum, at least for now, as I do not like the idea of being dependent and a third-party server to access coins.  I think that running full nodes is healthier for the entire network.  But thank you for suggesting that.

Back to my initial question:
How to import a segwit P2SH-P2WPKH keys into bitcoin core, as it is right now?

I am sure that goatpig knows if/how this can be done, but I do not want to send him a direct PM to ask.  It is best if those discussions are public so that it can help other people in the future too.  Smiley
goatpig
Moderator
Legendary
*
Offline Offline

Activity: 3682
Merit: 1347

Armory Developer


View Profile
January 04, 2018, 04:00:44 PM
 #8

This is a question for the recipient wallet, not the origin wallet, i.e. ask Core. I have no experience with the Core wallet, so I can't help you there.

RaviMoll (OP)
Newbie
*
Offline Offline

Activity: 14
Merit: 1


View Profile
January 04, 2018, 04:14:17 PM
Last edit: January 04, 2018, 04:46:19 PM by RaviMoll
 #9

This is a question for the recipient wallet, not the origin wallet, i.e. ask Core. I have no experience with the Core wallet, so I can't help you there.

Thank you for your answer - much appreciated.

(Just to clarify, when I mention "Core", I mean the original Bitcoin client/wallet - i.e. the same one that Armory requires to run.)

I somehow thought that being able to export private keys in a standard way was a regular feature of Armory, so that we could use them elsewhere in case of need.

My understanding of Segwit is far from being complete, and so I had the impression that I needed to extract or export something else from Armory (the redeem script?) in order to input it in the Bitcoin core client - but I cannot find where/how to export that.


Edit:  Typo.


goatpig
Moderator
Legendary
*
Offline Offline

Activity: 3682
Merit: 1347

Armory Developer


View Profile
January 04, 2018, 04:46:29 PM
 #10

the redeem script?)

No, there's no such thing in private key exporting. The target wallet has to know what to do with the private key.

Quote
I somehow thought that being able to export private keys in a standard way was a regular feature of Armory, so that we could use them elsewhere in case of need.

It's not. There is no standard for interoperability between wallets, this is a free for all. P2SH-P2WPKH is a standard SW script type described in the BIP, any SegWit compliant wallet is expected to support that script type to claim compliance. What you need to figure out is how to instruct the receiving wallet to instantiate the associated address as nested SW.

RaviMoll (OP)
Newbie
*
Offline Offline

Activity: 14
Merit: 1


View Profile
January 04, 2018, 05:20:36 PM
 #11

Thank you for that, I understand more now, and I know in which direction to continue searching.
RaviMoll (OP)
Newbie
*
Offline Offline

Activity: 14
Merit: 1


View Profile
January 05, 2018, 04:14:31 AM
Merited by STT (1)
 #12

I found the solution, and I am posting here in case it could be useful for others in the future, too:

Basically, I didn't manage to import properly earlier because  "Segwit only allows compressed public keys, but Armory only uses uncompressed public keys. In order to use Segwit, Armory will compress the keys on-the-fly, but the export will still give you the uncompressed version."

So I simply needed to get the compressed version of the private key (namely, the compressed WIF private key) from the (uncompressed) WIF private key that Armory was giving me.
I used a local version of bitaddress.org (taken from the repo at  https://github.com/pointbiz/bitaddress.org  )  to do that.

Credits and thanks to achow101 for telling me that (and full detailed instructions in case other people might need it):
https://bitcointalk.org/index.php?topic=2689834.msg27503623#msg27503623


Edit:  Typo.
PhoenixFire
Member
**
Offline Offline

Activity: 270
Merit: 36


View Profile
January 05, 2018, 03:19:23 PM
 #13

I found the solution, and I am posting here in case it could be useful for others in the future, too:

Basically, I didn't manage to import properly earlier because  "Segwit only allows compressed public keys, but Armory only uses uncompressed public keys. In order to use Segwit, Armory will compress the keys on-the-fly, but the export will still give you the uncompressed version."

So I simply needed to get the compressed version of the private key (namely, the compressed WIF private key) from the (uncompressed) WIF private key that Armory was giving me.
I used a local version of bitaddress.org (taken from the repo at  https://github.com/pointbiz/bitaddress.org  )  to do that.

Credits and thanks to achow101 for telling me that (and full detailed instructions in case other people might need it):
https://bitcointalk.org/index.php?topic=2689834.msg27503623#msg27503623


Edit:  Typo.

Good to know it is possible.
I know you're not keen on Electrum but as a reference for others, I tried this with Electrum beforehand. Using bitaddress.org as above, but changing
Code:
ECKey.privateKeyPrefix = 0x80;
to
Code:
ECKey.privateKeyPrefix = 0x82;
will spit out a Compressed Private Key in WIF that can be imported into Electrum and refers to the correct P2SH-P2WPKH address.
Pages: [1]
  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!