@bcpros/crypto-wallet-core
Version:
A multi-currency support library for address derivation, private key creation, and transaction creation
28 lines • 1.09 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.XECTxProvider = void 0;
const btc_1 = require("../btc");
class XECTxProvider extends btc_1.BTCTxProvider {
lib = require('@bcpros/bitcore-lib-xec');
create({ recipients, utxos = [], change, fee = 20000 }) {
const filteredUtxos = this.selectCoins(recipients, utxos, fee);
const btcUtxos = filteredUtxos.map(utxo => {
const btcUtxo = Object.assign({}, utxo, {
amount: utxo.value / 1e3,
txid: utxo.mintTxid,
outputIndex: utxo.mintIndex
});
return new this.lib.Transaction.UnspentOutput(btcUtxo);
});
let tx = new this.lib.Transaction().from(btcUtxos).feePerByte(Number(fee) + 2);
if (change) {
tx.change(change);
}
for (const recipient of recipients) {
tx.to(recipient.address, parseInt(recipient.amount));
}
return tx.uncheckedSerialize();
}
}
exports.XECTxProvider = XECTxProvider;
//# sourceMappingURL=index.js.map