Author

Topic: How to transfer/import a segwit (P2SH-P2WPKH) address (and private key) from Arm (Read 418 times)

member
Activity: 270
Merit: 36
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://bitcointalksearch.org/topic/m.27503623


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.
newbie
Activity: 14
Merit: 1
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://bitcointalksearch.org/topic/m.27503623


Edit:  Typo.
newbie
Activity: 14
Merit: 1
Thank you for that, I understand more now, and I know in which direction to continue searching.
legendary
Activity: 3766
Merit: 1364
Armory Developer
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.
newbie
Activity: 14
Merit: 1
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.


legendary
Activity: 3766
Merit: 1364
Armory Developer
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.
newbie
Activity: 14
Merit: 1
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
member
Activity: 270
Merit: 36
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.
newbie
Activity: 14
Merit: 1
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).

member
Activity: 270
Merit: 36
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?
newbie
Activity: 14
Merit: 1
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://bitcointalksearch.org/topic/is-the-transfer-of-a-p2sh-p2pk-addresskey-to-bitcoin-core-doable-2605402
member
Activity: 270
Merit: 36
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.
newbie
Activity: 14
Merit: 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?
Jump to: