Skip to content
This repository was archived by the owner on Feb 23, 2021. It is now read-only.

Commit 7cbb0bb

Browse files
committed
Cleanup fee estimate into its own action
1 parent c0d9ee0 commit 7cbb0bb

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

src/action/payment.js

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -192,19 +192,29 @@ class PaymentAction {
192192
}
193193
}
194194

195+
/**
196+
* Estimate the on-chain transaction fee using the grpc api after which
197+
* the fee is set in the store.
198+
* @return {Promise<undefined>}
199+
*/
200+
async estimateFee() {
201+
const { payment, settings } = this._store;
202+
const AddrToAmount = {};
203+
AddrToAmount[payment.address] = toSatoshis(payment.amount, settings);
204+
const { feeSat } = await this._grpc.sendCommand('estimateFee', {
205+
AddrToAmount,
206+
});
207+
payment.fee = toAmount(feeSat, settings);
208+
}
209+
195210
/**
196211
* Initialize the pay bitcoin confirm view by getting a fee estimate
197212
* from lnd and navigating to the view.
213+
* @return {Promise<undefined>}
198214
*/
199215
async initPayBitcoinConfirm() {
200216
try {
201-
const { payment, settings } = this._store;
202-
const AddrToAmount = {};
203-
AddrToAmount[payment.address] = toSatoshis(payment.amount, settings);
204-
const { feeSat } = await this._grpc.sendCommand('estimateFee', {
205-
AddrToAmount,
206-
});
207-
payment.fee = toAmount(feeSat, settings);
217+
await this.estimateFee();
208218
this._nav.goPayBitcoinConfirm();
209219
} catch (err) {
210220
this._notification.display({ msg: 'Fee estimation failed!', err });

0 commit comments

Comments
 (0)