3

I know we can send coins using the move, sendtoaddress and sendfrom commands from the console or commandline.

However these commands require to specify an "exact" amount, meaning you need to check the balance before you execute the commands.

Is it possible to just send all coins to an address or to oneself in the same wallet using just one command.

Hopefully someone understands what I"m talking about here.

3

Yes, this is possible, but you still need to check the wallet balance first.

However, you need to know the fee, as you usually specify how many BTC are supposed to arrive at the destination, rather than how much is being sent in total.

The sendtoaddress command takes 5 parameters: address, amount, comment, comment-to, subtractfeefromamount. This last option, subtractfeefromamount, is what you need.

So if your entire wallet balance is 0.1337 BTC, you could issue:

bitcoin-cli sendtoaddress "address" 0.1337 "" "" true

Also, you can't use move, as that does not actually issue a Bitcoin transaction, but only updates internal balances.

  • How many satoshis are deducted as transaction fee? – Shabahat M. Ayubi Nov 9 '16 at 11:21
  • Bitcoin has a floating fee per byte rate. You can either configure what that rate is, or let estimation do its work. – Pieter Wuille Nov 9 '16 at 16:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.