blockchain-wallet-ts
Version:
TypeScript wrapper for Blockchain.info's wallet API
62 lines (61 loc) • 1.64 kB
JavaScript
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const ApiClient_1 = __importDefault(require("./Providers/ApiClient"));
class BlockchainHDWallet extends ApiClient_1.default {
/**
* Blockchain HD Wallet constructor.
*/
constructor(config) {
super(config);
this.xpub = config.xpub;
this.index = config.index;
this.guid = config.guid;
this.password = config.password;
}
/**
* API path root.
*/
get basePath() {
return `/merchant/${this.guid}/accounts/${this.xpub}`;
}
/**
* Parameters to be included in every API request.
*/
get baseParams() {
return { password: this.password };
}
/**
* Wallet metadata.
*/
get data() {
return this.request('');
}
/**
* Fetch balance for current wallet.
*/
get balance() {
return this.request(`/balance`);
}
/**
* Fetch receiving Bitcoin address for current wallet.
*/
get receivingAddress() {
return this.request('/receiveAddress');
}
/**
* Archive the current address/account.
*/
archive() {
return this.request('/archive');
}
/**
* Remove the current address/account from the archive, making it active again.
*/
unarchive() {
return this.request('/unarchive');
}
}
exports.default = BlockchainHDWallet;