Bitcoin core How do I get the transaction fee while using sendtoaddress

0

I have a bitcoin core running on testnet, so for suppose I have a wallet balance of 1BTC and I have to send it to an addressx, so how can I know the amount of transaction fee so that I can subtract it from the sending amount.

bitcoin-cli sendtoaddress x 1

This will return an error stating that

error code: -4
error message:
Error: This transaction requires a transaction fee of at least 0.00000488

How can I know it beforehand the fee required for a transaction?

Paras

Posted 2019-05-30T07:49:28.137

Reputation: 161

Answers

-1

As the bitcoin-cli help sendtoaddress states:

  1. subtractfeefromamount (boolean, optional, default=false) The fee will be deducted from the amount being sent.

So you can change your call to:

bitcoin-cli sendtoaddress x 1 "" "" true

So that the fee is deducted from the amount to send

davidlj95

Posted 2019-05-30T07:49:28.137

Reputation: 40

doesnt sound like it really answers the question to me, what if the merchant/recipient expects the full amount?Mark S. 2019-05-30T20:58:42.300

0

I think you want estimatesmartfee or estimatefee it takes one argument which is the confirmation target in blocks. You can also select from Economical or Conservative fee modes which may affect the suggested fee rate.

Mark S.

Posted 2019-05-30T07:49:28.137

Reputation: 2 415

How should I dermine the blocks, also estimatesmartfee does not work for bitcoincash, and estimatefee do not take any argument now. Also, how is the fee determined for this sendtoaddress. Is it the average fee or the lowest possible value?Paras 2019-05-31T04:45:40.620