2018-03-20 21:41:07 +01:00
|
|
|
export class AbstractWallet {
|
|
|
|
constructor() {
|
|
|
|
this.type = 'abstract';
|
|
|
|
this.label = '';
|
|
|
|
this.secret = ''; // private key or recovery phrase
|
|
|
|
this.balance = 0;
|
2018-07-05 02:56:31 +02:00
|
|
|
this.unconfirmed_balance = 0;
|
2018-03-20 21:41:07 +01:00
|
|
|
this.transactions = [];
|
|
|
|
this._address = false; // cache
|
|
|
|
this.utxo = [];
|
2018-07-28 22:19:11 +02:00
|
|
|
this._lastTxFetch = 0;
|
|
|
|
this._lastBalanceFetch = 0;
|
2018-03-20 21:41:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
getTransactions() {
|
|
|
|
return this.transactions;
|
|
|
|
}
|
|
|
|
|
|
|
|
getTypeReadable() {
|
|
|
|
return this.type;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @returns {string}
|
|
|
|
*/
|
|
|
|
getLabel() {
|
|
|
|
return this.label;
|
|
|
|
}
|
|
|
|
|
|
|
|
getBalance() {
|
|
|
|
return this.balance;
|
|
|
|
}
|
|
|
|
|
2018-07-07 13:30:50 +02:00
|
|
|
allowReceive() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
allowSend() {
|
2018-10-06 02:45:24 +02:00
|
|
|
return true;
|
2018-07-07 13:30:50 +02:00
|
|
|
}
|
|
|
|
|
2018-07-05 02:56:31 +02:00
|
|
|
/**
|
|
|
|
* Returns delta of unconfirmed balance. For example, if theres no
|
|
|
|
* unconfirmed balance its 0
|
|
|
|
*
|
|
|
|
* @return {number}
|
|
|
|
*/
|
|
|
|
getUnconfirmedBalance() {
|
|
|
|
return this.unconfirmed_balance;
|
|
|
|
}
|
|
|
|
|
2018-03-20 21:41:07 +01:00
|
|
|
setLabel(newLabel) {
|
|
|
|
this.label = newLabel;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
getSecret() {
|
|
|
|
return this.secret;
|
|
|
|
}
|
|
|
|
|
|
|
|
setSecret(newSecret) {
|
2018-07-21 14:52:54 +02:00
|
|
|
this.secret = newSecret.trim();
|
2018-03-20 21:41:07 +01:00
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2018-06-25 00:22:46 +02:00
|
|
|
getLatestTransactionTime() {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-03-20 21:41:07 +01:00
|
|
|
static fromJson(obj) {
|
|
|
|
let obj2 = JSON.parse(obj);
|
|
|
|
let temp = new this();
|
|
|
|
for (let key2 of Object.keys(obj2)) {
|
|
|
|
temp[key2] = obj2[key2];
|
|
|
|
}
|
|
|
|
|
|
|
|
return temp;
|
|
|
|
}
|
|
|
|
|
|
|
|
getAddress() {}
|
|
|
|
|
|
|
|
// createTx () { throw Error('not implemented') }
|
|
|
|
}
|