mirror of
https://github.com/BlueWallet/BlueWallet.git
synced 2024-11-19 01:40:12 +01:00
add standard w plugins
This commit is contained in:
parent
d854c20240
commit
94dbc388d4
4
App.js
4
App.js
@ -2,7 +2,7 @@
|
||||
let BlueApp = require('./BlueApp')
|
||||
import './shim.js'
|
||||
if (!Error.captureStackTrace) { // captureStackTrace is only available when debugging
|
||||
Error.captureStackTrace = () => {};
|
||||
Error.captureStackTrace = () => {}
|
||||
}
|
||||
import React from 'react'
|
||||
import { Text, ScrollView, StyleSheet } from 'react-native'
|
||||
@ -70,7 +70,7 @@ const TabsInDrawer = DrawerNavigator({
|
||||
contentComponent: CustomDrawerContentComponent,
|
||||
drawerOpenRoute: 'DrawerOpen',
|
||||
drawerCloseRoute: 'DrawerClose',
|
||||
drawerToggleRoute: 'DrawerToggle',
|
||||
drawerToggleRoute: 'DrawerToggle'
|
||||
|
||||
})
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
import React from 'react'
|
||||
import { AppStorage, LegacyWallet, SegwitBech32Wallet, SegwitP2SHWallet } from './class'
|
||||
let assert = require('assert');
|
||||
let assert = require('assert')
|
||||
|
||||
describe('unit - LegacyWallet', function () {
|
||||
it('serialize and unserialize work correctly', () => {
|
||||
|
@ -1,13 +1,10 @@
|
||||
/** @type {AppStorage} */
|
||||
let BlueApp = require('./BlueApp')
|
||||
import React, { Component } from 'react';
|
||||
import React, { Component } from 'react'
|
||||
import { Button } from 'react-native-elements'
|
||||
import { SafeAreaView, } from 'react-navigation';
|
||||
import { FormLabel, FormInput, Divider, Icon, Card,Text, Header, List, ListItem, Avatar } from 'react-native-elements'
|
||||
import { ActivityIndicator, StyleSheet, ListView, View } from 'react-native';
|
||||
|
||||
|
||||
|
||||
import { SafeAreaView } from 'react-navigation'
|
||||
import { FormLabel, FormInput, Divider, Icon, Card, Text, Header, List, ListItem, Avatar } from 'react-native-elements'
|
||||
import { ActivityIndicator, StyleSheet, ListView, View } from 'react-native'
|
||||
|
||||
export class BlueButton extends Component {
|
||||
constructor (props) {
|
||||
@ -18,7 +15,7 @@ export class BlueButton extends Component {
|
||||
return (
|
||||
<Button
|
||||
{...this.props}
|
||||
style={{marginTop:20, borderRadius: 6, borderWidth: 0.7,borderColor: '#ffffff',}}
|
||||
style={{marginTop: 20, borderRadius: 6, borderWidth: 0.7, borderColor: '#ffffff'}}
|
||||
borderRadius={10}
|
||||
backgroundColor={BlueApp.settings.buttonBackground}
|
||||
|
||||
@ -28,7 +25,6 @@ export class BlueButton extends Component {
|
||||
/* icon={{name: 'home', type: 'octicon'}} */
|
||||
}
|
||||
|
||||
|
||||
export class SafeBlueArea extends Component {
|
||||
constructor (props) {
|
||||
super(props)
|
||||
@ -38,10 +34,9 @@ export class SafeBlueArea extends Component {
|
||||
return (
|
||||
<SafeAreaView
|
||||
{...this.props}
|
||||
forceInset={{ horizontal: 'always' }} style={{flex: 1, backgroundColor: BlueApp.settings.brandingColor}}
|
||||
forceInset={{ horizontal: 'always' }} style={{flex: 1, backgroundColor: BlueApp.settings.brandingColor}}
|
||||
/>
|
||||
)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -59,11 +54,9 @@ export class BlueCard extends Component {
|
||||
wrapperStyle={{backgroundColor: BlueApp.settings.buttonBackground}}
|
||||
/>
|
||||
)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export class BlueText extends Component {
|
||||
constructor (props) {
|
||||
super(props)
|
||||
@ -76,12 +69,9 @@ export class BlueText extends Component {
|
||||
style={{color: 'white'}}
|
||||
/>
|
||||
)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
export class BlueListItem extends Component {
|
||||
constructor (props) {
|
||||
super(props)
|
||||
@ -91,16 +81,14 @@ export class BlueListItem extends Component {
|
||||
return (
|
||||
<ListItem
|
||||
{...this.props}
|
||||
containerStyle={{backgroundColor: BlueApp.settings.brandingColor,}}
|
||||
titleStyle={{color:"white", fontSize: 18,}}
|
||||
subtitleStyle={{color:"white"}}
|
||||
containerStyle={{backgroundColor: BlueApp.settings.brandingColor}}
|
||||
titleStyle={{color: 'white', fontSize: 18}}
|
||||
subtitleStyle={{color: 'white'}}
|
||||
/>
|
||||
)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export class BlueFormLabel extends Component {
|
||||
constructor (props) {
|
||||
super(props)
|
||||
@ -110,14 +98,12 @@ export class BlueFormLabel extends Component {
|
||||
return (
|
||||
<FormLabel
|
||||
{...this.props}
|
||||
labelStyle={{color:"white"}}
|
||||
labelStyle={{color: 'white'}}
|
||||
/>
|
||||
)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export class BlueFormInput extends Component {
|
||||
constructor (props) {
|
||||
super(props)
|
||||
@ -127,10 +113,9 @@ export class BlueFormInput extends Component {
|
||||
return (
|
||||
<FormInput
|
||||
{...this.props}
|
||||
inputStyle={{color:"white"}}
|
||||
inputStyle={{color: 'white'}}
|
||||
/>
|
||||
)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -146,11 +131,9 @@ export class BlueHeader extends Component {
|
||||
backgroundColor={BlueApp.settings.brandingColor}
|
||||
/>
|
||||
)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export class BlueSpacing extends Component {
|
||||
constructor (props) {
|
||||
super(props)
|
||||
@ -163,11 +146,9 @@ export class BlueSpacing extends Component {
|
||||
style={{height: 60, backgroundColor: BlueApp.settings.brandingColor}}
|
||||
/>
|
||||
)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export class BlueSpacing20 extends Component {
|
||||
constructor (props) {
|
||||
super(props)
|
||||
@ -180,11 +161,9 @@ export class BlueSpacing20 extends Component {
|
||||
style={{height: 20, backgroundColor: BlueApp.settings.brandingColor}}
|
||||
/>
|
||||
)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export class BlueListView extends Component {
|
||||
constructor (props) {
|
||||
super(props)
|
||||
@ -196,11 +175,9 @@ export class BlueListView extends Component {
|
||||
{...this.props}
|
||||
/>
|
||||
)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export class BlueList extends Component {
|
||||
constructor (props) {
|
||||
super(props)
|
||||
@ -210,14 +187,12 @@ export class BlueList extends Component {
|
||||
return (
|
||||
<List
|
||||
{...this.props}
|
||||
containerStyle={{backgroundColor: BlueApp.settings.brandingColor,}}
|
||||
containerStyle={{backgroundColor: BlueApp.settings.brandingColor}}
|
||||
/>
|
||||
)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export class BlueView extends Component {
|
||||
constructor (props) {
|
||||
super(props)
|
||||
@ -227,14 +202,12 @@ export class BlueView extends Component {
|
||||
return (
|
||||
<View
|
||||
{...this.props}
|
||||
containerStyle={{backgroundColor: BlueApp.settings.brandingColor,}}
|
||||
containerStyle={{backgroundColor: BlueApp.settings.brandingColor}}
|
||||
/>
|
||||
)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export class BlueLoading extends Component {
|
||||
constructor (props) {
|
||||
super(props)
|
||||
@ -248,7 +221,5 @@ export class BlueLoading extends Component {
|
||||
</View>
|
||||
</SafeBlueArea>
|
||||
)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -44,7 +44,7 @@ const Tabs = TabNavigator(
|
||||
activeTintColor: 'white',
|
||||
activeBackgroundColor: '#33bdf1',
|
||||
inactiveBackgroundColor: BlueApp.settings.brandingColor,
|
||||
inactiveTintColor: "white",
|
||||
inactiveTintColor: 'white'
|
||||
}
|
||||
}
|
||||
)
|
||||
|
35
class.js
35
class.js
@ -7,7 +7,7 @@ let useBlockcypherTokens = false
|
||||
let bitcoin = require('bitcoinjs-lib')
|
||||
let signer = require('./models/signer')
|
||||
let BigNumber = require('bignumber.js')
|
||||
let isaac = require( 'isaac' );
|
||||
let isaac = require('isaac')
|
||||
// alternative https://github.com/pointbiz/bitaddress.org/blob/master/src/securerandom.js
|
||||
|
||||
let assert = require('assert')
|
||||
@ -69,7 +69,7 @@ class AbstractWallet {
|
||||
|
||||
getAddress () {}
|
||||
|
||||
//createTx () { throw Error('not implemented') }
|
||||
// createTx () { throw Error('not implemented') }
|
||||
}
|
||||
|
||||
/**
|
||||
@ -86,18 +86,18 @@ export class LegacyWallet extends AbstractWallet {
|
||||
function myRng (c) {
|
||||
let buf = new Buffer(c)
|
||||
let totalhex = ''
|
||||
for (let i = 0; i<c; i++) {
|
||||
for (let i = 0; i < c; i++) {
|
||||
let random_number = isaac.random()
|
||||
random_number = Math.floor(random_number * 255);
|
||||
let n = new BigNumber( random_number )
|
||||
random_number = Math.floor(random_number * 255)
|
||||
let n = new BigNumber(random_number)
|
||||
let hex = n.toString(16)
|
||||
if (hex.length === 1) {
|
||||
hex = '0' + hex
|
||||
}
|
||||
totalhex += hex
|
||||
}
|
||||
totalhex = bitcoin.crypto.sha256('oh hai!' + totalhex).toString('hex')
|
||||
totalhex = bitcoin.crypto.sha256(totalhex).toString('hex')
|
||||
totalhex = bitcoin.crypto.sha256('oh hai!' + totalhex).toString('hex')
|
||||
totalhex = bitcoin.crypto.sha256(totalhex).toString('hex')
|
||||
buf.fill(totalhex, 0, 'hex')
|
||||
return buf
|
||||
}
|
||||
@ -127,7 +127,7 @@ export class LegacyWallet extends AbstractWallet {
|
||||
|
||||
async fetchBalance () {
|
||||
let response
|
||||
;let token = ((array) => {
|
||||
let token = ((array) => {
|
||||
for (let i = array.length - 1; i > 0; i--) {
|
||||
let j = Math.floor(Math.random() * (i + 1));
|
||||
[array[i], array[j]] = [array[j], array[i]]
|
||||
@ -152,7 +152,7 @@ export class LegacyWallet extends AbstractWallet {
|
||||
|
||||
async fetchUtxo () {
|
||||
let response
|
||||
;let token = ((array) => {
|
||||
let token = ((array) => {
|
||||
for (let i = array.length - 1; i > 0; i--) {
|
||||
let j = Math.floor(Math.random() * (i + 1));
|
||||
[array[i], array[j]] = [array[j], array[i]]
|
||||
@ -185,7 +185,7 @@ export class LegacyWallet extends AbstractWallet {
|
||||
|
||||
async fetchTransactions () {
|
||||
let response
|
||||
;let token = ((array) => {
|
||||
let token = ((array) => {
|
||||
for (let i = array.length - 1; i > 0; i--) {
|
||||
let j = Math.floor(Math.random() * (i + 1));
|
||||
[array[i], array[j]] = [array[j], array[i]]
|
||||
@ -240,7 +240,6 @@ export class LegacyWallet extends AbstractWallet {
|
||||
}
|
||||
|
||||
async broadcastTx (txhex) {
|
||||
|
||||
const api = new Frisbee({
|
||||
baseURI: 'https://btczen.com',
|
||||
headers: {
|
||||
@ -253,9 +252,7 @@ export class LegacyWallet extends AbstractWallet {
|
||||
console.log('response', res.body)
|
||||
return res.body
|
||||
|
||||
|
||||
return
|
||||
/*const api = new Frisbee({
|
||||
/* const api = new Frisbee({
|
||||
baseURI: 'https://api.blockcypher.com',
|
||||
headers: {
|
||||
'Accept': 'application/json',
|
||||
@ -272,7 +269,7 @@ export class LegacyWallet extends AbstractWallet {
|
||||
console.log('broadcast using token')
|
||||
let res = await api.post('/v1/btc/main/txs/push?token=' + token, {body: {'tx': txhex}})
|
||||
console.log('response', res.body)
|
||||
return res.body*/
|
||||
return res.body */
|
||||
}
|
||||
}
|
||||
|
||||
@ -341,7 +338,7 @@ export class SegwitP2SHWallet extends LegacyWallet {
|
||||
u.amount = u.amount.div(100000000)
|
||||
u.amount = u.amount.toString(10)
|
||||
}
|
||||
console.log('creating tx ', amount, ' with fee ', fee, 'secret=',this.getSecret(), 'from address',this.getAddress())
|
||||
console.log('creating tx ', amount, ' with fee ', fee, 'secret=', this.getSecret(), 'from address', this.getAddress())
|
||||
let amountPlusFee = parseFloat((new BigNumber(amount)).add(fee).toString(10))
|
||||
// to compensate that module substracts fee from amount
|
||||
return signer.createSegwitTransaction(utxos, address, amountPlusFee, fee, this.getSecret(), this.getAddress(), sequence)
|
||||
@ -356,7 +353,7 @@ export class AppStorage {
|
||||
this.settings = {
|
||||
brandingColor: '#00aced',
|
||||
buttonBackground: '#00aced',
|
||||
buttonDangedBackground: '#F40349',
|
||||
buttonDangedBackground: '#F40349'
|
||||
}
|
||||
}
|
||||
|
||||
@ -420,7 +417,7 @@ export class AppStorage {
|
||||
|
||||
let data = {
|
||||
wallets: walletsToSave,
|
||||
tx_metadata: this.tx_metadata,
|
||||
tx_metadata: this.tx_metadata
|
||||
}
|
||||
|
||||
return AsyncStorage.setItem('data', JSON.stringify(data))
|
||||
@ -469,4 +466,4 @@ export class AppStorage {
|
||||
}
|
||||
return finalBalance
|
||||
}
|
||||
}
|
||||
}
|
||||
|
6065
package-lock.json
generated
6065
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
10
package.json
10
package.json
@ -3,12 +3,20 @@
|
||||
"version": "1.0.1",
|
||||
"private": true,
|
||||
"devDependencies": {
|
||||
"eslint": "^4.19.0",
|
||||
"eslint-config-standard": "^11.0.0",
|
||||
"eslint-config-standard-react": "^6.0.0",
|
||||
"eslint-plugin-import": "^2.9.0",
|
||||
"eslint-plugin-node": "^6.0.1",
|
||||
"eslint-plugin-promise": "^3.7.0",
|
||||
"eslint-plugin-react": "^7.7.0",
|
||||
"eslint-plugin-standard": "^3.0.1",
|
||||
"jest-expo": "^23.0.0",
|
||||
"react-native-scripts": "1.8.1",
|
||||
"react-test-renderer": "16.0.0",
|
||||
"rn-nodeify": "^8.3.0",
|
||||
"snazzy": "^7.0.0",
|
||||
"standard": "^11.0.0"
|
||||
"standard": "^11.0.1"
|
||||
},
|
||||
"main": "./node_modules/react-native-scripts/build/bin/crna-entry.js",
|
||||
"scripts": {
|
||||
|
@ -26,7 +26,7 @@ const WalletsNavigator = StackNavigator({
|
||||
},
|
||||
WalletExport: {
|
||||
screen: WalletExport
|
||||
},
|
||||
}
|
||||
}, {
|
||||
headerMode: 'none',
|
||||
mode: 'modal'
|
||||
|
@ -4,7 +4,6 @@ let assert = require('assert')
|
||||
|
||||
describe('unit - signer', function () {
|
||||
describe('createTransaction()', function () {
|
||||
|
||||
it('should return valid tx hex for segwit transactions', function (done) {
|
||||
let signer = require('../../models/signer')
|
||||
let utxos = [{ txid: '1e1a8cced5580eecd0ac15845fc3adfafbb0f5944a54950e4a16b8f6d1e9b715', vout: 1, address: '3Bsssbs4ANCGNETvGLJ3Fvri6SiVnH1fbi', account: '3Bsssbs4ANCGNETvGLJ3Fvri6SiVnH1fbi', scriptPubKey: 'a9146fbf1cee74734503297e46a0db3e3fbb06f2e9d387', amount: 0.001, confirmations: 108, spendable: false, solvable: false, safe: true }]
|
||||
|
Loading…
Reference in New Issue
Block a user