Bitcoin Forum
May 06, 2024, 07:30:32 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
  Home Help Search Login Register More  
  Show Posts
Pages: [1]
1  Bitcoin / Development & Technical Discussion / Getting transaction size/fees before sending on: July 27, 2021, 07:04:59 AM
Hello,

I'm creating an application which allows users to have their own addresses from which they can deposit/withdraw from. When users withdraw from an address generated from my wallet to their own personal wallet, I'd like to account for fees and let users aware of these fees before actually withdrawing.

My initial idea to do this would go as follows:

1) User inputs a desired value that they want to withdraw which sends a request to my backend
2) I then create a "mock" transaction (whether is be by manually creating it or with fundrawtransaction)
3) Get the resultant the number of inputs/outputs of the transaction/the resultant tx size in bytes
4) Use this resultant tx size to estimate the actual fee based off a certain feerate
Note: this feerate will be decided by user and based on whether they want a faster tx time w/ lower fees or a slower tx time w/ higher fees
5) Add this fee to the total withdraw amount

However, this seems to be a bit "overkill" since every time a user enters a value to withdraw (even if they do not go through with it), I'd have to create a new transaction and this seems unnecessarily intensive.

Another idea I had was to ignore the part of actually creating the transaction but instead checking the minimal amount of transaction inputs/outputs that I'd need for the transaction with something like listunspent and then calculate the total tx fee with the formula: (n_in*148 + n_out*34 + 10) * feerate.

As a follow up question, would I then have to create raw transactions to properly implement these fees? It seems that the JSON RPC commands like sendtoaddress and fundrawtransaction do not provide enough flexibility when setting user fees.

Any input would be appreciated! And if there is anything that I seem to be confused/wrong about, please let me know Smiley
2  Bitcoin / Project Development / What APIs are commonly used in crypto payment/withdrawal systems? on: June 21, 2020, 02:55:59 AM
I'm creating a web application that will allow users to both deposit and withdraw Bitcoin (or any other cryptocurrency that would be possible but mainly looking at BTC atm) and am looking at APIs that can potentially help with designing this system.

I'm currently looking at the Blockchain.com API (was planning on using it with Nodejs if that matters) and am wondering if there are any limitations/drawbacks to it or if there are better options that are known as the standard within the community.

Any help would be much appreciated, thanks!

EDIT: I was also wondering if it is common to see websites/groups using blockchain based transaction systems creating their own in-house transaction system without any API
Pages: [1]
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!