Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: wsxdrfv on June 12, 2018, 02:48:06 AM



Title: getbalance, sendtoaddress require full sync with recent chain data?
Post by: wsxdrfv on June 12, 2018, 02:48:06 AM
So I want to make cold wallet, so for that, I will buy another computer and install VM ware, install ubuntu, install coin-core program.

And then, generate address from there. Then if I send coin from outside, is cold wallet's coin core program can use console commands like

[getbalance], [sendtoaddress] ?

or it need to be synced, download most recent blockchain datas?

Because if this is true cold wallet, then it should be disconnected with internet, so I want to maintain this computer with unplugged internet lan cable.

Then when need to check balance or send coin to another address from cold wallet computer, then I should wait for sync?

Then, if I need to send fastly, cold wallet computer is also should be connected with internet?

How to solve this problem?

Thanks.


Title: Re: getbalance, sendtoaddress require full sync with recent chain data?
Post by: Heisenberg_Hunter on June 12, 2018, 06:08:48 AM
Your understanding of cold wallets might be certainly wrong. A cold wallet holds your private keys securely by not exposing them online. This means that the wallet can hold only your keys (which controls your bitcoins) and the bitcoins are present in the public ledger. If you need to spend a cold wallet balances, you need to import the keys to a hot wallet or you need to use the wallet online. A cold wallet is used for storing coins for long terms and you should not use them for sending your coins often.

Then if I send coin from outside, is cold wallet's coin core program can use console commands like [getbalance], [sendtoaddress] ?
or it need to be synced, download most recent blockchain datas?
getbalance command is used to check the balance of an account. If the blockchain is not synced, you won't be able to see the balances of the wallet and the core wallet will return the balance as 0. sendtoaddress command is used to send the coins to an address. If the blockchain gets synced completely and if you are sure of the number of bitcoins present you can perform this. If you didn't sync the wallet and try to send the bitcoins higher than what is present in your wallet, your transaction won't get broadcasted in the network.

Because if this is true cold wallet, then it should be disconnected with internet, so I want to maintain this computer with unplugged internet lan cable.
You are completely confused and you need to read what is a Cold Storage (https://en.bitcoin.it/wiki/Cold_storage).

Then when need to check balance or send coin to another address from cold wallet computer, then I should wait for sync?
You need to check the cold wallet address balance in blockchain.info or any other wallet explorer

Then, if I need to send fastly, cold wallet computer is also should be connected with internet?
Use a light weight wallet (electrum, multibit) or a paper wallet instead if you are willing to store your keys offline.


Title: Re: getbalance, sendtoaddress require full sync with recent chain data?
Post by: pebwindkraft on June 12, 2018, 07:55:37 AM
So I want to make cold wallet, so for that, I will buy another computer and install VM ware, install ubuntu, install coin-core program.

And then, generate address from there. Then if I send coin from outside, is cold wallet's coin core program can use console commands like

[getbalance], [sendtoaddress] ?

or it need to be synced, download most recent blockchain datas?
Good, right approach. The cold wallet is only used to sign a transaction. You would not use the cold wallet to do things like „getbalnace“ or „sendtoaddress“.

Quote
Because if this is true cold wallet, then it should be disconnected with internet, so I want to maintain this computer with unplugged internet lan cable.

Then when need to check balance or send coin to another address from cold wallet computer, then I should wait for sync?
The cold wallet will never connect to the internet, and will never download the blockchain. This means, you cannot check balances on the cold wallet.

The procedure to go would most likely look like this:
1. Create an address on the cold storage system
2. Bring this address into the second wallet, which is connected to the internet (the hot wallet, or the live system). As mentioned by Heisenberg_Hunter, make this a watch only address in the hot wallet. Then you can see at all times the balance on this address.
3. On the hot wallet you can now create a transaction, and save it as raw transaction on a USB stick or similar.
4. Bring the USB stick to your cold storage system, load the transaction into the wallet, and sign it.
5. After signature, store it again on USB stick, and bring it to the hot wallet system
6. send the transaction.

The procedures how to load addresses or save/export transactions vary from wallet to wallet.
Hint: you are already,playing with virtual machines, try to setup a test environment, and play e.g. with „regtest“, that will give you the opportunity to get familiar with the process, before losing anything on the live environment.



Title: Re: getbalance, sendtoaddress require full sync with recent chain data?
Post by: NeuroticFish on June 12, 2018, 08:06:32 AM
If you need to spend a cold wallet balances, you need to import the keys to a hot wallet or you need to use the wallet online.

No! If your private keys went online, you can't really call that a cold wallet anymore.

If you want to spend, you generate transaction from a view wallet, then SIGN it from the cold wallet. The safest is when the private keys of the cold wallet should not go online.
The transactions can be saved and loaded and you can transfer between the online computer and offline computer via USB.

The rest is already explained better than I tried :)




Title: Re: getbalance, sendtoaddress require full sync with recent chain data?
Post by: HCP on June 12, 2018, 09:54:04 AM
So I want to make cold wallet, so for that, I will buy another computer and install VM ware, install ubuntu, install coin-core program.
Why would you want to install VM ware??!? Surely, you'd just install Ubuntu directly on the new computer? ???


Title: Re: getbalance, sendtoaddress require full sync with recent chain data?
Post by: NeuroticFish on June 12, 2018, 10:05:48 AM
So I want to make cold wallet, so for that, I will buy another computer and install VM ware, install ubuntu, install coin-core program.
Why would you want to install VM ware??!? Surely, you'd just install Ubuntu directly on the new computer? ???

Maybe he bought the computer with licensed Windows 10 and wants to keep it.
Also, afaik VMWare needs license, while there's the free option of using VirtualBox (https://www.virtualbox.org/)!


Title: Re: getbalance, sendtoaddress require full sync with recent chain data?
Post by: bob123 on June 12, 2018, 10:40:22 AM
So I want to make cold wallet, so for that, I will buy another computer and install VM ware, install ubuntu, install coin-core program.
Why would you want to install VM ware??!? Surely, you'd just install Ubuntu directly on the new computer? ???
Maybe he bought the computer with licensed Windows 10 and wants to keep it.

Why would someone need windows 10 installed on a computer which is not being used at all (except for cold storage with linux) ?

If it truly is a dedicated cold storage computer, it 1) should under no circumstances go online and 2) should not be used for anything else than storing cryptos.
I can't see a single reason why someone should keep windows installed and run a virtual machine on such a computer to access his wallet.



Title: Re: getbalance, sendtoaddress require full sync with recent chain data?
Post by: MrCrank on June 12, 2018, 12:10:12 PM
So I want to make cold wallet, so for that, I will buy another computer and install VM ware, install ubuntu, install coin-core program.

And then, generate address from there. Then if I send coin from outside, is cold wallet's coin core program can use console commands like

[getbalance], [sendtoaddress] ?

or it need to be synced, download most recent blockchain datas?

Because if this is true cold wallet, then it should be disconnected with internet, so I want to maintain this computer with unplugged internet lan cable.

Then when need to check balance or send coin to another address from cold wallet computer, then I should wait for sync?

Then, if I need to send fastly, cold wallet computer is also should be connected with internet?

How to solve this problem?

Thanks.


Where you read this info?
It's wrong.
ubuntu + bitcoin core is not cold wallet, it's online wallet (but this is not web wallet online).
For using console commands need full sync blockchain db.

Try use paper wallet bitaddress.org




Title: Re: getbalance, sendtoaddress require full sync with recent chain data?
Post by: HCP on June 12, 2018, 10:13:45 PM
Where you read this info?
It's wrong.
ubuntu + bitcoin core is not cold wallet, it's online wallet (but this is not web wallet online).
Where did you read this?

Ubuntu+Bitcoin Core can be used as a "cold wallet" setup... IF the Ubuntu computer is not connected to any networks once Ubuntu and Bitcoin Core have been downloaded and installed.

You can then setup another copy on an online computer and just import your addresses from the offline computer as watching only addresses.

Granted, Bitcoin Core isn't exactly geared towards operating as an "offline+online" two computer setup... And is a bit cumbersome to operate like this. But it does "work".

There are probably better options than Bitcoin Core for this type of workflow.


Title: Re: getbalance, sendtoaddress require full sync with recent chain data?
Post by: Hamzahaddane on June 13, 2018, 12:40:19 AM
sure the cold wallets can not send coins.
for me i use a computer syn to the latest blockchain, when i want send coins i use the stoaged cold wallet.dat replace the syned wallet.dat and after sended, i dele it in the pc and useback the syned wallet.dat.


Title: Re: getbalance, sendtoaddress require full sync with recent chain data?
Post by: MrCrank on June 13, 2018, 06:26:03 AM
Where you read this info?
It's wrong.
ubuntu + bitcoin core is not cold wallet, it's online wallet (but this is not web wallet online).
Where did you read this?

Ubuntu+Bitcoin Core can be used as a "cold wallet" setup... IF the Ubuntu computer is not connected to any networks once Ubuntu and Bitcoin Core have been downloaded and installed.

You can then setup another copy on an online computer and just import your addresses from the offline computer as watching only addresses.

Granted, Bitcoin Core isn't exactly geared towards operating as an "offline+online" two computer setup... And is a bit cumbersome to operate like this. But it does "work".

There are probably better options than Bitcoin Core for this type of workflow.


I know this.
Details here https://en.bitcoin.it/wiki/Cold_storage
Agree with you that "IF the Ubuntu computer is not connected to any networks".
I see this idea is unuseful.
Cold wallet can't send bitcoin..


Title: Re: getbalance, sendtoaddress require full sync with recent chain data?
Post by: NeuroticFish on June 13, 2018, 08:04:17 AM
Cold wallet can't send bitcoin..

Cold wallet is not supposed to send Bitcoin. Cold wallet only signs transactions.

You build the transaction on the view wallet (which is online), you save it to USB stick, go to the cold wallet, sign it, go back to the online computer and broadcast it.
Not very straightforward, but certainly safe.


Title: Re: getbalance, sendtoaddress require full sync with recent chain data?
Post by: bob123 on June 13, 2018, 08:21:13 AM
for me i use a computer syn to the latest blockchain, when i want send coins i use the stoaged cold wallet.dat replace the syned wallet.dat and after sended, i dele it in the pc and useback the syned wallet.dat.

Does this mean you are moving your 'cold storage' wallet file to your online pc to make a transaction?
This should be avoided under all circumstances!

Private keys of a cold wallet are supposed to stay offline all the time.

To spend from a cold wallet you have to create an unsigned transaction (on an online machine), move it to your offline pc, sign it, move it to your online pc and broadcast it.
Or, use a hardware wallet.

But do NOT consider a wallet which you move to an online computer occasionally as a cold wallet.


Title: Re: getbalance, sendtoaddress require full sync with recent chain data?
Post by: CryptOliver on June 13, 2018, 10:12:43 AM
GetBalance and listaccounts returns an incorrect balance (testnet)

Problem: The testnet account Testnet "elmo" shows a balance of 1.02 but should show 0.01.

bitcoin-cli -testnet getinfo {"version": 100000, "protocolversion": 70002, "walletversion": 60000, "balance": 2.66964380, "blocks": 350108, "timeoffset": 0, "connections": 0, " proxy ":" "," difficulty ": 1.00000000," testnet ": true," keypoololdest ": 1426225664," keypoolsize ": 101," paytxfee ": 0.00000000," relayfee ": 0.00001000," errors ":" "} bitcoin -cli -testnet listaccounts {"": 1.64964380, "elmo": 1.02000000,} bitcoin-cli -testnet getbalance elmo 1.02000000 bitcoin-cli -testnet listreceivedbyaccount 1 true [{"account": "", "amount": 2.06080000, " confirmations ": 1040}, {" account ":" elmo "," amount ": 1.02000000," confirmations ": 22149},
However when using listunspent to check UTXO in the wallet, there is only one UTXO set for "elmo" account and this UTXO shows a 0.01 balance.

 { "Txid": "42e2579dd090415713510c5cc58aa13afd14cfc2a1fb6ebee873afc169927e8b", "vout": 0, "address": "myZ2mEYZt1CyRPgdE6oXRbAJWbaaTtTwRi", "account": "elmo", "scriptPubKey": "76a914c5d6d3854e653be3c31e66d322cb0a05cb0a17c888ac", "amount": 0.01000000, "confirmations": 22 149 , "spendable": true}
Here are two addresses associated with "elmo" account

 bitcoin-cli -testnet getaddressesbyaccount elmo ["mkwLg4ARNWimVW1Bh9uxv9SKdfNnPHRHWr", "myZ2mEYZt1CyRPgdE6oXRbAJWbaaTtTwRi"]
Two separate explorer blocks report the balances of each address as:

http://tbtc.blockr.io/address/info/myZ2mEYZt1CyRPgdE6oXRbAJWbaaTtTwRi
https://www.blocktrail.com/tBTC/address/myZ2mEYZt1CyRPgdE6oXRbAJWbaaTtTwRi
0.01

http://tbtc.blockr.io/address/info/mkwLg4ARNWimVW1Bh9uxv9SKdfNnPHRHWr
https://www.blocktrail.com/tBTC/address/mkwLg4ARNWimVW1Bh9uxv9SKdfNnPHRHWr
0

So it seems that bitcoin returns the wrong balance of 1.02 instead of 0.01.


Title: Re: getbalance, sendtoaddress require full sync with recent chain data?
Post by: starmyc on June 13, 2018, 10:31:13 AM
GetBalance and listaccounts returns an incorrect balance (testnet)


You should open a new topic because this is a totally unrelated problem.

Problem: The testnet account Testnet "elmo" shows a balance of 1.02 but should show 0.01.

bitcoin-cli -testnet getinfo {"version": 100000, "protocolversion": 70002, "walletversion": 60000, "balance": 2.66964380, "blocks": 350108, "timeoffset": 0, "connections": 0, " proxy ":" "," difficulty ": 1.00000000," testnet ": true," keypoololdest ": 1426225664," keypoolsize ": 101," paytxfee ": 0.00000000," relayfee ": 0.00001000," errors ":" "} bitcoin -cli -testnet listaccounts {"": 1.64964380, "elmo": 1.02000000,} bitcoin-cli -testnet getbalance elmo 1.02000000 bitcoin-cli -testnet listreceivedbyaccount 1 true [{"account": "", "amount": 2.06080000, " confirmations ": 1040}, {" account ":" elmo "," amount ": 1.02000000," confirmations ": 22149},

Your client is not up to date, as you have only 350108 blocks when there is more than 1.3 M currently in the testnet chain. Please synchronize it and you'll get correct balances.


Title: Re: getbalance, sendtoaddress require full sync with recent chain data?
Post by: wsxdrfv on July 01, 2018, 01:11:23 PM

The procedure to go would most likely look like this:
1. Create an address on the cold storage system
2. Bring this address into the second wallet, which is connected to the internet (the hot wallet, or the live system). As mentioned by Heisenberg_Hunter, make this a watch only address in the hot wallet. Then you can see at all times the balance on this address.
3. On the hot wallet you can now create a transaction, and save it as raw transaction on a USB stick or similar.
4. Bring the USB stick to your cold storage system, load the transaction into the wallet, and sign it.
5. After signature, store it again on USB stick, and bring it to the hot wallet system
6. send the transaction.

The procedures how to load addresses or save/export transactions vary from wallet to wallet.  

Thanks, but I totally don't understand what this means and how to do this actually, I never heard about this. So this is so-called [multi-sig] wallet? or?

How to perform this procedure actually?

2. Bring this address into the second wallet, -> How? Commands?

3. -> How? This is not [sendtoaddress]?

4. load the transaction into the wallet, and sign it. -> How? I don't know at all.

5. bring it to the hot wallet system -> How?

6. ?? finally [sendtoaddress]?


And how about coins that does not have this features?


Title: Re: getbalance, sendtoaddress require full sync with recent chain data?
Post by: wsxdrfv on July 01, 2018, 01:42:21 PM
So this is it?

https://gist.github.com/gavinandresen/3966071

Looks too complicated...


and https://en.bitcoin.it/wiki/Multisignature


Then hot-cold wallet storage divide scenario is 2 of 2? not 2 of 3.


Title: Re: getbalance, sendtoaddress require full sync with recent chain data?
Post by: HCP on July 02, 2018, 12:31:01 AM
Thanks, but I totally don't understand what this means and how to do this actually, I never heard about this. So this is so-called [multi-sig] wallet? or?
No... it isn't a multi-sig. It is describing a a two computer (1 online, 1 offline "air-gapped") setup


2. Bring this address into the second wallet, which is connected to the internet (the hot wallet, or the live system). As mentioned by Heisenberg_Hunter, make this a watch only address in the hot wallet. Then you can see at all times the balance on this address.
How to perform this procedure actually?
2. Bring this address into the second wallet, -> How? Commands?
- For Bitcoin Core, you would simply use importaddress - This will create a "watching-only" copy of the address within the second wallet.
- Other wallets have their own methods for creating watching-only addresses/wallets.


3. On the hot wallet you can now create a transaction, and save it as raw transaction on a USB stick or similar.
3. -> How? This is not [sendtoaddress]?
- Using Bitcoin Core, you would use createrawtransaction - This creates an "unsigned" transaction, but will include the inputs and outputs for the transaction. You then copy/paste the output from createrawtransaction into a text document and copy it to USB stick.
- Again, other wallets have their own methods, Electrum for instance (http://docs.electrum.org/en/latest/coldstorage.html), you simply create a new "send" transaction, but instead of "sign" and/or "broadcast", you click "save". This will allow you to create a text document that contains the raw, unsigned transaction (or you can even create it as a QR Code)


4. Bring the USB stick to your cold storage system, load the transaction into the wallet, and sign it.
4. load the transaction into the wallet, and sign it. -> How? I don't know at all.
- For Bitcoin Core, you would use the signrawtransaction command. Basically, you copy/paste the output from the "createrawtransaction" command used in step 3. This will give you ANOTHER raw transaction in "hex" format, only this time it is signed.
NOTE: If your "offline" computer is properly air-gapped, it won't be synced, so you would need to provide the appropriate "output" info. However, you shouldn't need to explicitly provide the private keys as your offline wallet should have the private key for the address you're attempting to sign with.
- For a wallet like Electrum, you use the "Tools -> Load Transaction -> From File" option, then click "Sign"


5. After signature, store it again on USB stick, and bring it to the hot wallet system
5. bring it to the hot wallet system -> How?
Now you
- For Bitcoin Core, it is simply the reverse of Step 3. You copy/paste the signed raw transaction "hex" output from the signrawtransaction commmand on offline computer into another text file... and put it onto the USB stick and take that to online computer.
- For Electrum, once you clicked "sign", you can then "save" the transaction and save it as a text file onto the USB stick etc.


6. send the transaction.
6. ?? finally [sendtoaddress]?
- Bitcoin Core uses the sendrawtransaction command. You copy/paste the signed raw transaction hex from text file.
- Electrum uses "Tools -> Load Transaction -> From File"... then you click "broadcast"



So this is it?
https://gist.github.com/gavinandresen/3966071
Not quite... that is using Multi-Sig, which requires partially signing transactions and sending them to a third-party to counter-sign. But you can see examples of the "createrawtransaction" and "signrawtransaction" and "sendrawtransaction" commands. Albeit, very complicated ones, as they require multiple keys to sign etc.


Quote
Looks too complicated...
You're right Bitcoin Core is a bit of a nuisance to use in a two computer, air-gapped setup... it wasn't exactly designed for such a use-case... but can be used to achieve it. Easier options exist like Electrum which have explicit "Save Transaction" and "Import Transaction" features that are designed to facilitate air-gapped setups (http://docs.electrum.org/en/latest/coldstorage.html)... or Armory (https://btcarmory.com/) which requires your own Bitcoin Core node on the online system but was designed with the whole offline/online setup in mind. NOTE: Armory is an advanced wallet and NOT for beginners.


Title: Re: getbalance, sendtoaddress require full sync with recent chain data?
Post by: wsxdrfv on July 02, 2018, 09:17:02 AM
You're right Bitcoin Core is a bit of a nuisance to use in a two computer, air-gapped setup... it wasn't exactly designed for such a use-case... but can be used to achieve it. Easier options exist like Electrum which have explicit "Save Transaction" and "Import Transaction" features that are designed to facilitate air-gapped setups (http://docs.electrum.org/en/latest/coldstorage.html)... or Armory (https://btcarmory.com/) which requires your own Bitcoin Core node on the online system but was designed with the whole offline/online setup in mind. NOTE: Armory is an advanced wallet and NOT for beginners.
Thanks!

So Electrum is not the choice if I installed bitcoin core for some web service?


Title: Re: getbalance, sendtoaddress require full sync with recent chain data?
Post by: HCP on July 03, 2018, 03:25:51 AM
It will all depend on your specific use-case and requirements. Without knowing exactly what it is that you're trying to achieve, it is difficult to recommend any solution over any other solution.

Electrum is an "SPV" (aka lite) wallet... so will connect to public Electrum servers to send/receive etc. You could theoretically run a private Electrum server alongside your Bitcoin Core node and specify that it connect only to your server if you wanted. The Linux version of Electrum (and I believe the MacOSX version as well) support CLI... so there are options for scripting/automation etc... however the Windows version does not.

Bitcoin Armory is built to use a full Bitcoin Core node as it's base data source. It is very powerful and offers a lot of options, but can be confusing and a bit complicated to inexperienced users. I believe there is also a CLI interface, but I've never used it, so I'm not sure what you can actually do with it.

Bitcoin Core in an "air gapped" setup is quite labour intensive and requires a lot of "manual" work having to create, sign and broadcast transactions using CLI (or console), but these things can be scripted/automated using bitcoin-cli etc.

I'm sure there are other options available... like just using a hardware wallet or even something like "BitKey (https://bitkey.io/)" or TailsOS (https://tails.boum.org/) that offer "air gapped" solutions.