4

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.

1 Answer 1

4

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.

2
  • How many satoshis are deducted as transaction fee? Nov 9, 2016 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. Nov 9, 2016 at 16:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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