Skip to content

Commit

Permalink
Eject (BlueWallet#126)
Browse files Browse the repository at this point in the history
* OPS: randombytes work
* OPS: porting to RN android: added prompt, refactoring
* OPS: better android prompt
* FIX: scan qr callback
* FIX: correct fee sat calculation for HD & classic segwit wallets
* FIX: Fixed height for button in empty transaction list
* FIX: keyboard issue on fee selection modal
* FIX: slow QR code generation for HD backup screen
* ADD: wallet reorder
* FIX: TypeError: undefined is not an object (evaluating 'recommendedFees.halfHourFee') BlueWallet#133
* FIX: android appstore link
* OPS: Code to Migrate Expo json
* REF: renamed blitzhub to lndhub
* OPS: Migration: move expo files instead of parsing
* FIX: lndhub uri usage
* FIX: no security alert on android (it was ios specific)
* REF: better tx list rendering and sorting
* ADD: verify tx on coinb.in
* FIX: Tap to dismiss is not working BlueWallet#137
* REF: Removed Wallet gradients duplication.
* REF: about screen
* FIX: bech32 qr scan in send screen
* FIX: better bip21 handling
* Use of dayjs for transaction details
* REF: QR code content follows BIP21
* ADD: fee in local currency when send
* FIX: Refresh wallet info on page focus
  • Loading branch information
Overtorment authored Dec 11, 2018
1 parent e79f342 commit 6f581a2
Show file tree
Hide file tree
Showing 148 changed files with 9,684 additions and 7,561 deletions.
9 changes: 2 additions & 7 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
{
"presets": ["babel-preset-expo"],
"env": {
"development": {
"plugins": ["transform-react-jsx-source"]
}
}
}
"presets": ["module:metro-react-native-babel-preset"]
}
39 changes: 35 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
# See https://help.github.com/ignore-files/ for more about ignoring files.

# expo
.expo/

# dependencies
/node_modules

node_modules/
# misc
.env.local
.env.development.local
Expand All @@ -18,3 +15,37 @@ yarn-debug.log*
yarn-error.log*

class/constants.js

# OSX# OSX
#
.DS_Store

# Xcode
#
build/
ios/build/*
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata
*.xccheckout
*.moved-aside
DerivedData
*.hmap
*.ipa
*.xcuserstate
#

# Android
#
android/local.properties
android/app/bluewallet-release-key.keystore
.idea
.gradle
*.iml
build/
14 changes: 0 additions & 14 deletions App.js

This file was deleted.

18 changes: 13 additions & 5 deletions App.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import Settings from './screen/settings/settings';
import Selftest from './screen/selftest';
import { BlueHeader } from './BlueComponents';
import MockStorage from './MockStorage';
global.crypto = require('crypto'); // shall be used by tests under nodejs CLI, but not in RN environment
let assert = require('assert');
jest.mock('react-native-custom-qr-codes', () => 'Video');
const AsyncStorage = new MockStorage();
Expand Down Expand Up @@ -39,6 +40,13 @@ jest.mock('ScrollView', () => {
return ScrollView;
});

jest.mock('react-native-google-analytics-bridge', () => ({
GoogleAnalyticsTracker: () => {
this.trackEvent = jest.fn();
return this;
},
}));

describe('unit - LegacyWallet', function() {
it('serialize and unserialize work correctly', () => {
let a = new LegacyWallet();
Expand Down Expand Up @@ -66,7 +74,7 @@ it('BlueHeader works', () => {
expect(rendered).toBeTruthy();
});

it('Settings work', () => {
it.skip('Settings work', () => {
const rendered = TestRenderer.create(<Settings />).toJSON();
expect(rendered).toBeTruthy();
});
Expand Down Expand Up @@ -101,7 +109,7 @@ it('Appstorage - loadFromDisk works', async () => {
let Storage = new AppStorage();
let w = new SegwitP2SHWallet();
w.setLabel('testlabel');
w.generate();
await w.generate();
Storage.wallets.push(w);
await Storage.saveToDisk();

Expand Down Expand Up @@ -130,7 +138,7 @@ it('Appstorage - encryptStorage & load encrypted storage works', async () => {
let Storage = new AppStorage();
let w = new SegwitP2SHWallet();
w.setLabel('testlabel');
w.generate();
await w.generate();
Storage.wallets.push(w);
await Storage.saveToDisk();
let isEncrypted = await Storage.storageIsEncrypted();
Expand Down Expand Up @@ -171,7 +179,7 @@ it('Appstorage - encryptStorage & load encrypted storage works', async () => {
assert.equal(Storage2.wallets[0].getLabel(), 'testlabel');
w = new SegwitP2SHWallet();
w.setLabel('testlabel2');
w.generate();
await w.generate();
Storage2.wallets.push(w);
assert.equal(Storage2.wallets.length, 2);
assert.equal(Storage2.wallets[1].getLabel(), 'testlabel2');
Expand All @@ -193,7 +201,7 @@ it('Appstorage - encryptStorage & load encrypted storage works', async () => {
assert.equal(Storage2.cachedPassword, 'fakePassword');
w = new SegwitP2SHWallet();
w.setLabel('fakewallet');
w.generate();
await w.generate();
Storage2.wallets.push(w);
await Storage2.saveToDisk();
// now, will try to load & decrypt with real password and with fake password
Expand Down
4 changes: 1 addition & 3 deletions BlueApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { AppStorage } from './class';
let prompt = require('./prompt');
let EV = require('./events');
let currency = require('./currency');
let entropy = require('./entropy');
let loc = require('./loc');
let A = require('./analytics');

Expand Down Expand Up @@ -63,8 +62,7 @@ async function startAndDecrypt(retry) {
}

A(A.ENUM.INIT);
startAndDecrypt();
BlueApp.startAndDecrypt = startAndDecrypt;
currency.startUpdater();
entropy.start();

module.exports = BlueApp;
41 changes: 23 additions & 18 deletions BlueComponents.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
/** @type {AppStorage} */
import React, { Component } from 'react';
import Ionicons from 'react-native-vector-icons/Ionicons';
import { LinearGradient, Constants } from 'expo';
import { Icon, Button, FormLabel, FormInput, Text, Header, List, ListItem } from 'react-native-elements';
import { TouchableOpacity, ActivityIndicator, View, StyleSheet, Dimensions, Image, SafeAreaView, Clipboard, Platform } from 'react-native';
import LinearGradient from 'react-native-linear-gradient';
import { WatchOnlyWallet, LegacyWallet } from './class';
import Carousel from 'react-native-snap-carousel';
import DeviceInfo from 'react-native-device-info';
import { HDLegacyP2PKHWallet } from './class/hd-legacy-p2pkh-wallet';
import { HDLegacyBreadwalletWallet } from './class/hd-legacy-breadwallet-wallet';
import { HDSegwitP2SHWallet } from './class/hd-segwit-p2sh-wallet';
Expand Down Expand Up @@ -146,18 +147,22 @@ export class BlueButtonLink extends Component {
}
}

export const BlueNavigationStyle = (navigation, withNavigationCloseButton = false) => ({
export const BlueNavigationStyle = (navigation, withNavigationCloseButton = false, customCloseButtonFunction = undefined) => ({
headerStyle: {
backgroundColor: '#FFFFFF',
borderBottomWidth: 0,
elevation: 0,
},
headerTitleStyle: {
fontWeight: '600',
color: '#0c2550',
},
headerTintColor: '#0c2550',
headerRight: withNavigationCloseButton ? (
<TouchableOpacity style={{ width: 40, height: 40, padding: 14 }} onPress={() => navigation.goBack(null)}>
<TouchableOpacity
style={{ width: 40, height: 40, padding: 14 }}
onPress={customCloseButtonFunction === undefined ? () => navigation.goBack(null) : customCloseButtonFunction}
>
<Image style={{ alignSelf: 'center' }} source={require('./img/close.png')} />
</TouchableOpacity>
) : null,
Expand Down Expand Up @@ -194,14 +199,14 @@ export class BlueText extends Component {
render() {
return (
<Text
{...this.props}
style={Object.assign(
{
color: BlueApp.settings.foregroundColor,
},
// eslint-disable-next-line
this.props.style,
)}
{...this.props}
/>
);
}
Expand Down Expand Up @@ -449,7 +454,7 @@ export class is {
if (Platform.OS !== 'ios') {
return false;
}
return Constants.platform.ios.platform === 'iPhone10,4';
return DeviceInfo.getDeviceId() === 'iPhone10,4';
}
}

Expand Down Expand Up @@ -835,7 +840,7 @@ export class BluePlusIconDimmed extends Component {
}
}

export class NewWalletPannel extends Component {
export class NewWalletPanel extends Component {
constructor(props) {
super(props);
// WalletsCarousel.handleClick = props.handleClick // because cant access `this` from _renderItem
Expand All @@ -856,12 +861,10 @@ export class NewWalletPannel extends Component {
>
<LinearGradient
colors={['#eef0f4', '#eef0f4']}
start={[0, 0]}
end={[1, 1]}
style={{
padding: 15,
borderRadius: 10,
height: 164,
minHeight: 164,
justifyContent: 'center',
alignItems: 'center',
}}
Expand Down Expand Up @@ -911,14 +914,15 @@ export class WalletsCarousel extends Component {
super(props);
// eslint-disable-next-line
WalletsCarousel.handleClick = props.handleClick; // because cant access `this` from _renderItem
WalletsCarousel.handleLongPress = props.handleLongPress;
// eslint-disable-next-line
this.onSnapToItem = props.onSnapToItem;
}

_renderItem({ item, index }) {
if (!item) {
return (
<NewWalletPannel
<NewWalletPanel
onPress={() => {
if (WalletsCarousel.handleClick) {
WalletsCarousel.handleClick(index);
Expand Down Expand Up @@ -962,29 +966,30 @@ export class WalletsCarousel extends Component {
}

return (
<View style={{ paddingRight: 10, marginVertical: 17 }}>
<View
style={{ paddingRight: 10, marginVertical: 17 }}
shadowOpacity={40 / 100}
shadowOffset={{ width: 0, height: 0 }}
shadowRadius={5}
>
<TouchableOpacity
activeOpacity={1}
onLongPress={WalletsCarousel.handleLongPress}
onPress={() => {
if (WalletsCarousel.handleClick) {
WalletsCarousel.handleClick(index);
WalletsCarousel.handleClick(index, [gradient1, gradient2]);
}
}}
>
<LinearGradient
shadowOpacity={20 / 100}
shadowOffset={{ width: 0, height: 4 }}
shadowRadius={10}
shadowColor="#000000"
colors={[gradient1, gradient2]}
style={{
padding: 15,
borderRadius: 10,
height: 164,
minHeight: 164,
elevation: 5,
}}
start={[0, 0]}
end={[1, 1]}
>
<Image
source={
Expand Down
3 changes: 2 additions & 1 deletion HDWallet.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* global it, jasmine */
import { SegwitP2SHWallet, SegwitBech32Wallet, HDSegwitP2SHWallet, HDLegacyBreadwalletWallet, HDLegacyP2PKHWallet } from './class';
global.crypto = require('crypto'); // shall be used by tests under nodejs CLI, but not in RN environment
let assert = require('assert');
let bitcoin = require('bitcoinjs-lib');

Expand Down Expand Up @@ -56,7 +57,7 @@ it('can generate Segwit HD (BIP49)', async () => {
let hd = new HDSegwitP2SHWallet();
let hashmap = {};
for (let c = 0; c < 1000; c++) {
hd.generate();
await hd.generate();
let secret = hd.getSecret();
if (hashmap[secret]) {
throw new Error('Duplicate secret generated!');
Expand Down
6 changes: 4 additions & 2 deletions LightningCustodianWallet.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ describe('LightningCustodianWallet', () => {
}
});

it.skip('can create invoice and pay other blitzhub invoice', async () => {
it('can create invoice and pay other blitzhub invoice', async () => {
jasmine.DEFAULT_TIMEOUT_INTERVAL = 100 * 1000;
if (!process.env.BLITZHUB) {
console.error('process.env.BLITZHUB not set, skipped');
Expand All @@ -192,6 +192,7 @@ describe('LightningCustodianWallet', () => {
assert.equal(invoices2.length, invoices.length + 1);
assert.ok(invoices2[0].ispaid === false);
assert.ok(invoices2[0].description);
assert.equal(invoices2[0].description, 'test memo');
assert.ok(invoices2[0].payment_request);
assert.equal(invoices2[0].amt, 1);

Expand All @@ -216,11 +217,12 @@ describe('LightningCustodianWallet', () => {
assert.equal(lNew.balance, 1);

// now, paying back that amount
oldBalance = lOld.balance;
invoice = await lOld.addInvoice(1, 'test memo');
await lNew.payInvoice(invoice);
await lOld.fetchBalance();
await lNew.fetchBalance();
assert.equal(oldBalance - lOld.balance, 0);
assert.equal(lOld.balance - oldBalance, 1);
assert.equal(lNew.balance, 0);
});
});
Loading

0 comments on commit 6f581a2

Please sign in to comment.