Commit 300cbb1b authored by Tankred Hase's avatar Tankred Hase

Cleanup fee estimate payment actions

parent 55b18bce
......@@ -11,14 +11,7 @@ import {
MED_TARGET_CONF,
HIGH_TARGET_CONF,
} from '../config';
import {
toSatoshis,
toAmount,
toAmountLabel,
isLnUri,
isAddress,
nap,
} from '../helper';
import { toSatoshis, toAmount, isLnUri, isAddress, nap } from '../helper';
import * as log from './log';
class PaymentAction {
......@@ -245,22 +238,21 @@ class PaymentAction {
const { payment, settings } = this._store;
const AddrToAmount = {};
AddrToAmount[payment.address] = toSatoshis(payment.amount, settings);
const { feeSat, feerateSatPerByte } = await this._grpc.sendCommand(
'estimateFee',
{
AddrToAmount,
targetConf,
}
);
const { feeSat } = await this._grpc.sendCommand('estimateFee', {
AddrToAmount,
targetConf,
});
payment.feeEstimates.push({
fee: toAmount(feeSat, settings),
targetConf,
prio,
satPerByte: feerateSatPerByte,
fee: toAmount(feeSat, settings),
feeLabel: toAmountLabel(feeSat, settings),
});
}
/**
* Set the target_conf for the on-chain send operation and set a fee.
* @param {number} options.targetConf The number blocks to target
*/
setTargetConf({ targetConf }) {
const { payment } = this._store;
payment.targetConf = targetConf;
......
......@@ -10,6 +10,15 @@ const ComputedPayment = store => {
get paymentAmountLabel() {
return toLabel(store.payment.amount, store.settings);
},
get paymentFeeEstimateItems() {
return store.payment.feeEstimates.map(e => {
const feeLabel = toLabel(e.fee, store.settings);
return {
label: `${e.prio} ${feeLabel} ${store.unitLabel || ''}`.trim(),
value: e.targetConf,
};
});
},
get paymentFeeLabel() {
return toLabel(store.payment.fee, store.settings);
},
......
......@@ -69,14 +69,9 @@ const PayBitcoinConfirmView = ({ store, nav, payment }) => (
</BalanceLabel>
<NamedFieldSelect
name="Fee"
items={store.payment.feeEstimates.map(e => ({
label: `${e.prio} ${e.feeLabel} ${store.unitLabel || ''}`,
value: e.targetConf,
}))}
items={store.paymentFeeEstimateItems}
value={store.payment.targetConf}
onValueChange={value =>
payment.setTargetConf({ targetConf: value })
}
onValueChange={targetConf => payment.setTargetConf({ targetConf })}
/>
<NamedField name="Total" style={styles.totalLbl}>
{store.paymentTotalLabel} {store.unitLabel}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment