Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: kbdwarrior on September 23, 2017, 09:47:58 PM



Title: Problems importing private key from paper wallet to bitcoin-qt
Post by: kbdwarrior on September 23, 2017, 09:47:58 PM
For testing purposes I sent some BTC to a paper wallet from my bitcoin-qt client and later, after ~50 confirmations I imported the private key from the paper wallet back into bitcoin-qt with the command

Code:
importprivkey $key $label rescan

and after finishing the rescan it doesn't show anything. Well, almost nothing, it renamed the paperwallet address I sent to in the first place to "$label" in the outgoing transaction, but no other sign of the imported private key, especially the balance didn't change. The Blockchain explorer shows that the funds are still under the associated paper wallet address.

Can anybody explain why the funds don't show up under balance, what I did wrong, and how importing a private key into bitcoin-qt is done correctly?

Thanks!


Title: Re: Problems importing private key from paper wallet to bitcoin-qt
Post by: achow101 on September 23, 2017, 11:45:32 PM
What are you using to run this command?

Are you sure that $key refers to the actual private key string? Does the private key begin with a '5', 'K', or 'L'?

Is Bitcoin Core fully synced?


Title: Re: Problems importing private key from paper wallet to bitcoin-qt
Post by: HCP on September 24, 2017, 03:51:35 AM
Since that address is now part of your wallet after the import... Could it be that Bitcoin Core is now treating it as though you just sent the funds to yourself??

Does the "outgoing" transaction now show in the transaction list as type "Payment to yourself" with a net value of just the transaction fee? Something like this:
https://talkimg.com/images/2023/11/15/zeusP.png




Title: Re: Problems importing private key from paper wallet to bitcoin-qt
Post by: kbdwarrior on September 24, 2017, 11:22:26 AM
I used the debug window -> console to run the commands. The $key was fine and beginning with a 5 and the node was fully synced.

After a good nights sleep I opened my bitcoin-qt again and the display had changed.

Ok, originally I did the following:

Sent from my bitstamp account to bitcoin-qt:
0.29498000
received in bitcoin-qt:
0.29498000
where's the fee gone here? Why does this tx not show any fee?

Then sent to my paperwallet:
0.20000000
what cost me a fee of
0.00032399
this tx showing up in my bitcoin-qt as, well I don't remember exactly, I should have taken a screenshot
Anyway, there ended up on my paper wallet address
0.01967601
then I imported the private key as written in my OP and all that changed was the display of the paper wallet address as $label that I assigned when doing the import

Today, after ~12 hours I restarted the bitcoin-qt and now it shows the fee of the tx to the paper wallet as a payment to myself
-0.00032399
and the balance of my wallet is now
0.29465601

So everything adds up as it should. Why didn't the bitcoin-qt show that immediately after the rescan?

When I look at the tx of the "payment to myself" with "gettransaction" in the console, I see the fee, the amount on the paper wallet once as "spend" and once as "receive" and the address of the paper wallet.

So obviously everything is ok, I'm only confused, partially by my lack of understanding of bitcoin transactions, partially by the weird interface of bitcoin-qt.

Thanks for your help.

Edit:

Now I spent everything in my bitcoin-qt wallet to a new address making another payment to myself, just to be sure that bitcoin-qt really controls the paper wallet key, and the balance of the paper wallet is now zero on the blockchain explorer, and everything is moved to the new address (minus fee). So everything works as expected, except the bitcoin-qt UI, that's a bit weird.


Title: Re: Problems importing private key from paper wallet to bitcoin-qt
Post by: LoyceV on September 25, 2017, 09:00:50 AM
Why didn't the bitcoin-qt show that immediately after the rescan?
All I can think of is that somehow your Bitcoin Core wasn't synced completely. I've done this same procedure before, and it always worked out just fine.

I do have two recommendations for the future:
1. Use smaller amounts to get familiar with paper wallets. Instead of testing things with $800, use $2.
2. Before funding a paper wallet, import the address (not the private key!) into Bitcoin Core:
    importaddress 1addy PaperWallet1addy false
    The "false" prevents a rescan. If you fund the paper wallet after this, it shows up as Watch-only and the balance is nicely updated. Since Bitcoin Core now knows your balance, you can later import the private key without a rescan.


Title: Re: Problems importing private key from paper wallet to bitcoin-qt
Post by: kbdwarrior on September 25, 2017, 11:41:30 AM
Thanks for the tip, will try this!


Title: Re: Problems importing private key from paper wallet to bitcoin-qt
Post by: kbdwarrior on September 25, 2017, 03:03:38 PM
More questions to this:

2. Before funding a paper wallet, import the address (not the private key!) into Bitcoin Core:
    importaddress 1addy PaperWallet1addy false
    The "false" prevents a rescan. If you fund the paper wallet after this, it shows up as Watch-only and the balance is nicely updated. Since Bitcoin Core now knows your balance, you can later import the private key without a rescan.

You emphasize the before, importing an address cannot be done after funding the paper wallet?

And if I hold private keys with some UTXOs at the corresponding address in the bitcoin-qt wallet and one or several watch-only addresses as well and this is all intermingled together to a single balance, how can I differentiate what values are spendable from the bitcoin-qt wallet and what belongs to the paper wallets?

Thx!


Title: Re: Problems importing private key from paper wallet to bitcoin-qt
Post by: LoyceV on September 25, 2017, 03:33:29 PM
You emphasize the before, importing an address cannot be done after funding the paper wallet?
Of course you can always import any watch-only address. The only benefit from doing it before funding it, is that you don't need a rescan.
If the address is funded already, any import requires a rescan to show an accurate balance. Importing unfunded watch-only addresses saves time, that's all.

Quote
And if I hold private keys with some UTXOs at the corresponding address in the bitcoin-qt wallet and one or several watch-only addresses as well and this is all intermingled together to a single balance, how can I differentiate what values are spendable from the bitcoin-qt wallet and what belongs to the paper wallets?
Bitcoin Core adds a new column "Watch-only", like this:
https://bitcoin.org/img/bitcoin-core/clear-overview.png


Title: Re: Problems importing private key from paper wallet to bitcoin-qt
Post by: kbdwarrior on September 25, 2017, 04:00:34 PM
Thanks, you're the man! Very helpful!