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

Commit daebaf5

Browse files
committed
Display lighting/bitcoin payment confirm in fiat if selected
1 parent ca8d716 commit daebaf5

File tree

3 files changed

+21
-11
lines changed

3 files changed

+21
-11
lines changed

src/computed/payment.js

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,23 @@
11
import { computed, extendObservable } from 'mobx';
2-
import { formatNumber } from '../helper';
2+
import { toSatoshis, toAmountLabel } from '../helper';
33

44
const ComputedPayment = store => {
55
extendObservable(store, {
6-
paymentAmountLabel: computed(() => formatNumber(store.payment.amount)),
7-
paymentFeeLabel: computed(() => formatNumber(store.payment.fee)),
6+
paymentAmountLabel: computed(() => {
7+
const { payment, settings } = store;
8+
const satoshis = toSatoshis(payment.amount, settings.unit);
9+
return toAmountLabel(satoshis, store.settings);
10+
}),
11+
paymentFeeLabel: computed(() => {
12+
const { payment, settings } = store;
13+
const satoshis = toSatoshis(payment.fee, settings.unit);
14+
return toAmountLabel(satoshis, store.settings);
15+
}),
816
paymentTotalLabel: computed(() => {
9-
const { payment } = store;
10-
return formatNumber(Number(payment.amount) + Number(payment.fee));
17+
const { payment, settings } = store;
18+
const satAmount = toSatoshis(payment.amount, settings.unit);
19+
const satFee = toSatoshis(payment.fee, settings.unit);
20+
return toAmountLabel(satAmount + satFee, store.settings);
1121
}),
1222
});
1323
};

src/view/pay-bitcoin-confirm.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,14 @@ const PayBitcoinConfirmView = ({ store, nav, payment }) => (
6464
{store.paymentAmountLabel}
6565
</BalanceLabelNumeral>
6666
<BalanceLabelUnit style={styles.unit}>
67-
{store.unit}
67+
{store.unitLabel}
6868
</BalanceLabelUnit>
6969
</BalanceLabel>
7070
<NamedField name="Fee">
71-
{store.paymentFeeLabel} {store.unit}
71+
{store.paymentFeeLabel} {store.unitLabel}
7272
</NamedField>
7373
<NamedField name="Total" style={styles.totalLbl}>
74-
{store.paymentTotalLabel} {store.unit}
74+
{store.paymentTotalLabel} {store.unitLabel}
7575
</NamedField>
7676
</FormStretcher>
7777
<PillButton

src/view/pay-lightning-confirm.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,14 @@ const PayLightningConfirmView = ({ store, nav, payment }) => (
5959
{store.paymentAmountLabel}
6060
</BalanceLabelNumeral>
6161
<BalanceLabelUnit style={styles.unit}>
62-
{store.unit}
62+
{store.unitLabel}
6363
</BalanceLabelUnit>
6464
</BalanceLabel>
6565
<NamedField name="Fee">
66-
{store.paymentFeeLabel} {store.unit}
66+
{store.paymentFeeLabel} {store.unitLabel}
6767
</NamedField>
6868
<NamedField name="Total" style={styles.totalLbl}>
69-
{store.paymentTotalLabel} {store.unit}
69+
{store.paymentTotalLabel} {store.unitLabel}
7070
</NamedField>
7171
</FormStretcher>
7272
<PillButton

0 commit comments

Comments
 (0)