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

Commit 300cbb1

Browse files
committed
Cleanup fee estimate payment actions
1 parent 55b18bc commit 300cbb1

File tree

3 files changed

+21
-25
lines changed

3 files changed

+21
-25
lines changed

src/action/payment.js

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,7 @@ import {
1111
MED_TARGET_CONF,
1212
HIGH_TARGET_CONF,
1313
} from '../config';
14-
import {
15-
toSatoshis,
16-
toAmount,
17-
toAmountLabel,
18-
isLnUri,
19-
isAddress,
20-
nap,
21-
} from '../helper';
14+
import { toSatoshis, toAmount, isLnUri, isAddress, nap } from '../helper';
2215
import * as log from './log';
2316

2417
class PaymentAction {
@@ -245,22 +238,21 @@ class PaymentAction {
245238
const { payment, settings } = this._store;
246239
const AddrToAmount = {};
247240
AddrToAmount[payment.address] = toSatoshis(payment.amount, settings);
248-
const { feeSat, feerateSatPerByte } = await this._grpc.sendCommand(
249-
'estimateFee',
250-
{
251-
AddrToAmount,
252-
targetConf,
253-
}
254-
);
241+
const { feeSat } = await this._grpc.sendCommand('estimateFee', {
242+
AddrToAmount,
243+
targetConf,
244+
});
255245
payment.feeEstimates.push({
246+
fee: toAmount(feeSat, settings),
256247
targetConf,
257248
prio,
258-
satPerByte: feerateSatPerByte,
259-
fee: toAmount(feeSat, settings),
260-
feeLabel: toAmountLabel(feeSat, settings),
261249
});
262250
}
263251

252+
/**
253+
* Set the target_conf for the on-chain send operation and set a fee.
254+
* @param {number} options.targetConf The number blocks to target
255+
*/
264256
setTargetConf({ targetConf }) {
265257
const { payment } = this._store;
266258
payment.targetConf = targetConf;

src/computed/payment.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,15 @@ const ComputedPayment = store => {
1010
get paymentAmountLabel() {
1111
return toLabel(store.payment.amount, store.settings);
1212
},
13+
get paymentFeeEstimateItems() {
14+
return store.payment.feeEstimates.map(e => {
15+
const feeLabel = toLabel(e.fee, store.settings);
16+
return {
17+
label: `${e.prio} ${feeLabel} ${store.unitLabel || ''}`.trim(),
18+
value: e.targetConf,
19+
};
20+
});
21+
},
1322
get paymentFeeLabel() {
1423
return toLabel(store.payment.fee, store.settings);
1524
},

src/view/pay-bitcoin-confirm-mobile.js

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,9 @@ const PayBitcoinConfirmView = ({ store, nav, payment }) => (
6969
</BalanceLabel>
7070
<NamedFieldSelect
7171
name="Fee"
72-
items={store.payment.feeEstimates.map(e => ({
73-
label: `${e.prio} ${e.feeLabel} ${store.unitLabel || ''}`,
74-
value: e.targetConf,
75-
}))}
72+
items={store.paymentFeeEstimateItems}
7673
value={store.payment.targetConf}
77-
onValueChange={value =>
78-
payment.setTargetConf({ targetConf: value })
79-
}
74+
onValueChange={targetConf => payment.setTargetConf({ targetConf })}
8075
/>
8176
<NamedField name="Total" style={styles.totalLbl}>
8277
{store.paymentTotalLabel} {store.unitLabel}

0 commit comments

Comments
 (0)