Skip to content

Commit

Permalink
Merge branch 'master' into devicel
Browse files Browse the repository at this point in the history
  • Loading branch information
marcosrdz committed Jun 15, 2020
2 parents 6bb1405 + 35b4a30 commit 22b5801
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 213 deletions.
10 changes: 6 additions & 4 deletions App.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import QuickActions from 'react-native-quick-actions';
import * as Sentry from '@sentry/react-native';
import OnAppLaunch from './class/on-app-launch';
import DeeplinkSchemaMatch from './class/deeplink-schema-match';
import BitcoinBIP70TransactionDecode from './bip70/bip70';
const A = require('./analytics');

if (process.env.NODE_ENV !== 'development') {
Expand Down Expand Up @@ -116,8 +115,7 @@ export default class App extends React.Component {
return wallet.isInvoiceGeneratedByWallet(clipboard) || wallet.weOwnAddress(clipboard);
}
});
const isBitcoinAddress =
DeeplinkSchemaMatch.isBitcoinAddress(clipboard) || BitcoinBIP70TransactionDecode.matchesPaymentURL(clipboard);
const isBitcoinAddress = DeeplinkSchemaMatch.isBitcoinAddress(clipboard);
const isLightningInvoice = DeeplinkSchemaMatch.isLightningInvoice(clipboard);
const isLNURL = DeeplinkSchemaMatch.isLnUrl(clipboard);
const isBothBitcoinAndLightning = DeeplinkSchemaMatch.isBothBitcoinAndLightning(clipboard);
Expand Down Expand Up @@ -171,7 +169,11 @@ export default class App extends React.Component {
};

handleOpenURL = event => {
DeeplinkSchemaMatch.navigationRouteFor(event, value => this.navigation && this.navigation.navigate(...value));
// dirty hack with timeout till we make a proper refactoring
// @see https://reactnavigation.org/docs/deep-linking/
setTimeout(() => {
DeeplinkSchemaMatch.navigationRouteFor(event, value => this.navigation && this.navigation.navigate(...value));
}, 1000);
};

renderClipboardContentModal = () => {
Expand Down
85 changes: 0 additions & 85 deletions bip70/bip70.js

This file was deleted.

9 changes: 7 additions & 2 deletions class/deeplink-schema-match.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { AppStorage, LightningCustodianWallet } from './';
import AsyncStorage from '@react-native-community/async-storage';
import BitcoinBIP70TransactionDecode from '../bip70/bip70';
import RNFS from 'react-native-fs';
import url from 'url';
import { Chain } from '../models/bitcoinUnits';
Expand Down Expand Up @@ -76,7 +75,7 @@ class DeeplinkSchemaMatch {
},
},
]);
} else if (DeeplinkSchemaMatch.isBitcoinAddress(event.url) || BitcoinBIP70TransactionDecode.matchesPaymentURL(event.url)) {
} else if (DeeplinkSchemaMatch.isBitcoinAddress(event.url)) {
completionHandler([
'SendDetailsRoot',
{
Expand Down Expand Up @@ -110,12 +109,18 @@ class DeeplinkSchemaMatch {
const urlObject = url.parse(event.url, true); // eslint-disable-line node/no-deprecated-api

const safelloStateToken = urlObject.query['safello-state-token'];
let wallet;
for (const w of BlueApp.getWallets()) {
wallet = w;
break;
}

completionHandler([
'BuyBitcoin',
{
uri: event.url,
safelloStateToken,
wallet,
},
]);
} else if (Azteco.isRedeemUrl(event.url)) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"e2e:release": "detox build -c android.emu.release; npm run e2e:release-no-build",
"e2e:release-no-build": "detox test -c android.emu.release --record-videos all --take-screenshots all --headless",
"e2e:debug": "(test -f android/app/build/outputs/apk/debug/app-debug.apk && test -f android/app/build/outputs/apk/androidTest/debug/app-debug-androidTest.apk) || detox build -c android.emu.debug; detox test -c android.emu.debug",
"lint": "eslint *.js screen/**/*.js bip70/ blue_modules/crypto.js class/**/*.js models/ loc/ tests/**/*.js",
"lint": "eslint *.js screen/**/*.js blue_modules/crypto.js class/**/*.js models/ loc/ tests/**/*.js",
"lint:fix": "npm run lint -- --fix",
"lint:quickfix": "git status --porcelain | grep -v '\\.json' | grep '\\.js' --color=never | awk '{print $2}' | xargs eslint --fix; exit 0",
"unit": "jest tests/unit/*"
Expand Down
16 changes: 15 additions & 1 deletion screen/lnd/lndCreateInvoice.js
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,20 @@ export default class LNDCreateInvoice extends Component {
throw new Error('Unsupported lnurl');
}

// amount that comes from lnurl is always in sats
let amount = (reply.maxWithdrawable / 1000).toString();
switch (this.state.unit) {
case BitcoinUnit.SATS:
// nop
break;
case BitcoinUnit.BTC:
amount = currency.satoshiToBTC(amount);
break;
case BitcoinUnit.LOCAL_CURRENCY:
amount = loc.formatBalancePlain(amount, BitcoinUnit.LOCAL_CURRENCY);
break;
}

// setting the invoice creating screen with the parameters
this.setState({
isLoading: false,
Expand All @@ -300,7 +314,7 @@ export default class LNDCreateInvoice extends Component {
min: (reply.minWithdrawable || 0) / 1000,
max: reply.maxWithdrawable / 1000,
},
amount: (reply.maxWithdrawable / 1000).toString(),
amount,
description: reply.defaultDescription,
});
} catch (Err) {
Expand Down
Loading

0 comments on commit 22b5801

Please sign in to comment.