Author

Topic: PHP: how to calculate the transaction fee? (Read 2294 times)

kjj
legendary
Activity: 1302
Merit: 1026
October 04, 2011, 08:16:56 AM
#7
What fee it calculates depends on what transaction outputs it decides to use to fund the new transaction, and (I could be wrong with this point) I don't believe it does so deterministically. So there certainly isn't a way to do it without all the information in wallet.dat, and that might not even be enough.

This is correct.

I believe the solution is providing an RPC call that creates a preliminary transaction (which isn't broadcast yet), but can be inspected. At this point, it can either be committed (broadcast) or reverted through another RPC call.

Yup, but it needs to lock all transactions involved in the potential spend until it gets approval / rejection / timeout.  For almost all systems that I can think of, this is worse than just paying the fee and noting the amount later.
legendary
Activity: 1072
Merit: 1181
October 04, 2011, 03:14:30 AM
#6
What fee it calculates depends on what transaction outputs it decides to use to fund the new transaction, and (I could be wrong with this point) I don't believe it does so deterministically. So there certainly isn't a way to do it without all the information in wallet.dat, and that might not even be enough.

This is correct.

I believe the solution is providing an RPC call that creates a preliminary transaction (which isn't broadcast yet), but can be inspected. At this point, it can either be committed (broadcast) or reverted through another RPC call.
legendary
Activity: 905
Merit: 1012
October 03, 2011, 11:29:49 AM
#5
What fee it calculates depends on what transaction outputs it decides to use to fund the new transaction, and (I could be wrong with this point) I don't believe it does so deterministically. So there certainly isn't a way to do it without all the information in wallet.dat, and that might not even be enough.
legendary
Activity: 1199
Merit: 1012
October 03, 2011, 09:05:48 AM
#4
There is currently no way to calculate the resulting fees, afaik.

but bitcoin software does it somehow.. probably just need to look at sources
full member
Activity: 228
Merit: 100
August 05, 2011, 01:24:12 AM
#3
Hi!

I have a big problem i can't solve by myself:

I am using PHP and use the API "sendfrom" command to send some transactions.

Is there a way to calculate the exactly needed transaction fee? I tried it with a basic 2% calculation and if I send i.e. 2 BTC I check if my account balance is more than 2 BTC + 2%.

But if I am sending more transactions it results in an error, because the account balance is to low.

Is there a way/command to calculate the correct transactions fee needed for each transaction? Or a way to get the transaction KB value?

Kind regards,

DaMan


There is currently no way to calculate the resulting fees, afaik.
sr. member
Activity: 361
Merit: 250
August 04, 2011, 10:35:59 PM
#2
Have you found a solution for your problem?
full member
Activity: 126
Merit: 100
Hi!

I have a big problem i can't solve by myself:

I am using PHP and use the API "sendfrom" command to send some transactions.

Is there a way to calculate the exactly needed transaction fee? I tried it with a basic 2% calculation and if I send i.e. 2 BTC I check if my account balance is more than 2 BTC + 2%.

But if I am sending more transactions it results in an error, because the account balance is to low.

Is there a way/command to calculate the correct transactions fee needed for each transaction? Or a way to get the transaction KB value?

Kind regards,

DaMan
Jump to: