Bitcoin Forum
April 26, 2018, 02:20:03 AM *
News: Latest stable version of Bitcoin Core: 0.16.0  [Torrent]. (New!)
 
   Home   Help Search Donate Login Register  
Pages: [1]
  Print  
Author Topic: How do you transfer all the funds in a bitcoind wallet via RPC?  (Read 268 times)
s2
Full Member
***
Offline Offline

Activity: 171
Merit: 104


View Profile
March 01, 2017, 10:14:33 AM
 #1

I'm curious what the RPC approach is to transfer all the funds in a wallet to an external address but with a reasonable transaction fee?

(This is version 0.13.1 if that matters)

E.g. If I have 20,000,000 satoshi balance in the bitcoind controlled wallet and want to transfer as much as possible to a new address but with sufficient fees it's likely to be in the next block, what do I provide to sendToAddress?

Some PGP public keys you should import: theymos, Wladimir, Gregory, Pieter
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
1524709203
Hero Member
*
Offline Offline

Posts: 1524709203

View Profile Personal Message (Offline)

Ignore
1524709203
Reply with quote  #2

1524709203
Report to moderator
achow101
Moderator
Legendary
*
Offline Offline

Activity: 1386
Merit: 1292


3F1Y9yquzvY6RWvKbw2n2zeo9V5mvBhADU


View Profile WWW
March 01, 2017, 02:10:22 PM
 #2

Run
Code:
estimatefee <blocks>
where <blocks> is the number of blocks that you want your transaction to be confirmed within. Note that you cannot choose 1 because that is too soon and not enough data can be gathered for 1 block. I recommend using 3.

Take the result of the estimatefee command above and run
Code:
settxfee <fee>
where <fee> is the output of the estimatefee command.

Then whenever you send using the wallet RPCs in the same session, it will use the fees set by settxfee.

s2
Full Member
***
Offline Offline

Activity: 171
Merit: 104


View Profile
March 01, 2017, 06:01:05 PM
 #3

Many thanks for the reply, I have changed it as you've said and so far so good.


Do you know what happens if you construct a transaction which used loads of inputs therefore requiring a larger fee?

(Also has it already been discussed changing the RPC methods to just use satoshis?  Having it return floating point bitcoin has already flagged one rounding problem today Smiley )
achow101
Moderator
Legendary
*
Offline Offline

Activity: 1386
Merit: 1292


3F1Y9yquzvY6RWvKbw2n2zeo9V5mvBhADU


View Profile WWW
March 01, 2017, 06:07:31 PM
 #4

Many thanks for the reply, I have changed it as you've said and so far so good.


Do you know what happens if you construct a transaction which used loads of inputs therefore requiring a larger fee?
The fee returned by estimatefee and the fee entered into settxfee is actually the fee rate in BTC/kB. So if you have a large transaction, it will pay a higher fee which is still using the fee rate specified in settxfee.

(Also has it already been discussed changing the RPC methods to just use satoshis?  Having it return floating point bitcoin has already flagged one rounding problem today Smiley )
There is discussion about making it all in satoshis instead of BTC. See  https://github.com/bitcoin/bitcoin/pull/9855 and https://github.com/bitcoin/bitcoin/pull/9882

Pages: [1]
  Print  
 
Jump to:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!