Bitcoin Forum
May 11, 2024, 07:13:04 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: How do you transfer all the funds in a bitcoind wallet via RPC?  (Read 348 times)
s2 (OP)
Full Member
***
Offline Offline

Activity: 198
Merit: 123


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?

1715411584
Hero Member
*
Offline Offline

Posts: 1715411584

View Profile Personal Message (Offline)

Ignore
1715411584
Reply with quote  #2

1715411584
Report to moderator
1715411584
Hero Member
*
Offline Offline

Posts: 1715411584

View Profile Personal Message (Offline)

Ignore
1715411584
Reply with quote  #2

1715411584
Report to moderator
1715411584
Hero Member
*
Offline Offline

Posts: 1715411584

View Profile Personal Message (Offline)

Ignore
1715411584
Reply with quote  #2

1715411584
Report to moderator
Once a transaction has 6 confirmations, it is extremely unlikely that an attacker without at least 50% of the network's computation power would be able to reverse it.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
achow101
Moderator
Legendary
*
Offline Offline

Activity: 3388
Merit: 6635


Just writing some code


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 (OP)
Full Member
***
Offline Offline

Activity: 198
Merit: 123


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: 3388
Merit: 6635


Just writing some code


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:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!