Bitcoin Forum
November 24, 2017, 10:07:05 PM *
News: Latest stable version of Bitcoin Core: 0.15.1  [Torrent].
 
   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 264 times)
s2
Full Member
***
Offline Offline

Activity: 126


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?

1511561225
Hero Member
*
Offline Offline

Posts: 1511561225

View Profile Personal Message (Offline)

Ignore
1511561225
Reply with quote  #2

1511561225
Report to moderator
Join ICO Now A blockchain platform for effective freelancing
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
achow101
Moderator
Legendary
*
Offline Offline

Activity: 1232


17kKQppUsngUiByDsce4JXoZEjjpvX9bpR


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.

          ▄█████▄
        ▄█████████▄
      ▄████▀   ▀████▄
    ▄████▀   ▄ ▄█▀████▄
  ▄████▀   ▄███▀   ▀████▄
▄████▀   ▄███▀   ▄   ▀████▄
█████   ███▀   ▄███   █████
▀████▄   ▀██▄▄███▀   ▄████▀
  ▀████▄   ▀███▀   ▄████▀
    ▀████▄       ▄████▀
      ▀████▄   ▄████▀
        ▀███  ████▀
          ▀█▄███▀
.
|
.
|
          ▄█████▄
        ▄█████████▄
      ▄████▀   ▀████▄
    ▄████▀   ▄ ▄█▀████▄
  ▄████▀   ▄███▀   ▀████▄
▄████▀   ▄███▀   ▄   ▀████▄
█████   ███▀   ▄███   █████
▀████▄   ▀██▄▄███▀   ▄████▀
  ▀████▄   ▀███▀   ▄████▀
    ▀████▄       ▄████▀
      ▀████▄   ▄████▀
        ▀███  ████▀
          ▀█▄███▀
unthy
s2
Full Member
***
Offline Offline

Activity: 126


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: 1232


17kKQppUsngUiByDsce4JXoZEjjpvX9bpR


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

          ▄█████▄
        ▄█████████▄
      ▄████▀   ▀████▄
    ▄████▀   ▄ ▄█▀████▄
  ▄████▀   ▄███▀   ▀████▄
▄████▀   ▄███▀   ▄   ▀████▄
█████   ███▀   ▄███   █████
▀████▄   ▀██▄▄███▀   ▄████▀
  ▀████▄   ▀███▀   ▄████▀
    ▀████▄       ▄████▀
      ▀████▄   ▄████▀
        ▀███  ████▀
          ▀█▄███▀
.
|
.
|
          ▄█████▄
        ▄█████████▄
      ▄████▀   ▀████▄
    ▄████▀   ▄ ▄█▀████▄
  ▄████▀   ▄███▀   ▀████▄
▄████▀   ▄███▀   ▄   ▀████▄
█████   ███▀   ▄███   █████
▀████▄   ▀██▄▄███▀   ▄████▀
  ▀████▄   ▀███▀   ▄████▀
    ▀████▄       ▄████▀
      ▀████▄   ▄████▀
        ▀███  ████▀
          ▀█▄███▀
unthy
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!