@bcpros/crypto-wallet-core
Version:
A multi-currency support library for address derivation, private key creation, and transaction creation
58 lines • 2.48 kB
JavaScript
;
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.DOGETxProvider = void 0;
var btc_1 = require("../btc");
var DOGETxProvider = (function (_super) {
__extends(DOGETxProvider, _super);
function DOGETxProvider() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.lib = require('@bcpros/bitcore-lib-doge');
return _this;
}
DOGETxProvider.prototype.create = function (_a) {
var _this = this;
var recipients = _a.recipients, _b = _a.utxos, utxos = _b === void 0 ? [] : _b, change = _a.change, feeRate = _a.feeRate, _c = _a.fee, fee = _c === void 0 ? 20000 : _c;
var filteredUtxos = this.selectCoins(recipients, utxos, fee);
var btcUtxos = filteredUtxos.map(function (utxo) {
var btcUtxo = Object.assign({}, utxo, {
amount: utxo.value / 1e8,
txid: utxo.mintTxid,
outputIndex: utxo.mintIndex
});
return new _this.lib.Transaction.UnspentOutput(btcUtxo);
});
var tx = new this.lib.Transaction().from(btcUtxos);
if (fee) {
tx.fee(fee);
}
if (feeRate) {
tx.feePerKb(Number(feeRate) * 1000);
}
if (change) {
tx.change(change);
}
for (var _i = 0, recipients_1 = recipients; _i < recipients_1.length; _i++) {
var recipient = recipients_1[_i];
tx.to(recipient.address, parseInt(recipient.amount));
}
return tx.uncheckedSerialize();
};
return DOGETxProvider;
}(btc_1.BTCTxProvider));
exports.DOGETxProvider = DOGETxProvider;
//# sourceMappingURL=index.js.map