Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

way to spend certain amount of bitcoin including the fee #57

Open
ha1331 opened this issue Jul 5, 2017 · 1 comment
Open

way to spend certain amount of bitcoin including the fee #57

ha1331 opened this issue Jul 5, 2017 · 1 comment

Comments

@ha1331
Copy link

ha1331 commented Jul 5, 2017

The problem I'm trying to solve here is the following: If I have an application where the users have certain balances, I would wan't to have a way for them to withdraw that balance without me having to pay the cost of the operation. So, say user has 1btc and he/she decides to transfer these funds to where ever. Now when this transaction is happening, the user gets 1btc but I end up paying the fee. What I would like to have happen here is the following: My wallets balance is reduced by 1btc and the user is going to receive what ever amount is left after the fee has been payed.

I could do what some apps do and have their balance go to negative (the amount of fee payed is reduced from onsite balance after the transaction has been sent), but I don't like that. I could also have a set withdrawal fee, percentage or similar arrangement, but I would like to not do that either. Ideally I could charge a fee on the service I provide and advertise that my service doesn't charge extra for withdrawals, you just pay the costs that are enforced by the network.

@RishabSwift
Copy link

When you try to withdraw max available coins, it will give you an error saying "Wallet balance too low to pay the fee [12880]". Notice the fee in the square brackets.

In code, you can try withdrawing, catch the error, take out the square brackets and subtract this value from the original price and send it.

Not efficient, I know. But this is how I've done it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants