mirror of
https://github.com/BlueWallet/BlueWallet.git
synced 2025-02-21 14:34:55 +01:00
Merge branch 'master' into filepicker
This commit is contained in:
commit
335ad5f5d1
11 changed files with 132 additions and 56 deletions
|
@ -119,7 +119,7 @@ android {
|
|||
minSdkVersion rootProject.ext.minSdkVersion
|
||||
targetSdkVersion rootProject.ext.targetSdkVersion
|
||||
versionCode 1
|
||||
versionName "4.9.1"
|
||||
versionName "4.9.2"
|
||||
multiDexEnabled true
|
||||
missingDimensionStrategy 'react-native-camera', 'general'
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { LegacyWallet } from './legacy-wallet';
|
||||
import Frisbee from 'frisbee';
|
||||
import bolt11 from 'bolt11';
|
||||
import { BitcoinUnit, Chain } from '../models/bitcoinUnits';
|
||||
|
||||
export class LightningCustodianWallet extends LegacyWallet {
|
||||
|
@ -515,7 +516,7 @@ export class LightningCustodianWallet extends LegacyWallet {
|
|||
* Example return:
|
||||
* { destination: '03864ef025fde8fb587d989186ce6a4a186895ee44a926bfc370e2c366597a3f8f',
|
||||
* payment_hash: 'faf996300a468b668c58ca0702a12096475a0dd2c3dde8e812f954463966bcf4',
|
||||
* num_satoshisnum_satoshis: '100',
|
||||
* num_satoshis: '100',
|
||||
* timestamp: '1535116657',
|
||||
* expiry: '3600',
|
||||
* description: 'hundredSatoshis blitzhub',
|
||||
|
@ -527,31 +528,42 @@ export class LightningCustodianWallet extends LegacyWallet {
|
|||
* @param invoice BOLT invoice string
|
||||
* @return {Promise.<Object>}
|
||||
*/
|
||||
async decodeInvoice(invoice) {
|
||||
await this.checkLogin();
|
||||
decodeInvoice(invoice) {
|
||||
let { payeeNodeKey, tags, satoshis, millisatoshis, timestamp } = bolt11.decode(invoice);
|
||||
|
||||
let response = await this._api.get('/decodeinvoice?invoice=' + invoice, {
|
||||
headers: {
|
||||
'Access-Control-Allow-Origin': '*',
|
||||
'Content-Type': 'application/json',
|
||||
Authorization: 'Bearer' + ' ' + this.access_token,
|
||||
},
|
||||
});
|
||||
let decoded = {
|
||||
destination: payeeNodeKey,
|
||||
num_satoshis: satoshis ? satoshis.toString() : '0',
|
||||
num_millisatoshis: millisatoshis ? millisatoshis.toString() : '0',
|
||||
timestamp: timestamp.toString(),
|
||||
fallback_addr: '',
|
||||
route_hints: [],
|
||||
};
|
||||
|
||||
let json = response.body;
|
||||
if (typeof json === 'undefined') {
|
||||
throw new Error('API failure: ' + response.err + ' ' + JSON.stringify(response.body));
|
||||
for (let i = 0; i < tags.length; i++) {
|
||||
let { tagName, data } = tags[i];
|
||||
switch (tagName) {
|
||||
case 'payment_hash':
|
||||
decoded.payment_hash = data;
|
||||
break;
|
||||
case 'purpose_commit_hash':
|
||||
decoded.description_hash = data;
|
||||
break;
|
||||
case 'min_final_cltv_expiry':
|
||||
decoded.cltv_expiry = data.toString();
|
||||
break;
|
||||
case 'expire_time':
|
||||
decoded.expiry = data.toString();
|
||||
break;
|
||||
case 'description':
|
||||
decoded.description = data;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (json && json.error) {
|
||||
throw new Error('API error: ' + json.message + ' (code ' + json.code + ')');
|
||||
}
|
||||
if (!decoded.expiry) decoded.expiry = '3600'; // default
|
||||
|
||||
if (!json.payment_hash) {
|
||||
throw new Error('API unexpected response: ' + JSON.stringify(response.body));
|
||||
}
|
||||
|
||||
return (this.decoded_invoice_raw = json);
|
||||
return (this.decoded_invoice_raw = decoded);
|
||||
}
|
||||
|
||||
async fetchInfo() {
|
||||
|
@ -602,6 +614,49 @@ export class LightningCustodianWallet extends LegacyWallet {
|
|||
allowReceive() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Example return:
|
||||
* { destination: '03864ef025fde8fb587d989186ce6a4a186895ee44a926bfc370e2c366597a3f8f',
|
||||
* payment_hash: 'faf996300a468b668c58ca0702a12096475a0dd2c3dde8e812f954463966bcf4',
|
||||
* num_satoshis: '100',
|
||||
* timestamp: '1535116657',
|
||||
* expiry: '3600',
|
||||
* description: 'hundredSatoshis blitzhub',
|
||||
* description_hash: '',
|
||||
* fallback_addr: '',
|
||||
* cltv_expiry: '10',
|
||||
* route_hints: [] }
|
||||
*
|
||||
* @param invoice BOLT invoice string
|
||||
* @return {Promise.<Object>}
|
||||
*/
|
||||
async decodeInvoiceRemote(invoice) {
|
||||
await this.checkLogin();
|
||||
|
||||
let response = await this._api.get('/decodeinvoice?invoice=' + invoice, {
|
||||
headers: {
|
||||
'Access-Control-Allow-Origin': '*',
|
||||
'Content-Type': 'application/json',
|
||||
Authorization: 'Bearer' + ' ' + this.access_token,
|
||||
},
|
||||
});
|
||||
|
||||
let json = response.body;
|
||||
if (typeof json === 'undefined') {
|
||||
throw new Error('API failure: ' + response.err + ' ' + JSON.stringify(response.body));
|
||||
}
|
||||
|
||||
if (json && json.error) {
|
||||
throw new Error('API error: ' + json.message + ' (code ' + json.code + ')');
|
||||
}
|
||||
|
||||
if (!json.payment_hash) {
|
||||
throw new Error('API unexpected response: ' + JSON.stringify(response.body));
|
||||
}
|
||||
|
||||
return (this.decoded_invoice_raw = json);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -48,7 +48,7 @@
|
|||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>4.9.1</string>
|
||||
<string>4.9.2</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleURLTypes</key>
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
<key>CFBundlePackageType</key>
|
||||
<string>XPC!</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>4.9.1</string>
|
||||
<string>4.9.2</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>239</string>
|
||||
<key>CLKComplicationPrincipalClass</key>
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>4.9.1</string>
|
||||
<string>4.9.2</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>239</string>
|
||||
<key>UISupportedInterfaceOrientations</key>
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
<key>CFBundlePackageType</key>
|
||||
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>4.9.1</string>
|
||||
<string>4.9.2</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1</string>
|
||||
<key>NSExtension</key>
|
||||
|
|
|
@ -1,3 +1,24 @@
|
|||
v4.9.2
|
||||
======
|
||||
|
||||
* ADD: Swipe to Scan
|
||||
* ADD: Handle clipboard content with both bitcoin: and lightning:
|
||||
* ADD: Ask user if they have backed up their seed phrase
|
||||
* ADD: Export screen allows copying to clipboard if its a LNDHub wallet
|
||||
* ADD: Show LNDHub backup when creating lnd wallet
|
||||
* ADD: CLP Fiat
|
||||
* FIX: TX Time visual glitch
|
||||
* FIX: Show an alert when theres a fetch transactions error
|
||||
* FIX: TX list uses whole canvas area
|
||||
* FIX: Don't allow empty wallet labels
|
||||
* FIX: Wallet type selecion clipping on advanced mode
|
||||
* FIX: Receive address was not being rendered
|
||||
* FIX: Don't show wallet export warning if wallet was imported
|
||||
* REF: Reworked Import wallet flow
|
||||
* REF: BIP49 to use electrum
|
||||
* REF: Custom receive
|
||||
|
||||
|
||||
v4.9.0
|
||||
======
|
||||
|
||||
|
@ -30,24 +51,4 @@ v4.8.0
|
|||
* FIX: layout for small devices with flexbox
|
||||
* FIX: Dont allow zero invoices to enable create invoice button
|
||||
* FIX: Change create button on Receive LN payment should be create invoice
|
||||
* FIX: Update for watch
|
||||
|
||||
|
||||
v4.7.1
|
||||
======
|
||||
|
||||
* ADD: Lapp browser
|
||||
* FIX: White screen on boot
|
||||
* FIX: Lightning wallet was not shown on Watch app
|
||||
* FIX: crash on PSBT tx broadcast (when using with hardware wallet)
|
||||
* REF: mnemonic backup screen
|
||||
* DEL: Auto brightenss
|
||||
|
||||
v4.7.0
|
||||
======
|
||||
|
||||
* ADD: external marketplace link
|
||||
* FIX: electrum connection
|
||||
* FIX: Now able to use biometrics with encrypted storage (not for unlocking)
|
||||
* FIX: LApp marketplace address is now editable
|
||||
* FIX: single address watch-only wallet Receive button crash
|
||||
* FIX: Update for watch
|
2
package-lock.json
generated
2
package-lock.json
generated
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "BlueWallet",
|
||||
"version": "4.9.1",
|
||||
"version": "4.9.2",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "BlueWallet",
|
||||
"version": "4.9.1",
|
||||
"version": "4.9.2",
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.5.0",
|
||||
"@babel/runtime": "^7.5.1",
|
||||
|
@ -38,7 +38,8 @@
|
|||
"postinstall": "./node_modules/.bin/rn-nodeify --install buffer,events,process,stream,util,inherits,fs,path --hack; npm run releasenotes2json; npm run podinstall; npx jetify",
|
||||
"test": "npm run unit && npm run jest && npm run lint",
|
||||
"jest": "node node_modules/jest/bin/jest.js tests/integration/*",
|
||||
"lint": "./node_modules/.bin/eslint *.js screen/**/*.js screen/ class/ models/ loc/ tests/integration/ --fix",
|
||||
"lint": "./node_modules/.bin/eslint *.js screen/**/*.js screen/ class/ models/ loc/ tests/integration/",
|
||||
"lint:fix": "./node_modules/.bin/eslint *.js screen/**/*.js screen/ class/ models/ loc/ tests/integration/ --fix",
|
||||
"unit": "./node_modules/.bin/mocha tests/unit/*"
|
||||
},
|
||||
"jest": {
|
||||
|
@ -64,6 +65,7 @@
|
|||
"bip32": "2.0.3",
|
||||
"bip39": "2.5.0",
|
||||
"bitcoinjs-lib": "5.1.6",
|
||||
"bolt11": "1.2.7",
|
||||
"buffer": "5.2.1",
|
||||
"buffer-reverse": "1.0.1",
|
||||
"coinselect": "3.1.11",
|
||||
|
|
|
@ -122,7 +122,7 @@ export default class ScanLndInvoice extends React.Component {
|
|||
let w = this.state.fromWallet;
|
||||
let decoded;
|
||||
try {
|
||||
decoded = await w.decodeInvoice(data);
|
||||
decoded = w.decodeInvoice(data);
|
||||
|
||||
let expiresIn = (decoded.timestamp * 1 + decoded.expiry * 1) * 1000; // ms
|
||||
if (+new Date() > expiresIn) {
|
||||
|
|
|
@ -100,11 +100,12 @@ describe('LightningCustodianWallet', () => {
|
|||
|
||||
let invoice =
|
||||
'lnbc1u1pdcqpt3pp5ltuevvq2g69kdrzcegrs9gfqjer45rwjc0w736qjl92yvwtxhn6qdp8dp6kuerjv4j9xct5daeks6tnyp3xc6t50f582cscqp2zrkghzl535xjav52ns0rpskcn20takzdr2e02wn4xqretlgdemg596acq5qtfqhjk4jpr7jk8qfuuka2k0lfwjsk9mchwhxcgxzj3tsp09gfpy';
|
||||
let decoded = await l2.decodeInvoice(invoice);
|
||||
let decoded = l2.decodeInvoice(invoice);
|
||||
|
||||
assert.ok(decoded.payment_hash);
|
||||
assert.ok(decoded.description);
|
||||
assert.ok(decoded.num_satoshis);
|
||||
assert.strictEqual(parseInt(decoded.num_satoshis) * 1000, parseInt(decoded.num_millisatoshis));
|
||||
|
||||
await l2.checkRouteInvoice(invoice);
|
||||
|
||||
|
@ -112,13 +113,30 @@ describe('LightningCustodianWallet', () => {
|
|||
invoice = 'gsom';
|
||||
let error = false;
|
||||
try {
|
||||
await l2.decodeInvoice(invoice);
|
||||
l2.decodeInvoice(invoice);
|
||||
} catch (Err) {
|
||||
error = true;
|
||||
}
|
||||
assert.ok(error);
|
||||
});
|
||||
|
||||
it('can decode invoice locally & remotely', async () => {
|
||||
let l2 = new LightningCustodianWallet();
|
||||
l2.setSecret(process.env.BLITZHUB);
|
||||
await l2.authorize();
|
||||
let invoice =
|
||||
'lnbc1u1pdcqpt3pp5ltuevvq2g69kdrzcegrs9gfqjer45rwjc0w736qjl92yvwtxhn6qdp8dp6kuerjv4j9xct5daeks6tnyp3xc6t50f582cscqp2zrkghzl535xjav52ns0rpskcn20takzdr2e02wn4xqretlgdemg596acq5qtfqhjk4jpr7jk8qfuuka2k0lfwjsk9mchwhxcgxzj3tsp09gfpy';
|
||||
let decodedLocally = l2.decodeInvoice(invoice);
|
||||
let decodedRemotely = await l2.decodeInvoiceRemote(invoice);
|
||||
assert.strictEqual(decodedLocally.destination, decodedRemotely.destination);
|
||||
assert.strictEqual(decodedLocally.num_satoshis, decodedRemotely.num_satoshis);
|
||||
assert.strictEqual(decodedLocally.timestamp, decodedRemotely.timestamp);
|
||||
assert.strictEqual(decodedLocally.expiry, decodedRemotely.expiry);
|
||||
assert.strictEqual(decodedLocally.payment_hash, decodedRemotely.payment_hash);
|
||||
assert.strictEqual(decodedLocally.description, decodedRemotely.description);
|
||||
assert.strictEqual(decodedLocally.cltv_expiry, decodedRemotely.cltv_expiry);
|
||||
});
|
||||
|
||||
it('can pay invoice', async () => {
|
||||
jasmine.DEFAULT_TIMEOUT_INTERVAL = 100 * 1000;
|
||||
if (!process.env.BLITZHUB) {
|
||||
|
@ -155,7 +173,7 @@ describe('LightningCustodianWallet', () => {
|
|||
await l2.fetchTransactions();
|
||||
let txLen = l2.transactions_raw.length;
|
||||
|
||||
let decoded = await l2.decodeInvoice(invoice);
|
||||
let decoded = l2.decodeInvoice(invoice);
|
||||
assert.ok(decoded.payment_hash);
|
||||
assert.ok(decoded.description);
|
||||
|
||||
|
@ -336,7 +354,7 @@ describe('LightningCustodianWallet', () => {
|
|||
let oldBalance = +l2.balance;
|
||||
let txLen = l2.transactions_raw.length;
|
||||
|
||||
let decoded = await l2.decodeInvoice(invoice);
|
||||
let decoded = l2.decodeInvoice(invoice);
|
||||
assert.ok(decoded.payment_hash);
|
||||
assert.ok(decoded.description);
|
||||
assert.strictEqual(+decoded.num_satoshis, 0);
|
||||
|
@ -443,7 +461,7 @@ describe('LightningCustodianWallet', () => {
|
|||
let oldBalance = +l2.balance;
|
||||
let txLen = l2.transactions_raw.length;
|
||||
|
||||
let decoded = await l2.decodeInvoice(invoice);
|
||||
let decoded = l2.decodeInvoice(invoice);
|
||||
assert.ok(decoded.payment_hash);
|
||||
assert.ok(decoded.description);
|
||||
assert.strictEqual(+decoded.num_satoshis, 0);
|
||||
|
|
Loading…
Add table
Reference in a new issue