Bitcoin Forum
December 05, 2016, 04:51:13 PM *
News: Latest stable version of Bitcoin Core: 0.13.1  [Torrent].
 
   Home   Help Search Donate Login Register  
Pages: [1]
  Print  
Author Topic: PHP: how to calculate the transaction fee?  (Read 1948 times)
DaMan
Member
**
Offline Offline

Activity: 84



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

Posts: 1480956673

View Profile Personal Message (Offline)

Ignore
1480956673
Reply with quote  #2

1480956673
Report to moderator
1480956673
Hero Member
*
Offline Offline

Posts: 1480956673

View Profile Personal Message (Offline)

Ignore
1480956673
Reply with quote  #2

1480956673
Report to moderator
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
1480956673
Hero Member
*
Offline Offline

Posts: 1480956673

View Profile Personal Message (Offline)

Ignore
1480956673
Reply with quote  #2

1480956673
Report to moderator
1480956673
Hero Member
*
Offline Offline

Posts: 1480956673

View Profile Personal Message (Offline)

Ignore
1480956673
Reply with quote  #2

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

Activity: 361


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


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: 1116


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


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: 1036


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.

aka sipa, core dev team

Tips and donations: 1KwDYMJMS4xq3ZEWYfdBRwYG2fHwhZsipa
kjj
Legendary
*
Offline Offline

Activity: 1302



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.

p2pcoin: a USB/CD/PXE p2pool miner - 1N8ZXx2cuMzqBYSK72X4DAy1UdDbZQNPLf - todo
I routinely ignore posters with paid advertising in their sigs.  You should too.
Pages: [1]
  Print  
 
Jump to:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!