Author

Topic: Recommended way to handle fees (website communicating through RPC api)? (Read 630 times)

legendary
Activity: 1890
Merit: 1086
Ian Knowles - CIYAM Lead Developer
You might want to look into the recent Bitcoin RPC command: estimatefee

It will tell you the estimated fee per KB in order to confirm within 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 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).
legendary
Activity: 1135
Merit: 1002
Developer
... 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?
legendary
Activity: 4228
Merit: 1313
... 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.
legendary
Activity: 1135
Merit: 1002
Developer
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
Jump to: