mirror of
https://github.com/BlueWallet/BlueWallet.git
synced 2025-02-22 06:52:41 +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 style={{ flexDirection: 'row', justifyContent: 'center', paddingTop: 16, paddingBottom: 16 }}>
|
||||
<TextInput
|
||||
{...this.props}
|
||||
keyboardType="numeric"
|
||||
onChangeText={text =>
|
||||
this.props.onChangeText(
|
||||
this.props.unit === BitcoinUnit.BTC
|
||||
? text.replace(new RegExp('[^0-9.]'), '', '.')
|
||||
: text.replace(new RegExp('[^0-9]'), ''),
|
||||
)
|
||||
}
|
||||
onChangeText={text => {
|
||||
text = this.props.unit === BitcoinUnit.BTC ? text.replace(/[^0-9.]/g, '') : text.replace(/[^0-9]/g, '');
|
||||
this.props.onChangeText(text);
|
||||
}}
|
||||
placeholder="0"
|
||||
maxLength={10}
|
||||
ref={textInput => (this.textInput = textInput)}
|
||||
|
@ -1150,7 +1148,6 @@ export class BlueBitcoinAmount extends Component {
|
|||
fontSize: 36,
|
||||
fontWeight: '600',
|
||||
}}
|
||||
{...this.props}
|
||||
/>
|
||||
<Text
|
||||
style={{
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
</dict>
|
||||
</array>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>217</string>
|
||||
<string>218</string>
|
||||
<key>ITSAppUsesNonExemptEncryption</key>
|
||||
<false/>
|
||||
<key>LSRequiresIPhoneOS</key>
|
||||
|
|
|
@ -71,46 +71,50 @@ export default class ScanLndInvoice extends React.Component {
|
|||
}
|
||||
}
|
||||
|
||||
async processInvoice(data) {
|
||||
if (this.ignoreRead) return;
|
||||
this.ignoreRead = true;
|
||||
setTimeout(() => {
|
||||
this.ignoreRead = false;
|
||||
}, 6000);
|
||||
processInvoice(data) {
|
||||
this.setState({ isLoading: true }, async () => {
|
||||
if (this.ignoreRead) return;
|
||||
this.ignoreRead = true;
|
||||
setTimeout(() => {
|
||||
this.ignoreRead = false;
|
||||
}, 6000);
|
||||
|
||||
if (!this.state.fromWallet) {
|
||||
alert('Before paying a Lightning invoice, you must first add a Lightning wallet.');
|
||||
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';
|
||||
if (!this.state.fromWallet) {
|
||||
alert('Before paying a Lightning invoice, you must first add a Lightning wallet.');
|
||||
return this.props.navigation.goBack();
|
||||
}
|
||||
Keyboard.dismiss();
|
||||
this.setState({
|
||||
invoice: data,
|
||||
decoded,
|
||||
expiresIn,
|
||||
destination: data,
|
||||
isAmountInitiallyEmpty: decoded.num_satoshis === '0',
|
||||
});
|
||||
} catch (Err) {
|
||||
alert(Err.message);
|
||||
}
|
||||
|
||||
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({
|
||||
invoice: data,
|
||||
decoded,
|
||||
expiresIn,
|
||||
destination: data,
|
||||
isAmountInitiallyEmpty: decoded.num_satoshis === '0',
|
||||
isLoading: false,
|
||||
});
|
||||
} catch (Err) {
|
||||
this.setState({ isLoading: false });
|
||||
alert(Err.message);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
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}
|
||||
onChangeText={text => {
|
||||
if (typeof this.state.decoded === 'object') {
|
||||
text = parseInt(text);
|
||||
text = parseInt(text || 0);
|
||||
let decoded = this.state.decoded;
|
||||
decoded.num_satoshis = text;
|
||||
this.setState({ decoded: decoded });
|
||||
|
|
Loading…
Add table
Reference in a new issue