mirror of
https://github.com/BlueWallet/BlueWallet.git
synced 2025-02-22 23:08:07 +01:00
FIX: Fix issue with typing amounts
This commit is contained in:
parent
5876b9e9ef
commit
c0a137a965
3 changed files with 49 additions and 48 deletions
|
@ -1131,14 +1131,12 @@ export class BlueBitcoinAmount extends Component {
|
||||||
<View>
|
<View>
|
||||||
<View style={{ flexDirection: 'row', justifyContent: 'center', paddingTop: 16, paddingBottom: 16 }}>
|
<View style={{ flexDirection: 'row', justifyContent: 'center', paddingTop: 16, paddingBottom: 16 }}>
|
||||||
<TextInput
|
<TextInput
|
||||||
|
{...this.props}
|
||||||
keyboardType="numeric"
|
keyboardType="numeric"
|
||||||
onChangeText={text =>
|
onChangeText={text => {
|
||||||
this.props.onChangeText(
|
text = this.props.unit === BitcoinUnit.BTC ? text.replace(/[^0-9.]/g, '') : text.replace(/[^0-9]/g, '');
|
||||||
this.props.unit === BitcoinUnit.BTC
|
this.props.onChangeText(text);
|
||||||
? text.replace(new RegExp('[^0-9.]'), '', '.')
|
}}
|
||||||
: text.replace(new RegExp('[^0-9]'), ''),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
placeholder="0"
|
placeholder="0"
|
||||||
maxLength={10}
|
maxLength={10}
|
||||||
ref={textInput => (this.textInput = textInput)}
|
ref={textInput => (this.textInput = textInput)}
|
||||||
|
@ -1150,7 +1148,6 @@ export class BlueBitcoinAmount extends Component {
|
||||||
fontSize: 36,
|
fontSize: 36,
|
||||||
fontWeight: '600',
|
fontWeight: '600',
|
||||||
}}
|
}}
|
||||||
{...this.props}
|
|
||||||
/>
|
/>
|
||||||
<Text
|
<Text
|
||||||
style={{
|
style={{
|
||||||
|
|
|
@ -33,7 +33,7 @@
|
||||||
</dict>
|
</dict>
|
||||||
</array>
|
</array>
|
||||||
<key>CFBundleVersion</key>
|
<key>CFBundleVersion</key>
|
||||||
<string>217</string>
|
<string>218</string>
|
||||||
<key>ITSAppUsesNonExemptEncryption</key>
|
<key>ITSAppUsesNonExemptEncryption</key>
|
||||||
<false/>
|
<false/>
|
||||||
<key>LSRequiresIPhoneOS</key>
|
<key>LSRequiresIPhoneOS</key>
|
||||||
|
|
|
@ -71,46 +71,50 @@ export default class ScanLndInvoice extends React.Component {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async processInvoice(data) {
|
processInvoice(data) {
|
||||||
if (this.ignoreRead) return;
|
this.setState({ isLoading: true }, async () => {
|
||||||
this.ignoreRead = true;
|
if (this.ignoreRead) return;
|
||||||
setTimeout(() => {
|
this.ignoreRead = true;
|
||||||
this.ignoreRead = false;
|
setTimeout(() => {
|
||||||
}, 6000);
|
this.ignoreRead = false;
|
||||||
|
}, 6000);
|
||||||
|
|
||||||
if (!this.state.fromWallet) {
|
if (!this.state.fromWallet) {
|
||||||
alert('Before paying a Lightning invoice, you must first add a Lightning wallet.');
|
alert('Before paying a Lightning invoice, you must first add a Lightning wallet.');
|
||||||
return this.props.navigation.goBack();
|
return this.props.navigation.goBack();
|
||||||
}
|
|
||||||
|
|
||||||
data = data.replace('LIGHTNING:', '').replace('lightning:', '');
|
|
||||||
console.log(data);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @type {LightningCustodianWallet}
|
|
||||||
*/
|
|
||||||
let w = this.state.fromWallet;
|
|
||||||
let decoded;
|
|
||||||
try {
|
|
||||||
decoded = await w.decodeInvoice(data);
|
|
||||||
|
|
||||||
let expiresIn = (decoded.timestamp * 1 + decoded.expiry * 1) * 1000; // ms
|
|
||||||
if (+new Date() > expiresIn) {
|
|
||||||
expiresIn = 'expired';
|
|
||||||
} else {
|
|
||||||
expiresIn = Math.round((expiresIn - +new Date()) / (60 * 1000)) + ' min';
|
|
||||||
}
|
}
|
||||||
Keyboard.dismiss();
|
|
||||||
this.setState({
|
data = data.replace('LIGHTNING:', '').replace('lightning:', '');
|
||||||
invoice: data,
|
console.log(data);
|
||||||
decoded,
|
|
||||||
expiresIn,
|
/**
|
||||||
destination: data,
|
* @type {LightningCustodianWallet}
|
||||||
isAmountInitiallyEmpty: decoded.num_satoshis === '0',
|
*/
|
||||||
});
|
let w = this.state.fromWallet;
|
||||||
} catch (Err) {
|
let decoded;
|
||||||
alert(Err.message);
|
try {
|
||||||
}
|
decoded = await w.decodeInvoice(data);
|
||||||
|
|
||||||
|
let expiresIn = (decoded.timestamp * 1 + decoded.expiry * 1) * 1000; // ms
|
||||||
|
if (+new Date() > expiresIn) {
|
||||||
|
expiresIn = 'expired';
|
||||||
|
} else {
|
||||||
|
expiresIn = Math.round((expiresIn - +new Date()) / (60 * 1000)) + ' min';
|
||||||
|
}
|
||||||
|
Keyboard.dismiss();
|
||||||
|
this.setState({
|
||||||
|
invoice: data,
|
||||||
|
decoded,
|
||||||
|
expiresIn,
|
||||||
|
destination: data,
|
||||||
|
isAmountInitiallyEmpty: decoded.num_satoshis === '0',
|
||||||
|
isLoading: false,
|
||||||
|
});
|
||||||
|
} catch (Err) {
|
||||||
|
this.setState({ isLoading: false });
|
||||||
|
alert(Err.message);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async pay() {
|
async pay() {
|
||||||
|
@ -190,7 +194,7 @@ export default class ScanLndInvoice extends React.Component {
|
||||||
amount={typeof this.state.decoded === 'object' ? this.state.decoded.num_satoshis : 0}
|
amount={typeof this.state.decoded === 'object' ? this.state.decoded.num_satoshis : 0}
|
||||||
onChangeText={text => {
|
onChangeText={text => {
|
||||||
if (typeof this.state.decoded === 'object') {
|
if (typeof this.state.decoded === 'object') {
|
||||||
text = parseInt(text);
|
text = parseInt(text || 0);
|
||||||
let decoded = this.state.decoded;
|
let decoded = this.state.decoded;
|
||||||
decoded.num_satoshis = text;
|
decoded.num_satoshis = text;
|
||||||
this.setState({ decoded: decoded });
|
this.setState({ decoded: decoded });
|
||||||
|
|
Loading…
Add table
Reference in a new issue