crypto-wallet-core
Version:
A multi-currency support library for address derivation, private key creation, and transaction creation
31 lines (29 loc) • 934 B
text/typescript
import { BTCTxProvider } from '../btc';
export class DOGETxProvider extends BTCTxProvider {
lib = require('bitcore-lib-doge');
create({ recipients, utxos = [], change, feeRate, fee = 20000 }) {
const filteredUtxos = this.selectCoins(recipients, utxos, fee);
const btcUtxos = filteredUtxos.map(utxo => {
const btcUtxo = Object.assign({}, utxo, {
amount: utxo.value / 1e8,
txid: utxo.mintTxid,
outputIndex: utxo.mintIndex
});
return new this.lib.Transaction.UnspentOutput(btcUtxo);
});
let tx = new this.lib.Transaction().from(btcUtxos);
if (fee) {
tx.fee(fee);
}
if (feeRate) {
tx.feePerKb(Number(feeRate) * 1000); // feeRate is in feePerByte
}
if (change) {
tx.change(change);
}
for (const recipient of recipients) {
tx.to(recipient.address, parseInt(recipient.amount));
}
return tx.uncheckedSerialize();
}
}