Page MenuHomePhabricator

[Cashtab] Improve input-collecting functions for Agora partial accept and cancel txs
ClosedPublic

Authored by bytesofman on Sat, Oct 19, 22:52.

Details

Summary

Initially, the function getAgoraPartialFuelInput was used to get the required fuel inputs for canceling or accepting an agora partial tx. This was a simplified function that would only return 1 utxo.

For the cancel feature, this simplification was ok (though still lazy) --- because canceling a tx only requires a tx fee, usually less than 1,000 satoshis. In this case, users will almost always have a utxo large enough to cover the tx (if their balance is large enough).

This same assumption would be rarely true for accepting partial txs though. Accept txs must pay for tokens and cover the fee. Paying for tokens can be almost anything, so we cannot assume the user just has this amount in 1 utxo somewhere.

Drop the lazy approach for a new approach that properly picks inputs. We use a dummy input to estimate the fees.

Complicated to test because we need to create an AgoraOffer object. AgoraOffer objects were created for integration testing Agora accepts and cancels in D16846. We include that mock here, since we use it in this diff, and it makes it easier to see how we build these mocks outside of the very large D16846.

getAgoraPartialFuelInput is deprecated along with its associated tests.

No functions are yet implemented in Cashtab. That is reserved for D16846

Test Plan

npm test

Diff Detail

Repository
rABC Bitcoin ABC
Branch
better-agora-inputs
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 30683
Build 60882: Build Diffcashtab-tests · ecash-lib-tests
Build 60881: arc lint + arc unit

Event Timeline

remove "cashtabswap" reference, going with Agora

improve comments on getAgoraPartialCancelFuelInputs

bytesofman added inline comments.
cashtab/src/components/Agora/fixtures/mocks.js
11 ↗(On Diff #50216)

I created these mocks by adding debug logs in Cashtab, creating new wallets, creating AgoraPartial offers, and copying them into this file.

cashtab/src/wallet/index.js
26 ↗(On Diff #50216)

Saved as a constant in hex in this DUMMY_KEYPAIR object because we need ecc initialized to calculate it.

This revision is now accepted and ready to land.Sun, Oct 20, 11:22