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

Commit 5b45c79

Browse files
committed
Fix issue where writing 500 yeild 0500.
1 parent 07978ca commit 5b45c79

File tree

3 files changed

+18
-5
lines changed

3 files changed

+18
-5
lines changed

src/action/payment.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ class PaymentAction {
169169
this._store.payment.amount === '0' ||
170170
this._store.payment.amount === 0
171171
) {
172+
this._store.payment.amount = null;
172173
this._nav.goPayLightningSupplyAmount();
173174
} else {
174175
this._nav.goPayLightningConfirm();
@@ -180,6 +181,15 @@ class PaymentAction {
180181
}
181182
}
182183

184+
async checkAmountSuppliedAndGoPayLightningConfirm() {
185+
if (!this._store.payment.amount) {
186+
return this._notification.display({ msg: 'Enter an invoice or address' });
187+
} else {
188+
this.reEstimateLightningFee();
189+
this._nav.goPayLightningConfirm();
190+
}
191+
}
192+
183193
/**
184194
* Attempt to decode a lightning invoice using the lnd grpc api. If it is
185195
* an invoice the amount and note store values will be set and the lightning
@@ -212,11 +222,12 @@ class PaymentAction {
212222
* @param {number} options.satAmt The amount to be payed in satoshis
213223
* @return {Promise<undefined>}
214224
*/
215-
async estimateLightningFeeForAmount({ amount }) {
225+
async reEstimateLightningFee() {
216226
try {
217227
const request = await this._grpc.sendCommand('decodePayReq', {
218228
payReq: this._store.payment.address,
219229
});
230+
const amount = this._store.payment.amount;
220231
this.estimateLightningFee({
221232
destination: request.destination,
222233
satAmt: toSatoshis(amount, this._store.settings),

src/view/pay-lightning-supply-amount-mobile.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ const PayLightningSupplyAmountView = ({ store, nav, payment }) => (
4747
value={store.invoice.amount}
4848
onChangeText={amount => payment.setAmount({ amount })}
4949
onSubmitEditing={() =>
50-
payment.estimateLightningFeeForAmount(payment.amount)
50+
payment.checkAmountSuppliedAndGoPayLightningConfirm()
5151
}
5252
/>
5353
<BalanceLabelUnit style={styles.unit}>
@@ -67,7 +67,9 @@ const PayLightningSupplyAmountView = ({ store, nav, payment }) => (
6767
</FormSubText>
6868
</Card>
6969
</MainContent>
70-
<SmallGlasButton onPress={() => nav.goPayLightningConfirm()}>
70+
<SmallGlasButton
71+
onPress={() => payment.checkAmountSuppliedAndGoPayLightningConfirm()}
72+
>
7173
Pay
7274
</SmallGlasButton>
7375
</Background>

src/view/pay-lightning-supply-amount.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ const PayLightningSupplyAmountView = ({ store, nav, payment }) => (
5454
value={store.payment.amount}
5555
onChangeText={amount => payment.setAmount({ amount })}
5656
onSubmitEditing={() =>
57-
payment.estimateLightningFeeForAmount(payment.amount)
57+
payment.checkAmountSuppliedAndGoPayLightningConfirm()
5858
}
5959
/>
6060
<BalanceLabelUnit style={styles.unit}>
@@ -74,7 +74,7 @@ const PayLightningSupplyAmountView = ({ store, nav, payment }) => (
7474
</FormStretcher>
7575
<PillButton
7676
style={styles.nextBtn}
77-
onPress={() => nav.goPayLightningConfirm()}
77+
onPress={() => payment.checkAmountSuppliedAndGoPayLightningConfirm()}
7878
>
7979
Pay
8080
</PillButton>

0 commit comments

Comments
 (0)