mirror of
https://github.com/BlueWallet/BlueWallet.git
synced 2025-02-22 15:04:50 +01:00
WIP: lnd
This commit is contained in:
parent
984278ec7e
commit
a08b3527bc
8 changed files with 29 additions and 22 deletions
|
@ -643,7 +643,7 @@ export class BlueTransactionOffchainIcon extends Component {
|
||||||
size={16}
|
size={16}
|
||||||
type="font-awesome"
|
type="font-awesome"
|
||||||
color="#d0021b"
|
color="#d0021b"
|
||||||
iconStyle={{ left: 0, top: 7, transform: [{ rotate: '135deg' }] }}
|
iconStyle={{ left: 0, top: 7, transform: [{ rotate: '155deg' }] }}
|
||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
|
|
|
@ -3,7 +3,7 @@ import Frisbee from 'frisbee';
|
||||||
import { LightningCustodianWallet } from './class';
|
import { LightningCustodianWallet } from './class';
|
||||||
let assert = require('assert');
|
let assert = require('assert');
|
||||||
|
|
||||||
describe.skip('LightningCustodianWallet', () => {
|
describe('LightningCustodianWallet', () => {
|
||||||
let l1 = new LightningCustodianWallet();
|
let l1 = new LightningCustodianWallet();
|
||||||
|
|
||||||
it.skip('can issue wallet credentials', async () => {
|
it.skip('can issue wallet credentials', async () => {
|
||||||
|
@ -168,7 +168,7 @@ describe.skip('LightningCustodianWallet', () => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
it('can create invoice and pay other blitzhub invoice', async () => {
|
it.skip('can create invoice and pay other blitzhub invoice', async () => {
|
||||||
jasmine.DEFAULT_TIMEOUT_INTERVAL = 100 * 1000;
|
jasmine.DEFAULT_TIMEOUT_INTERVAL = 100 * 1000;
|
||||||
if (!process.env.BLITZHUB) {
|
if (!process.env.BLITZHUB) {
|
||||||
console.error('process.env.BLITZHUB not set, skipped');
|
console.error('process.env.BLITZHUB not set, skipped');
|
||||||
|
@ -212,8 +212,8 @@ describe.skip('LightningCustodianWallet', () => {
|
||||||
|
|
||||||
await lOld.fetchBalance();
|
await lOld.fetchBalance();
|
||||||
await lNew.fetchBalance();
|
await lNew.fetchBalance();
|
||||||
assert.equal(oldBalance - lOld.balance, 100);
|
assert.equal(oldBalance - lOld.balance, 1);
|
||||||
assert.equal(lNew.balance, 100);
|
assert.equal(lNew.balance, 1);
|
||||||
|
|
||||||
// now, paying back that amount
|
// now, paying back that amount
|
||||||
invoice = await lOld.addInvoice(1, 'test memo');
|
invoice = await lOld.addInvoice(1, 'test memo');
|
||||||
|
|
|
@ -292,29 +292,31 @@ export class LightningCustodianWallet extends LegacyWallet {
|
||||||
getTransactions() {
|
getTransactions() {
|
||||||
let txs = [];
|
let txs = [];
|
||||||
this.pending_transactions_raw = this.pending_transactions_raw || [];
|
this.pending_transactions_raw = this.pending_transactions_raw || [];
|
||||||
console.log('this.pending_transactions_raw', this.pending_transactions_raw);
|
|
||||||
this.transactions_raw = this.transactions_raw || [];
|
this.transactions_raw = this.transactions_raw || [];
|
||||||
console.log('this.transactions_raw', this.transactions_raw);
|
|
||||||
txs = txs.concat(this.pending_transactions_raw, this.transactions_raw.slice().reverse()); // slice so array is cloned
|
txs = txs.concat(this.pending_transactions_raw, this.transactions_raw.slice().reverse()); // slice so array is cloned
|
||||||
// transforming to how wallets/list screen expects it
|
// transforming to how wallets/list screen expects it
|
||||||
for (let tx of txs) {
|
for (let tx of txs) {
|
||||||
tx.value = parseInt(tx.amount * 100000000);
|
|
||||||
tx.received = new Date(tx.time * 1000).toString();
|
tx.received = new Date(tx.time * 1000).toString();
|
||||||
tx.memo = 'On-chain transaction';
|
|
||||||
|
|
||||||
if (typeof tx.amt !== 'undefined' && typeof tx.fee !== 'undefined') {
|
if (typeof tx.amt !== 'undefined' && typeof tx.fee !== 'undefined') {
|
||||||
// lnd tx outgoing
|
// lnd tx outgoing
|
||||||
tx.value = parseInt((tx.amt * 1 + tx.fee * 1) * -1);
|
tx.value = parseInt((tx.amt * 1 + tx.fee * 1) * -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tx.type === 'paid_invoices') {
|
if (tx.type === 'paid_invoice') {
|
||||||
tx.memo = 'Lightning payment'; // TODO once api is ready
|
tx.memo = tx.memo || 'Lightning payment';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tx.type === 'bitcoind_tx') {
|
||||||
|
tx.memo = 'On-chain transaction';
|
||||||
}
|
}
|
||||||
|
|
||||||
tx.received = new Date(tx.timestamp * 1000).toString(); // TODO once api is ready
|
tx.received = new Date(tx.timestamp * 1000).toString(); // TODO once api is ready
|
||||||
}
|
}
|
||||||
console.log('getTx', txs);
|
console.log('getTx', txs);
|
||||||
return txs;
|
return txs.sort(function(a, b) {
|
||||||
|
return b.timestamp - a.timestamp;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async fetchPendingTransactions() {
|
async fetchPendingTransactions() {
|
||||||
|
|
|
@ -23,10 +23,10 @@
|
||||||
"main": "./node_modules/react-native-scripts/build/bin/crna-entry.js",
|
"main": "./node_modules/react-native-scripts/build/bin/crna-entry.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"prepare": "./patches/fix_mangle.sh; git apply patches/transaction_builder.js.patch; git apply ./patches/transaction.js.patch",
|
"prepare": "./patches/fix_mangle.sh; git apply patches/transaction_builder.js.patch; git apply ./patches/transaction.js.patch",
|
||||||
"start": "react-native-scripts start",
|
"start": "expo start",
|
||||||
"eject": "react-native-scripts eject",
|
"eject": "expo eject",
|
||||||
"android": "react-native-scripts android",
|
"android": "expo android",
|
||||||
"ios": "react-native-scripts ios",
|
"ios": "expo ios",
|
||||||
"postinstall": "./node_modules/.bin/rn-nodeify --install buffer,events,process,stream,util,inherits,fs,path --hack",
|
"postinstall": "./node_modules/.bin/rn-nodeify --install buffer,events,process,stream,util,inherits,fs,path --hack",
|
||||||
"test": "npm run unit && npm run jest && npm run lint",
|
"test": "npm run unit && npm run jest && npm run lint",
|
||||||
"jest": "node node_modules/jest/bin/jest.js",
|
"jest": "node node_modules/jest/bin/jest.js",
|
||||||
|
|
|
@ -19,7 +19,9 @@ const { width } = Dimensions.get('window');
|
||||||
|
|
||||||
export default class ScanLndInvoice extends React.Component {
|
export default class ScanLndInvoice extends React.Component {
|
||||||
static navigationOptions = {
|
static navigationOptions = {
|
||||||
tabBarVisible: false,
|
header: ({ navigation }) => {
|
||||||
|
return <View />;
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
state = {
|
state = {
|
||||||
|
@ -48,7 +50,7 @@ export default class ScanLndInvoice extends React.Component {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
async onBarCodeRead(ret) {
|
async onBarCodeScanned(ret) {
|
||||||
if (this.ignoreRead) return;
|
if (this.ignoreRead) return;
|
||||||
this.ignoreRead = true;
|
this.ignoreRead = true;
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
@ -220,7 +222,8 @@ export default class ScanLndInvoice extends React.Component {
|
||||||
}}
|
}}
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
this.setState({
|
this.setState({
|
||||||
type: this.state.type === BarCodeScanner.Constants.Type.back
|
type:
|
||||||
|
this.state.type === BarCodeScanner.Constants.Type.back
|
||||||
? BarCodeScanner.Constants.Type.front
|
? BarCodeScanner.Constants.Type.front
|
||||||
: BarCodeScanner.Constants.Type.back,
|
: BarCodeScanner.Constants.Type.back,
|
||||||
});
|
});
|
||||||
|
|
|
@ -77,7 +77,8 @@ export default class CameraExample extends React.Component {
|
||||||
}}
|
}}
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
this.setState({
|
this.setState({
|
||||||
type: this.state.type === BarCodeScanner.Constants.Type.back
|
type:
|
||||||
|
this.state.type === BarCodeScanner.Constants.Type.back
|
||||||
? BarCodeScanner.Constants.Type.front
|
? BarCodeScanner.Constants.Type.front
|
||||||
: BarCodeScanner.Constants.Type.back,
|
: BarCodeScanner.Constants.Type.back,
|
||||||
});
|
});
|
||||||
|
|
|
@ -412,7 +412,7 @@ export default class WalletsList extends Component {
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (rowData.item.type === 'paid_invoices') {
|
if (rowData.item.type === 'paid_invoice') {
|
||||||
// is it lightning offchain payment?
|
// is it lightning offchain payment?
|
||||||
return (
|
return (
|
||||||
<View style={{ width: 25 }}>
|
<View style={{ width: 25 }}>
|
||||||
|
|
|
@ -192,7 +192,8 @@ export default class ScanQrWif extends React.Component {
|
||||||
}}
|
}}
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
this.setState({
|
this.setState({
|
||||||
type: this.state.type === BarCodeScanner.Constants.Type.back
|
type:
|
||||||
|
this.state.type === BarCodeScanner.Constants.Type.back
|
||||||
? BarCodeScanner.Constants.Type.front
|
? BarCodeScanner.Constants.Type.front
|
||||||
: BarCodeScanner.Constants.Type.back,
|
: BarCodeScanner.Constants.Type.back,
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Reference in a new issue