mirror of
https://github.com/BlueWallet/BlueWallet.git
synced 2025-02-23 07:15:35 +01:00
Revert "FIX: Replace schema with empty string"
This reverts commit e1fd3952e8
.
This commit is contained in:
parent
e1fd3952e8
commit
3271dc8900
5 changed files with 6 additions and 162 deletions
|
@ -1,149 +0,0 @@
|
|||
import { LegacyWallet } from './legacy-wallet';
|
||||
import Frisbee from 'frisbee';
|
||||
import { BitcoinUnit } from '../models/bitcoinUnits';
|
||||
|
||||
export class ACINQStrikeLightningWallet extends LegacyWallet {
|
||||
static type = 'acinqStrikeLightningWallet';
|
||||
static typeReadable = 'strike';
|
||||
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.setBaseURI(); // no args to init with default value
|
||||
this.init();
|
||||
this.secret = '';
|
||||
this.user_charges_raw = [];
|
||||
this.preferredBalanceUnit = BitcoinUnit.SATS;
|
||||
}
|
||||
|
||||
/**
|
||||
* requires calling init() after setting
|
||||
*
|
||||
* @param URI
|
||||
*/
|
||||
setBaseURI(URI) {
|
||||
if (URI) {
|
||||
this.baseURI = URI;
|
||||
} else {
|
||||
this.baseURI = 'https://api.strike.acinq.co/api/v1';
|
||||
}
|
||||
}
|
||||
|
||||
getBaseURI() {
|
||||
return this.baseURI;
|
||||
}
|
||||
|
||||
allowSend() {
|
||||
return false;
|
||||
}
|
||||
|
||||
timeToRefreshBalance() {
|
||||
// only manual refresh for now
|
||||
return false;
|
||||
}
|
||||
|
||||
timeToRefreshTransaction() {
|
||||
// only manual refresh for now
|
||||
return false;
|
||||
}
|
||||
|
||||
static fromJson(param) {
|
||||
let obj = super.fromJson(param);
|
||||
obj.init();
|
||||
return obj;
|
||||
}
|
||||
|
||||
init() {
|
||||
this._api = new Frisbee({
|
||||
baseURI: this.baseURI,
|
||||
headers: {
|
||||
'cache-control': 'no-cache',
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
setSecret(secret) {
|
||||
this.secret = secret;
|
||||
this._api.auth(this.secret);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns list of LND invoices created by user
|
||||
*
|
||||
* @return {Promise.<Array>}
|
||||
*/
|
||||
async getCharge(chargeId) {
|
||||
let response = await this._api.get('/charges/' + chargeId);
|
||||
let json = response.body;
|
||||
if (typeof json === 'undefined') {
|
||||
throw new Error('API failure: ' + response.err + ' ' + JSON.stringify(response.originalResponse));
|
||||
}
|
||||
|
||||
if (json && json.error) {
|
||||
throw new Error('API error: ' + json.message + ' (code ' + json.code + ')');
|
||||
}
|
||||
|
||||
this.user_charges_raw = json.sort((a, b) => {
|
||||
return a.created - b.created;
|
||||
});
|
||||
|
||||
return this.user_charges_raw;
|
||||
}
|
||||
|
||||
async getUserCharges() {
|
||||
let response = await this._api.get('/charges');
|
||||
let json = response.body;
|
||||
if (typeof json === 'undefined') {
|
||||
throw new Error('API failure: ' + response.err + ' ' + JSON.stringify(response.originalResponse));
|
||||
}
|
||||
|
||||
if (json && json.code && json.code === 401) {
|
||||
throw new Error('API error: ' + json.message + ' (code ' + json.code + ')');
|
||||
}
|
||||
this.user_charges_raw = json.sort((a, b) => {
|
||||
return a.created - b.created;
|
||||
});
|
||||
return this.user_charges_raw;
|
||||
}
|
||||
|
||||
/**
|
||||
* Basically the same as this.getUserInvoices() but saves invoices list
|
||||
* to internal variable
|
||||
*
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
getTransactions() {
|
||||
console.warn('heee');
|
||||
|
||||
return this.user_charges_raw;
|
||||
}
|
||||
|
||||
async authenticate() {
|
||||
await this.getUserCharges();
|
||||
return true;
|
||||
}
|
||||
|
||||
async createCharge(amount, description = 'ACINQ strike Charge') {
|
||||
let response = await this._api.post('/charges', {
|
||||
body: { amount: Number(amount), description: String(description), currency: 'btc' },
|
||||
auth: {
|
||||
user: this.secret,
|
||||
pass: '',
|
||||
},
|
||||
});
|
||||
let json = response.body;
|
||||
if (typeof json === 'undefined') {
|
||||
throw new Error('API failure: ' + response.err + ' ' + JSON.stringify(response.originalResponse));
|
||||
}
|
||||
|
||||
if (json && json.code) {
|
||||
throw new Error('API error: ' + json.message + ' (code ' + json.code + ')');
|
||||
}
|
||||
|
||||
return json;
|
||||
}
|
||||
|
||||
allowReceive() {
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -10,4 +10,3 @@ export * from './hd-legacy-p2pkh-wallet';
|
|||
export * from './watch-only-wallet';
|
||||
export * from './lightning-custodian-wallet';
|
||||
export * from './abstract-hd-wallet';
|
||||
export * from './acinqStrikeLightningWallet';
|
||||
|
|
6
package-lock.json
generated
6
package-lock.json
generated
|
@ -3386,9 +3386,9 @@
|
|||
"integrity": "sha1-6vQ5/U1ISK105cx9vvIAZyueNFs="
|
||||
},
|
||||
"dayjs": {
|
||||
"version": "1.8.2",
|
||||
"resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.8.2.tgz",
|
||||
"integrity": "sha512-iHNxe5kIbxmPgzJFjks9TFMokOu3TQcUUSagb/Ff7GZNi7ulYF0qaAZ61trZEFOONgrp4jvKVpBJ86qy4UsSoA=="
|
||||
"version": "1.8.0",
|
||||
"resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.8.0.tgz",
|
||||
"integrity": "sha512-2ofInmfMKLLR5R02q3WEUuDt86UK33VQQTaEeJudF+C04ZUaekCP3VpB0NJPiyPDCGJWq9XYhHX2AemdxA8+dg=="
|
||||
},
|
||||
"debug": {
|
||||
"version": "4.1.1",
|
||||
|
|
|
@ -45,7 +45,7 @@
|
|||
"buffer": "^5.2.1",
|
||||
"buffer-reverse": "^1.0.1",
|
||||
"crypto-js": "^3.1.9-1",
|
||||
"dayjs": "^1.8.2",
|
||||
"dayjs": "^1.8.0",
|
||||
"electrum-client": "git+https://github.com/Overtorment/node-electrum-client.git",
|
||||
"electrum-host-parse": "^0.1.1",
|
||||
"eslint-config-prettier": "^4.0.0",
|
||||
|
|
|
@ -556,15 +556,9 @@ export default class SendDetails extends Component {
|
|||
} else {
|
||||
try {
|
||||
const { address, amount, memo } = this.decodeBitcoinUri(text);
|
||||
this.setState({
|
||||
address: address.replace('bitcoin:', ''),
|
||||
amount,
|
||||
memo,
|
||||
isLoading: false,
|
||||
bip70TransactionExpiration: null,
|
||||
});
|
||||
this.setState({ address, amount, memo, isLoading: false, bip70TransactionExpiration: null });
|
||||
} catch (_) {
|
||||
this.setState({ address: text.trim().replace('bitcoin:', ''), isLoading: false, bip70TransactionExpiration: null });
|
||||
this.setState({ address: text.trim(), isLoading: false, bip70TransactionExpiration: null });
|
||||
}
|
||||
}
|
||||
}}
|
||||
|
|
Loading…
Add table
Reference in a new issue