Bitcoin Forum
May 05, 2024, 06:39:20 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1] 2 »  All
  Print  
Author Topic: Exporting a SegWit wallet Private Keys on Bitcoin Core 0.15  (Read 2118 times)
miguelmorales85 (OP)
Hero Member
*****
Offline Offline

Activity: 544
Merit: 506


View Profile
September 16, 2017, 08:49:28 AM
 #1

Hello, I want to export my private keys for a SegWit wallet I created in Bitcoin Core 0.14

Currently I'm using Bitcoin Core 0.15
I did the usual procedure:
- walletpassphrase "passphrase" 600
- dumpprivkey "MySegWit-address-starting-in-3"

Then I got this error message:
Address does not refer to a key (code -3)


I check out the error code and is the following:
RPC_TYPE_ERROR                  = -3,  //! Unexpected type was passed as parameter

Is this a bug? Can some one confirm if its possible to export the private keys for a SegWit address in Bitcoin Core?
1714934360
Hero Member
*
Offline Offline

Posts: 1714934360

View Profile Personal Message (Offline)

Ignore
1714934360
Reply with quote  #2

1714934360
Report to moderator
1714934360
Hero Member
*
Offline Offline

Posts: 1714934360

View Profile Personal Message (Offline)

Ignore
1714934360
Reply with quote  #2

1714934360
Report to moderator
1714934360
Hero Member
*
Offline Offline

Posts: 1714934360

View Profile Personal Message (Offline)

Ignore
1714934360
Reply with quote  #2

1714934360
Report to moderator
"This isn't the kind of software where we can leave so many unresolved bugs that we need a tracker for them." -- Satoshi
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
Lauda
Legendary
*
Offline Offline

Activity: 2674
Merit: 2965


Terminated.


View Profile WWW
September 16, 2017, 11:28:54 AM
 #2

How exactly did you add this address to the wallet?

Hello, I want to export my private keys for a SegWit wallet I created in Bitcoin Core 0.14
There is no such thing as a "SegWit wallet".

"The Times 03/Jan/2009 Chancellor on brink of second bailout for banks"
😼 Bitcoin Core (onion)
AStorio
Full Member
***
Offline Offline

Activity: 156
Merit: 100


View Profile
September 16, 2017, 11:39:31 AM
 #3

address-starting-in-3 it's multisig address, not SegWit-address

   SEMUX   -   An innovative high-performance blockchain platform   
▬▬▬▬▬      Powered by Semux BFT consensus algorithm      ▬▬▬▬▬
Github    -    Discord    -    Twitter    -    Telegram    -    Get Free Airdrop Now!
Lauda
Legendary
*
Offline Offline

Activity: 2674
Merit: 2965


Terminated.


View Profile WWW
September 16, 2017, 11:48:02 AM
 #4

address-starting-in-3 it's multisig address, not SegWit-address
Segwit addresses start with an '3' (at least the current implementation of SW addresses). Do not respond to things which you clearly have no knowledge about.

"The Times 03/Jan/2009 Chancellor on brink of second bailout for banks"
😼 Bitcoin Core (onion)
miguelmorales85 (OP)
Hero Member
*****
Offline Offline

Activity: 544
Merit: 506


View Profile
September 16, 2017, 01:37:06 PM
 #5

How exactly did you add this address to the wallet?

Hello, I want to export my private keys for a SegWit wallet I created in Bitcoin Core 0.14
There is no such thing as a "SegWit wallet".

Hello Lauda, I followed the procedure to create a SegWit address using the command line interface from Bitcoin Core 0.14:
- addwitnessaddress "address"

Now that I think about it, I dont remember the address I used to create that one. I am a bit confused right now.

Is this SegWit enabled address binded to another wallet? That is not what I believe address work.
Lauda
Legendary
*
Offline Offline

Activity: 2674
Merit: 2965


Terminated.


View Profile WWW
September 16, 2017, 01:59:36 PM
 #6

Hello Lauda, I followed the procedure to create a SegWit address using the command line interface from Bitcoin Core 0.14:
- addwitnessaddress "address"
That's correct, so you must have one of the following (known to the wallet)[1]:
1) Public key.
2) Redeem script.

Now that I think about it, I dont remember the address I used to create that one. I am a bit confused right now.

Is this SegWit enabled address binded to another wallet? That is not what I believe address work.
You need to remember what P2SH is and how it works. The current Segwit addresses are basically encapsulated in P2SH which makes it a tad more complicated (bech32 will be native Segwit and much better/easier).

[1] Unfortunately I don't have any Segwit addresses in Bitcoin Core to test and guide you through your inquiry. I have tested the command with a SW address generated in another wallet. You should look for the redeem script/related private keys.

"The Times 03/Jan/2009 Chancellor on brink of second bailout for banks"
😼 Bitcoin Core (onion)
miguelmorales85 (OP)
Hero Member
*****
Offline Offline

Activity: 544
Merit: 506


View Profile
September 16, 2017, 02:23:49 PM
 #7

Hello Lauda, I followed the procedure to create a SegWit address using the command line interface from Bitcoin Core 0.14:
- addwitnessaddress "address"
That's correct, so you must have one of the following (known to the wallet)[1]:
1) Public key.
2) Redeem script.

Now that I think about it, I dont remember the address I used to create that one. I am a bit confused right now.

Is this SegWit enabled address binded to another wallet? That is not what I believe address work.
You need to remember what P2SH is and how it works. The current Segwit addresses are basically encapsulated in P2SH which makes it a tad more complicated (bech32 will be native Segwit and much better/easier).

[1] Unfortunately I don't have any Segwit addresses in Bitcoin Core to test and guide you through your inquiry. I have tested the command with a SW address generated in another wallet. You should look for the redeem script/related private keys.

Well, the address I used is definitely one of the other I have in my wallet. I dont know if there is such script to redeem.

Do you think I should report the issue to github?

I think there got to be a procedure to export the private key of the segwit enabled addresses.

Thanks for your help

Lauda
Legendary
*
Offline Offline

Activity: 2674
Merit: 2965


Terminated.


View Profile WWW
September 16, 2017, 02:25:51 PM
 #8

Well, the address I used is definitely one of the other I have in my wallet. I dont know if there is such script to redeem.
Every P2SH address, which that one is, has a redeem script. Read here: https://bitcoin.stackexchange.com/questions/52271/where-are-p2sh-full-redeem-scripts-stored.

Do you think I should report the issue to github?
Not yet.

I think there got to be a procedure to export the private key of the segwit enabled addresses.
I'm going forward with two questions for you:
1) How do you generate/add P2SH addresses to Bitcoin Core?
2) How do you export a P2SH address from Bitcoin Core?

Note: I'm talking about normal multisignature addresses.

"The Times 03/Jan/2009 Chancellor on brink of second bailout for banks"
😼 Bitcoin Core (onion)
miguelmorales85 (OP)
Hero Member
*****
Offline Offline

Activity: 544
Merit: 506


View Profile
September 16, 2017, 02:46:07 PM
 #9


I'm going forward with two questions for you:
1) How do you generate/add P2SH addresses to Bitcoin Core?
2) How do you export a P2SH address from Bitcoin Core?

Note: I'm talking about normal multisignature addresses.

I am learning to use Bitcoin Core cli, I'm kinda noob.

I have not generated a multi-signature address using Bitcoin Core so I've never exported one.

I just wanted to create my first SegWit address and now that I have received some funds in it I wanted to backup my privkey. I have created my wallet backup I just wanted to test the priv key export solution.

I'll take a look at information in the URL.
Lauda
Legendary
*
Offline Offline

Activity: 2674
Merit: 2965


Terminated.


View Profile WWW
September 16, 2017, 03:01:21 PM
 #10

I am learning to use Bitcoin Core cli, I'm kinda noob.

I have not generated a multi-signature address using Bitcoin Core so I've never exported one.
Then rethink what you're doing here. You're asking me whether you should open an issue because X is happening, even though you don't know what the right behavior is supposed to be. Don't rush into things.

Quote
So what information is encoded in a P2SH address? A specific unspent Bitcoin can actually have a whole range of different spending conditions attached to it, the most common being a typical P2PKH which just requires the recipient to provide a signature matching the public key hash. The Bitcoin core developers realized that people were looking at the capabilities of Bitcoin's Script language and seeing a whole array of possibilities about what spending conditions you could attach to a Bitcoin output, to create much more elaborate transactions than just P2PKH transactions. The core developers decided that instead of letting senders put in long scripts into their scriptPubKey (where spending conditions usually go), they would let each sender put in a hash of their spending conditions instead. These spending conditions are known as the redeem script, and a P2SH funding transaction simply contains a hash of this redeem script in the scriptPubKey of the funding transaction.The redeem script itself is only revealed, checked against the redeem script hash, and evaluated during the spending transaction.
Source (the whole piece if very useful / I'd recommend reading): http://www.soroushjp.com/2014/12/20/bitcoin-multisig-the-hard-way-understanding-raw-multisignature-bitcoin-transactions/. Segwit in it's current form is encapsulated in P2SH.

Again disclaimer: I have not used any SW stuff with Bitcoin Core yet, thus I'm just basing this on my knowledge of P2SH and SW, which should be correct (or mostly correct).

"The Times 03/Jan/2009 Chancellor on brink of second bailout for banks"
😼 Bitcoin Core (onion)
jackg
Copper Member
Legendary
*
Offline Offline

Activity: 2856
Merit: 3071


https://bit.ly/387FXHi lightning theory


View Profile
September 16, 2017, 11:19:35 PM
 #11

Hello Lauda, I followed the procedure to create a SegWit address using the command line interface from Bitcoin Core 0.14:
- addwitnessaddress "address"
That's correct, so you must have one of the following (known to the wallet)[1]:
1) Public key.
2) Redeem script.

Now that I think about it, I dont remember the address I used to create that one. I am a bit confused right now.

Is this SegWit enabled address binded to another wallet? That is not what I believe address work.
You need to remember what P2SH is and how it works. The current Segwit addresses are basically encapsulated in P2SH which makes it a tad more complicated (bech32 will be native Segwit and much better/easier).

[1] Unfortunately I don't have any Segwit addresses in Bitcoin Core to test and guide you through your inquiry. I have tested the command with a SW address generated in another wallet. You should look for the redeem script/related private keys.

Well, the address I used is definitely one of the other I have in my wallet. I dont know if there is such script to redeem.

Do you think I should report the issue to github?

I think there got to be a procedure to export the private key of the segwit enabled addresses.

Thanks for your help

A segwit address, afaik will have to have something that can be produced from a normal address.

Open "help" > "debug" > "console".
Then try dumpprivkey address again but with the legacy address. Import that into a segwit accepting service
achow101
Moderator
Legendary
*
Offline Offline

Activity: 3388
Merit: 6581


Just writing some code


View Profile WWW
September 17, 2017, 01:43:42 AM
 #12

addwitnessaddress was primarily a shim to facilitate testing of segwit. It was not really meant to be widely used by users for segwit.

Segwit addresses beginning with a '3' are actually P2SH addresses. This means that the address itself is mapped to a script (after all, it is Pay-to-script-hash), not to a private key. From there the parts of the script itself are mapped to a private key. However dumpprivkey does not go that deep, it only takes things that are mapped directly to a private key, which are P2PKH addresses and public keys. Segwit addresses are not mapped to a private key because they are really just P2SH addresses. So using dumpprivkey with segwit addresses will return an error (as will using any other P2SH address).

To get the private key of the address, you need to take the address that you used addwitnessaddress on originally and call dumpprivkey on that address.

miguelmorales85 (OP)
Hero Member
*****
Offline Offline

Activity: 544
Merit: 506


View Profile
September 18, 2017, 06:37:47 PM
 #13

addwitnessaddress was primarily a shim to facilitate testing of segwit. It was not really meant to be widely used by users for segwit.

Segwit addresses beginning with a '3' are actually P2SH addresses. This means that the address itself is mapped to a script (after all, it is Pay-to-script-hash), not to a private key. From there the parts of the script itself are mapped to a private key. However dumpprivkey does not go that deep, it only takes things that are mapped directly to a private key, which are P2PKH addresses and public keys. Segwit addresses are not mapped to a private key because they are really just P2SH addresses. So using dumpprivkey with segwit addresses will return an error (as will using any other P2SH address).

To get the private key of the address, you need to take the address that you used addwitnessaddress on originally and call dumpprivkey on that address.

Hello, thank you for your reply. Do you know if there is a plan to start using , as a regular user, the SegWit addresses?
I think that if we need to show to the users that SegWit is the right path to take at least the Bitcoin Core should start implementing it.
I will take a look at GreenBit wallet to see how they implemented the SegWit solution.

What I do not understand is why P2SH address does not come from a private key, arent multi-signatures addresses generated from private keys? The more I know about BTC the more I get to think that I know nothing. Huh



Quote
So what information is encoded in a P2SH address? A specific unspent Bitcoin can actually have a whole range of different spending conditions attached to it, the most common being a typical P2PKH which just requires the recipient to provide a signature matching the public key hash. The Bitcoin core developers realized that people were looking at the capabilities of Bitcoin's Script language and seeing a whole array of possibilities about what spending conditions you could attach to a Bitcoin output, to create much more elaborate transactions than just P2PKH transactions. The core developers decided that instead of letting senders put in long scripts into their scriptPubKey (where spending conditions usually go), they would let each sender put in a hash of their spending conditions instead. These spending conditions are known as the redeem script, and a P2SH funding transaction simply contains a hash of this redeem script in the scriptPubKey of the funding transaction.The redeem script itself is only revealed, checked against the redeem script hash, and evaluated during the spending transaction.
Source (the whole piece if very useful / I'd recommend reading): http://www.soroushjp.com/2014/12/20/bitcoin-multisig-the-hard-way-understanding-raw-multisignature-bitcoin-transactions/. Segwit in it's current form is encapsulated in P2SH.

Again disclaimer: I have not used any SW stuff with Bitcoin Core yet, thus I'm just basing this on my knowledge of P2SH and SW, which should be correct (or mostly correct).

Thank for the URL Lauda. I will read it, hope it is not so crypto-technical
Yogafan00000
Sr. Member
****
Offline Offline

Activity: 314
Merit: 251



View Profile
October 03, 2017, 12:52:30 PM
 #14

I'm in the same situation as OP.

I wanted to try a segwit address to receive some funds from an exchange.

So I generated a new regular address (the old way) then I went to console and did command addwitnessaddress newaddress and got another address with starting with 3

Then, with the intent of confirming I own the keys, I tried dumprivkey on the new segwit address and got the same error as OP.

I would love some knowledge to weigh in on what I'm dealing with, at a practical level.

What exactly is this segwit address I have starting with 3, and why's there no privatekey to it?
What happens if I send funds to it? Is the balance held under the orig address?
What's the difference between this and the first non-segwit address?
Why should I use 1 over the other?


TIA!!

1YogAFA... (oh, nevermind)
achow101
Moderator
Legendary
*
Offline Offline

Activity: 3388
Merit: 6581


Just writing some code


View Profile WWW
October 03, 2017, 03:14:07 PM
 #15

What exactly is this segwit address I have starting with 3, and why's there no privatekey to it?
Read the thread, I already explained above.

What happens if I send funds to it? Is the balance held under the orig address?
No, it is held under the '3' address.

Addresses and public-private key pairs are different things. A public-private key pair can be associated with many different addresses, not just one '1' address.

What's the difference between this and the first non-segwit address?
It uses segwit.

Why should I use 1 over the other?
Segwit has lower transaction fees.

Lauda
Legendary
*
Offline Offline

Activity: 2674
Merit: 2965


Terminated.


View Profile WWW
October 03, 2017, 03:30:34 PM
 #16

Do you know if there is a plan to start using , as a regular user, the SegWit addresses?
Yes, obviously. Bitcoin Core 0.15.1 or 0.16.0 will have GUI support for SegWit.

I think that if we need to show to the users that SegWit is the right path to take at least the Bitcoin Core should start implementing it.
I will take a look at GreenBit wallet to see how they implemented the SegWit solution.
You can use SegWit easily in plenty of other wallets, e.g. Ledger.

What I do not understand is why P2SH address does not come from a private key, arent multi-signatures addresses generated from private keys? The more I know about BTC the more I get to think that I know nothing. Huh
I've told you to do your research and achow has explained it. P2SH is mapped to a script, which itself is mapped to private keys. So, if you have a 2 of 3 multisig address you can't "dumpprivkey" on it. You run "dumpprivkey" on the two addresses (or all three) that were used to create the script, ergo the multisig address.

"The Times 03/Jan/2009 Chancellor on brink of second bailout for banks"
😼 Bitcoin Core (onion)
Yogafan00000
Sr. Member
****
Offline Offline

Activity: 314
Merit: 251



View Profile
October 03, 2017, 07:18:06 PM
 #17


(stuff that achow101 said)


thank you for the answers you provide. I appreciate your time.

What I ended up doing just for today is creating another legacy address on my core wallet and just using that one for my transaction.

I'm sure segwit is great and everything, but I can't afford a headache today if I somehow fuckit up.

I'll try another segwit transaction some other time when I have a more clear understanding of all implications of using segwit addresses from core.

1YogAFA... (oh, nevermind)
miguelmorales85 (OP)
Hero Member
*****
Offline Offline

Activity: 544
Merit: 506


View Profile
October 03, 2017, 07:47:19 PM
 #18

I think I will not use SegWit address until the process is more user friendly on the Bitcoin Core client.

I wanted to test some transactions and use the new address created to mode some satoshis but I guess I will wait for 0.15.1 ... 0.16... etc

Thank guys for the explanation, there are a lot of great mind in the forum  Cool
Lauda
Legendary
*
Offline Offline

Activity: 2674
Merit: 2965


Terminated.


View Profile WWW
October 04, 2017, 06:40:53 AM
 #19

I'm sure segwit is great and everything, but I can't afford a headache today if I somehow fuckit up.
I don't see any possible mistake that you could run into while not doing anything not out of the ordinary.

I'll try another segwit transaction some other time when I have a more clear understanding of all implications of using segwit addresses from core.
I think I will not use SegWit address until the process is more user friendly on the Bitcoin Core client.
Use a different wallet in the meantime (if you want to use SegWit), as I've said.

"The Times 03/Jan/2009 Chancellor on brink of second bailout for banks"
😼 Bitcoin Core (onion)
miguelmorales85 (OP)
Hero Member
*****
Offline Offline

Activity: 544
Merit: 506


View Profile
October 12, 2017, 11:41:45 AM
 #20

I have done some exploration in blockchain.info and found this details into my SegWit address:
it has a Hash 160 associated (as do all bitcoin addresses)

When I click on this Hash 160 code I get to another bitcoin address. Could it be this is the original address I used to generated my SegWit address??

I have not found a way to discover my original address from which I generated the SegWit one.
Pages: [1] 2 »  All
  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!