Bitcoin Forum
May 07, 2024, 01:51:09 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: PHP: how to calculate the transaction fee?  (Read 2280 times)
DaMan (OP)
Full Member
***
Offline Offline

Activity: 126
Merit: 100



View Profile
June 09, 2011, 09:20:54 PM
 #1

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
1715089869
Hero Member
*
Offline Offline

Posts: 1715089869

View Profile Personal Message (Offline)

Ignore
1715089869
Reply with quote  #2

1715089869
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.
1715089869
Hero Member
*
Offline Offline

Posts: 1715089869

View Profile Personal Message (Offline)

Ignore
1715089869
Reply with quote  #2

1715089869
Report to moderator
winnetou
Sr. Member
****
Offline Offline

Activity: 361
Merit: 250


View Profile
August 05, 2011, 03:35:59 AM
 #2

Have you found a solution for your problem?
talpan
Full Member
***
Offline Offline

Activity: 228
Merit: 100


View Profile
August 05, 2011, 06: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.
arsenische
Legendary
*
Offline Offline

Activity: 1199
Merit: 1012


View Profile
October 03, 2011, 02:05:48 PM
 #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

maaku
Legendary
*
expert
Offline Offline

Activity: 905
Merit: 1011


View Profile
October 03, 2011, 04:29:49 PM
 #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.

I'm an independent developer working on bitcoin-core, making my living off community donations.
If you like my work, please consider donating yourself: 13snZ4ZyCzaL7358SmgvHGC9AxskqumNxP
Pieter Wuille
Legendary
*
qt
Offline Offline

Activity: 1072
Merit: 1174


View Profile WWW
October 04, 2011, 08: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.

I do Bitcoin stuff.
kjj
Legendary
*
Offline Offline

Activity: 1302
Merit: 1025



View Profile
October 04, 2011, 01:16:56 PM
 #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.

17Np17BSrpnHCZ2pgtiMNnhjnsWJ2TMqq8
I routinely ignore posters with paid advertising in their sigs.  You should too.
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!