@ducatus/ducatus-wallet-service-rev
Version:
A service for Mutisig HD Bitcoin Wallets
108 lines • 4.54 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var bch_1 = require("./bch");
var btc_1 = require("./btc");
var duc_1 = require("./duc");
var ducx_1 = require("./ducx");
var eth_1 = require("./eth");
var xrp_1 = require("./xrp");
var Common = require('../common');
var Constants = Common.Constants;
var chain = {
BTC: new btc_1.BtcChain(),
BCH: new bch_1.BchChain(),
ETH: new eth_1.EthChain(),
XRP: new xrp_1.XrpChain(),
DUC: new duc_1.DucChain(),
DUCX: new ducx_1.DucXChain()
};
var ChainProxy = (function () {
function ChainProxy() {
}
ChainProxy.prototype.get = function (coin) {
var normalizedChain = this.getChain(coin);
return chain[normalizedChain];
};
ChainProxy.prototype.getChain = function (coin) {
var normalizedChain = coin.toUpperCase();
if (Constants.ERC20[normalizedChain]) {
normalizedChain = 'ETH';
}
if (Constants.DRC20[normalizedChain]) {
normalizedChain = 'DUCX';
}
return normalizedChain;
};
ChainProxy.prototype.getWalletBalance = function (server, wallet, opts, cb) {
return this.get(wallet.coin).getWalletBalance(server, wallet, opts, cb);
};
ChainProxy.prototype.getWalletSendMaxInfo = function (server, wallet, opts, cb) {
return this.get(wallet.coin).getWalletSendMaxInfo(server, wallet, opts, cb);
};
ChainProxy.prototype.getDustAmountValue = function (coin) {
return this.get(coin).getDustAmountValue();
};
ChainProxy.prototype.getTransactionCount = function (server, wallet, from) {
return this.get(wallet.coin).getTransactionCount(server, wallet, from);
};
ChainProxy.prototype.getChangeAddress = function (server, wallet, opts) {
return this.get(wallet.coin).getChangeAddress(server, wallet, opts);
};
ChainProxy.prototype.checkDust = function (coin, output, opts) {
return this.get(coin).checkDust(output, opts);
};
ChainProxy.prototype.getFee = function (server, wallet, opts) {
return this.get(wallet.coin).getFee(server, wallet, opts);
};
ChainProxy.prototype.buildTx = function (txp) {
return this.get(txp.coin).buildTx(txp);
};
ChainProxy.prototype.convertFeePerKb = function (coin, p, feePerKb) {
return this.get(coin).convertFeePerKb(p, feePerKb);
};
ChainProxy.prototype.addressToStorageTransform = function (coin, network, address) {
return this.get(coin).addressToStorageTransform(network, address);
};
ChainProxy.prototype.addressFromStorageTransform = function (coin, network, address) {
return this.get(coin).addressFromStorageTransform(network, address);
};
ChainProxy.prototype.checkTx = function (server, txp) {
return this.get(txp.coin).checkTx(server, txp);
};
ChainProxy.prototype.checkTxUTXOs = function (server, txp, opts, cb) {
return this.get(txp.coin).checkTxUTXOs(server, txp, opts, cb);
};
ChainProxy.prototype.selectTxInputs = function (server, txp, wallet, opts, cb, next) {
return this.get(txp.coin).selectTxInputs(server, txp, wallet, opts, cb, next);
};
ChainProxy.prototype.checkUtxos = function (coin, opts) {
return this.get(coin).checkUtxos(opts);
};
ChainProxy.prototype.checkValidTxAmount = function (coin, output) {
return this.get(coin).checkValidTxAmount(output);
};
ChainProxy.prototype.setInputs = function (coin, info) {
return this.get(coin).setInputs(info);
};
ChainProxy.prototype.isUTXOCoin = function (coin) {
return this.get(coin).isUTXOCoin();
};
ChainProxy.prototype.isSingleAddress = function (coin) {
return this.get(coin).isSingleAddress();
};
ChainProxy.prototype.notifyConfirmations = function (coin, network) {
return this.get(coin).notifyConfirmations(network);
};
ChainProxy.prototype.supportsMultisig = function (coin) {
return this.get(coin).supportsMultisig();
};
ChainProxy.prototype.addSignaturesToBitcoreTx = function (coin, tx, inputs, inputPaths, signatures, xpub) {
return this.get(coin).addSignaturesToBitcoreTx(tx, inputs, inputPaths, signatures, xpub);
};
ChainProxy.prototype.validateAddress = function (wallet, inaddr, opts) {
return this.get(wallet.coin).validateAddress(wallet, inaddr, opts);
};
return ChainProxy;
}());
exports.ChainService = new ChainProxy();
//# sourceMappingURL=index.js.map