-
Notifications
You must be signed in to change notification settings - Fork 282
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
wallet-http: put send transaction endpoints behind fund locks. #845
Conversation
|
||
// spend all money for now. | ||
await rcwallet1.send({ | ||
subtractFee: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is passphrase needed here for consistency?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This works because the wallet is unlocked at this stage. (Wallet is locked in the afterEach)
I will just add comment.
|
HTTP Endpoints that are responsible to directly sending transactions to the mempool (except send tx) - did not use fund lock to queue the requests to the wallet. What ends up happening if you are running automated scripts or send multiple requests at once - coins wont get marked as spent before another set of coins are selected. Resulting in conflicting transactions.
This makes sure every send* transaction:
POST /wallet/:id/open
POST /wallet/:id/bid
POST /wallet/:id/reveal
POST /wallet/:id/redeem
POST /wallet/:id/update
POST /wallet/:id/renewal
POST /wallet/:id/transfer
POST /wallet/:id/cancel
POST /wallet/:id/finalize
POST /wallet/:id/revoke
Uses fundlock until the coin is added to the txdb, before processing next HTTP request.
Hard Fee
Expose
hardFee
as an option to the HTTP. This can help users to specify the exact FEE they want to pay for transaction.NOTE About TODOs.
When creating transaction (w/o sending), you run into the same issue. If you create 2 transactions at once, chances are they will use the same coins to fund them. There are two solution with existing tools for this:
SIGNED
, we can add those transactions to the txdb w/o sending to the mempool.NOT SIGNED
, we can LOCK those coins, to ensure next createTX does not use the same coins to fund next one.This can be done by introducing new flags:
insert
- if signed but no broadcast - we can look at this flag and insert intotxdb
. And another flag:lock
- if we are not signed (and of course that also means no broadcast), we lock the coins in non-permanently.Big wallets, with lots of coins, or big transactions that needs lots of coins can take a some time to craft transactions before broadcasting. We get compounding effect when we use fundLocks where multiple requests are also queued.
So allowing new request parameter
abortOnClose
can work by making sure that transaction creation is done before request closes. If request closes and transaction already was being sent, it will do nothing.