Bitcoin Forum
May 09, 2024, 08:39:37 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Recommended way to handle fees (website communicating through RPC api)?  (Read 604 times)
johny1976 (OP)
Legendary
*
Offline Offline

Activity: 1135
Merit: 1002

Developer


View Profile
April 16, 2016, 08:03:47 AM
 #1

Hi,

since there's no way to calculate the fee (other than creating raw tx, which is unavailable when pruning blocks), I have this problem and no solution yet:

I've set the -paytxfee option to 0.0001 which I thought is enough. I'm also deducting this amount of 0.0001 BTC from the amount my visitors are withdrawing from my site. But during testing, I've tried to withdraw some funds.. 0.0001 was deducted but stood in wallet and it included a small fee of 0.00002260 to the transaction. This means the transaction has no big chance to get in block.

I know this happened because most transactions have cca 500 bytes, so it used the half of the amount I had set as a fee for kB.

So the real question is:

How can I know what amount to deduct from my user's withdrawal amounts? What if transaction fee gets bigger than that? How can I predict this?

Thank you very much for your help,

Johny
1715287177
Hero Member
*
Offline Offline

Posts: 1715287177

View Profile Personal Message (Offline)

Ignore
1715287177
Reply with quote  #2

1715287177
Report to moderator
1715287177
Hero Member
*
Offline Offline

Posts: 1715287177

View Profile Personal Message (Offline)

Ignore
1715287177
Reply with quote  #2

1715287177
Report to moderator
1715287177
Hero Member
*
Offline Offline

Posts: 1715287177

View Profile Personal Message (Offline)

Ignore
1715287177
Reply with quote  #2

1715287177
Report to moderator
BitcoinCleanup.com: Learn why Bitcoin isn't bad for the environment
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1715287177
Hero Member
*
Offline Offline

Posts: 1715287177

View Profile Personal Message (Offline)

Ignore
1715287177
Reply with quote  #2

1715287177
Report to moderator
1715287177
Hero Member
*
Offline Offline

Posts: 1715287177

View Profile Personal Message (Offline)

Ignore
1715287177
Reply with quote  #2

1715287177
Report to moderator
1715287177
Hero Member
*
Offline Offline

Posts: 1715287177

View Profile Personal Message (Offline)

Ignore
1715287177
Reply with quote  #2

1715287177
Report to moderator
cr1776
Legendary
*
Offline Offline

Activity: 4032
Merit: 1301


View Profile
April 16, 2016, 12:24:16 PM
 #2

... I'm also deducting this amount of 0.0001 BTC from the amount my visitors are withdrawing from my site. But during testing, I've tried to withdraw some funds.. 0.0001 was deducted but stood in wallet and it included a small fee of 0.00002260 to the transaction. This means the transaction has no big chance to get in block.

...

Perhaps you can explain in more detail how you are calculating the fees because the part in bold above doesn't sound right.  I'm not sure why you are deducting the fees from the withdrawal.
johny1976 (OP)
Legendary
*
Offline Offline

Activity: 1135
Merit: 1002

Developer


View Profile
April 16, 2016, 04:11:16 PM
 #3

... I'm also deducting this amount of 0.0001 BTC from the amount my visitors are withdrawing from my site. But during testing, I've tried to withdraw some funds.. 0.0001 was deducted but stood in wallet and it included a small fee of 0.00002260 to the transaction. This means the transaction has no big chance to get in block.

...

Perhaps you can explain in more detail how you are calculating the fees because the part in bold above doesn't sound right.  I'm not sure why you are deducting the fees from the withdrawal.

Thanks for answer.

When a user of my website decide to withdraw 0.5 BTC, my PHP script deducts 0.0001 BTC from that amount to cover transaction fee, so the wallet receives command to withdraw only 4.9999 BTC + transaction fee.

Problem is, the transaction fee can get bigger then that, but how can my PHP script know?
CIYAM
Legendary
*
Offline Offline

Activity: 1890
Merit: 1078


Ian Knowles - CIYAM Lead Developer


View Profile WWW
April 16, 2016, 04:19:20 PM
 #4

You might want to look into the recent Bitcoin RPC command: estimatefee <nBlocks>

It will tell you the estimated fee per KB in order to confirm within <nBlocks> but it should be noted that "priority" is relevant. If you are wanting to try and send without a fee there is also the RPC command: estimatepriority <nBlocks> which will return the estimated priority required for a tx to not require a fee at all.

You will need to work out the priority and size of your tx to use the above RPC information in order to determine your fee (first determine the priority and check with "estimatepriority" to see if you need a fee at all and then use "estimatefee" to determine the fee although if your priority is not a lot above the zero level then you'd want to make your fee bigger than the minimum estimated).

It's actually a pity there isn't a similar RPC command for raw transactions (that would be able to take into account both the priority and size without you having to do those calculations separately) as changing the fee for a raw tx wouldn't need to change its size (assuming some change was expected anyway).

With CIYAM anyone can create 100% generated C++ web applications in literally minutes.

GPG Public Key | 1ciyam3htJit1feGa26p2wQ4aw6KFTejU
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!