Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@trezor/utxo-lib

Package Overview
Dependencies
Maintainers
6
Versions
45
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@trezor/utxo-lib - npm Package Compare versions

Comparing version 1.0.10 to 1.0.11

11

CHANGELOG.md

@@ -0,1 +1,12 @@

# 1.0.11
- test(utxo-lib): zip-317 (140018dde)
- feat(utxo-lib): zip-317 (93ef15656)
- test(utxo-lib): add fee policies (725c2c32f)
- chore(utxo-lib): add fee policies (1e4435098)
- refactor(utxo-lib): reworked getFee params (65cb7f6ce)
- chore: replace deprecated String.subst with Sting.substing (57f45d4cd)
- chore: replace deprecated Buffer.slice with Buffer.subarray (814caeaa9)
- chore: use `getChunkSize` from @trezor/utils package (a6fb8ea98)
# 1.0.10

@@ -2,0 +13,0 @@

2

lib/address.js

@@ -59,3 +59,3 @@ "use strict";

function toFutureSegwitAddress(output, network = networks_1.bitcoin) {
const data = output.slice(2);
const data = output.subarray(2);
if (data.length < FUTURE_SEGWIT_MIN_SIZE || data.length > FUTURE_SEGWIT_MAX_SIZE)

@@ -62,0 +62,0 @@ throw new TypeError('Invalid program length for segwit address');

@@ -81,3 +81,3 @@ "use strict";

get fingerprint() {
return this.identifier.slice(0, 4);
return this.identifier.subarray(0, 4);
}

@@ -132,4 +132,4 @@ get compressed() {

const I = crypto.hmacSHA512(this.chainCode, data);
const IL = I.slice(0, 32);
const IR = I.slice(32);
const IL = I.subarray(0, 32);
const IR = I.subarray(32);
if (!ecc.isPrivate(IL))

@@ -215,3 +215,3 @@ return this.derive(index + 1);

throw new TypeError('Invalid index');
const chainCode = buffer.slice(13, 45);
const chainCode = buffer.subarray(13, 45);
let hd;

@@ -221,7 +221,7 @@ if (version === network.bip32.private) {

throw new TypeError('Invalid private key');
const k = buffer.slice(46, 78);
const k = buffer.subarray(46, 78);
hd = fromPrivateKeyLocal(k, chainCode, network, depth, index, parentFingerprint);
}
else {
const X = buffer.slice(45, 78);
const X = buffer.subarray(45, 78);
hd = fromPublicKeyLocal(X, chainCode, network, depth, index, parentFingerprint);

@@ -248,4 +248,4 @@ }

const I = crypto.hmacSHA512(Buffer.from('Bitcoin seed', 'utf8'), seed);
const IL = I.slice(0, 32);
const IR = I.slice(32);
const IL = I.subarray(0, 32);
const IR = I.subarray(32);
return fromPrivateKey(IL, IR, network);

@@ -252,0 +252,0 @@ }

@@ -10,5 +10,5 @@ "use strict";

function decodeBlake(buffer) {
const want = buffer.slice(-4);
const payload = buffer.slice(0, -4);
const got = (0, crypto_1.blake256)((0, crypto_1.blake256)(payload)).slice(0, 4);
const want = buffer.subarray(-4);
const payload = buffer.subarray(0, -4);
const got = (0, crypto_1.blake256)((0, crypto_1.blake256)(payload)).subarray(0, 4);
if ((want[0] ^ got[0]) | (want[1] ^ got[1]) | (want[2] ^ got[2]) | (want[3] ^ got[3]))

@@ -44,3 +44,3 @@ throw new Error('invalid checksum');

function encodeBlake256(payload) {
const checksum = (0, crypto_1.blake256)((0, crypto_1.blake256)(payload)).slice(0, 4);
const checksum = (0, crypto_1.blake256)((0, crypto_1.blake256)(payload)).subarray(0, 4);
return bs58.encode(Buffer.concat([payload, checksum]));

@@ -74,3 +74,3 @@ }

const version = multibyte ? payload.readUInt16BE(0) : payload[0];
const hash = payload.slice(offset);
const hash = payload.subarray(offset);
return { version, hash };

@@ -77,0 +77,0 @@ }

@@ -16,3 +16,2 @@ /// <reference types="node" />

export declare function cloneBuffer(buffer: Buffer): Buffer;
export declare function getChunkSize(n: number): Buffer;
type PushDataSize = (len: number) => number;

@@ -29,3 +28,3 @@ type ReadPushDataInt = (buffer: Buffer, offset: number) => {

export declare const writePushDataInt: WritePushDataInt;
export declare const reverseBuffer: (src: Buffer) => Buffer;
export declare const reverseBuffer: (src: Buffer) => Buffer, getChunkSize: (n: number) => Buffer;
export declare class BufferWriter {

@@ -32,0 +31,0 @@ buffer: Buffer;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.BufferReader = exports.BufferWriter = exports.reverseBuffer = exports.writePushDataInt = exports.varIntSize = exports.readPushDataInt = exports.pushDataSize = exports.getChunkSize = exports.cloneBuffer = exports.writeVarInt = exports.readVarInt = exports.writeInt64LE = exports.writeUInt64LEasString = exports.writeUInt64LE = exports.readInt64LE = exports.readUInt64LEasString = exports.readUInt64LE = exports.verifuint = void 0;
exports.BufferReader = exports.BufferWriter = exports.getChunkSize = exports.reverseBuffer = exports.writePushDataInt = exports.varIntSize = exports.readPushDataInt = exports.pushDataSize = exports.cloneBuffer = exports.writeVarInt = exports.readVarInt = exports.writeInt64LE = exports.writeUInt64LEasString = exports.writeUInt64LE = exports.readInt64LE = exports.readUInt64LEasString = exports.readUInt64LE = exports.verifuint = void 0;
const BN = require("bn.js");

@@ -96,8 +96,2 @@ const pushdata = require("pushdata-bitcoin");

exports.cloneBuffer = cloneBuffer;
function getChunkSize(n) {
const buf = Buffer.allocUnsafe(1);
buf.writeUInt8(n);
return buf;
}
exports.getChunkSize = getChunkSize;
exports.pushDataSize = pushdata.encodingLength;

@@ -107,3 +101,3 @@ exports.readPushDataInt = pushdata.decode;

exports.writePushDataInt = pushdata.encode;
exports.reverseBuffer = utils_1.bufferUtils.reverseBuffer;
exports.reverseBuffer = utils_1.bufferUtils.reverseBuffer, exports.getChunkSize = utils_1.bufferUtils.getChunkSize;
class BufferWriter {

@@ -206,3 +200,3 @@ constructor(buffer, offset = 0) {

}
const result = this.buffer.slice(this.offset, this.offset + n);
const result = this.buffer.subarray(this.offset, this.offset + n);
this.offset += n;

@@ -209,0 +203,0 @@ return result;

import * as BN from 'bn.js';
import { CoinSelectPaymentType, CoinSelectAlgorithm, CoinSelectOptions, CoinSelectInput, CoinSelectOutput, CoinSelectOutputFinal } from '../types';
import { Network } from '../networks';
export declare const ZERO: BN;

@@ -36,3 +37,4 @@ export declare const INPUT_SCRIPT_LENGTH: Record<CoinSelectPaymentType, number>;

}[], forgiving: F): F extends true ? BN : BN | undefined;
export declare function getFee(feeRate: number, bytes: number, options: Partial<CoinSelectOptions>, outputs: CoinSelectOutput[]): number;
export declare function getFeePolicy(network?: Network): "bitcoin" | "doge" | "zcash";
export declare function getFee(inputs: CoinSelectInput[], outputs: CoinSelectOutput[], feeRate: number, { feePolicy, ...options }?: Partial<CoinSelectOptions>): number;
export declare function finalize(inputs: CoinSelectInput[], outputs: CoinSelectOutput[], feeRate: number, options: CoinSelectOptions): {

@@ -39,0 +41,0 @@ fee: number;

"use strict";
var __rest = (this && this.__rest) || function (s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
t[p[i]] = s[p[i]];
}
return t;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.filterCoinbase = exports.sortByScore = exports.utxoScore = exports.anyOf = exports.finalize = exports.getFee = exports.sumOrNaN = exports.bignumberOrNaN = exports.getDustAmount = exports.transactionBytes = exports.transactionWeight = exports.getFeeForBytes = exports.outputBytes = exports.outputWeight = exports.inputBytes = exports.inputWeight = exports.getVarIntSize = exports.OUTPUT_SCRIPT_LENGTH = exports.INPUT_SCRIPT_LENGTH = exports.ZERO = void 0;
exports.filterCoinbase = exports.sortByScore = exports.utxoScore = exports.anyOf = exports.finalize = exports.getFee = exports.getFeePolicy = exports.sumOrNaN = exports.bignumberOrNaN = exports.getDustAmount = exports.transactionBytes = exports.transactionWeight = exports.getFeeForBytes = exports.outputBytes = exports.outputWeight = exports.inputBytes = exports.inputWeight = exports.getVarIntSize = exports.OUTPUT_SCRIPT_LENGTH = exports.INPUT_SCRIPT_LENGTH = exports.ZERO = void 0;
const BN = require("bn.js");
const networks_1 = require("../networks");
exports.ZERO = new BN(0);

@@ -122,31 +134,53 @@ exports.INPUT_SCRIPT_LENGTH = {

exports.sumOrNaN = sumOrNaN;
function getFee(feeRate, bytes, options, outputs) {
function getFeePolicy(network) {
if ((0, networks_1.isNetworkType)('doge', network))
return 'doge';
if ((0, networks_1.isNetworkType)('zcash', network))
return 'zcash';
return 'bitcoin';
}
exports.getFeePolicy = getFeePolicy;
function getBitcoinFee(inputs, outputs, feeRate, { baseFee = 0, floorBaseFee }) {
const bytes = transactionBytes(inputs, outputs);
const defaultFee = getFeeForBytes(feeRate, bytes);
let baseFee = options.baseFee || 0;
if (baseFee && bytes) {
if (options.floorBaseFee) {
baseFee *= Math.floor((baseFee + defaultFee) / baseFee);
}
else {
baseFee += defaultFee;
}
return baseFee && floorBaseFee
?
baseFee * (1 + Math.floor(defaultFee / baseFee))
:
baseFee + defaultFee;
}
function getDogeFee(inputs, outputs, feeRate, _a) {
var { dustThreshold = 0 } = _a, options = __rest(_a, ["dustThreshold"]);
const fee = getBitcoinFee(inputs, outputs, feeRate, options);
const limit = new BN(dustThreshold);
const dustOutputsCount = outputs.filter(({ value }) => value && new BN(value).lt(limit)).length;
return fee + dustOutputsCount * dustThreshold;
}
const MARGINAL_FEE_ZAT_PER_ACTION = 5000;
const GRACE_ACTIONS = 2;
const P2PKH_STANDARD_INPUT_SIZE = 150;
const P2PKH_STANDARD_OUTPUT_SIZE = 34;
function getZcashFee(inputs, outputs, feeRate, options) {
const fee = getBitcoinFee(inputs, outputs, feeRate, options);
const txInTotalBytes = inputs.reduce((sum, i) => sum + inputBytes(i), 0);
const txOutTotalBytes = outputs.reduce((sum, o) => sum + outputBytes(o), 0);
const actions = Math.max(GRACE_ACTIONS, Math.ceil(txInTotalBytes / P2PKH_STANDARD_INPUT_SIZE), Math.ceil(txOutTotalBytes / P2PKH_STANDARD_OUTPUT_SIZE));
return Math.max(actions * MARGINAL_FEE_ZAT_PER_ACTION, fee);
}
function getFee(inputs, outputs, feeRate, _a = {}) {
var { feePolicy } = _a, options = __rest(_a, ["feePolicy"]);
switch (feePolicy) {
case 'doge':
return getDogeFee(inputs, outputs, feeRate, options);
case 'zcash':
return getZcashFee(inputs, outputs, feeRate, options);
default:
return getBitcoinFee(inputs, outputs, feeRate, options);
}
if (options.dustOutputFee && options.dustThreshold) {
for (let i = 0; i < outputs.length; i++) {
const { value } = outputs[i];
if (value && new BN(value).sub(new BN(options.dustThreshold)).isNeg()) {
baseFee += options.dustOutputFee;
}
}
}
return baseFee || defaultFee;
}
exports.getFee = getFee;
function finalize(inputs, outputs, feeRate, options) {
const bytesAccum = transactionBytes(inputs, outputs);
const blankOutputBytes = outputBytes({
script: { length: exports.OUTPUT_SCRIPT_LENGTH[options.txType] },
});
const fee = getFee(feeRate, bytesAccum, options, outputs);
const feeAfterExtraOutput = getFee(feeRate, bytesAccum + blankOutputBytes, options, outputs);
const blankOutput = { script: { length: exports.OUTPUT_SCRIPT_LENGTH[options.txType] } };
const fee = getFee(inputs, outputs, feeRate, options);
const feeAfterExtraOutput = getFee(inputs, [...outputs, blankOutput], feeRate, options);
const sumInputs = sumOrNaN(inputs);

@@ -153,0 +187,0 @@ const sumOutputs = sumOrNaN(outputs);

@@ -7,3 +7,2 @@ "use strict";

function accumulative(utxos0, outputs, feeRate, options) {
let bytesAccum = (0, coinselectUtils_1.transactionBytes)([], outputs);
let inAccum = coinselectUtils_1.ZERO;

@@ -17,5 +16,3 @@ const inputs = [];

requiredUtxos.push(u);
const utxoBytes = (0, coinselectUtils_1.inputBytes)(u);
const utxoValue = (0, coinselectUtils_1.bignumberOrNaN)(u.value, true);
bytesAccum += utxoBytes;
inAccum = inAccum.add(utxoValue);

@@ -41,3 +38,3 @@ inputs.push(u);

if (i === utxos.length - 1) {
const fee = (0, coinselectUtils_1.getFee)(feeRate, bytesAccum + utxoBytes, options, outputs);
const fee = (0, coinselectUtils_1.getFee)([...inputs, utxo], outputs, feeRate, options);
return { fee };

@@ -47,6 +44,5 @@ }

else {
bytesAccum += utxoBytes;
inAccum = inAccum.add(utxoValue);
inputs.push(utxo);
const fee = (0, coinselectUtils_1.getFee)(feeRate, bytesAccum, options, outputs);
const fee = (0, coinselectUtils_1.getFee)(inputs, outputs, feeRate, options);
const outAccumWithFee = outAccum ? outAccum.add(new BN(fee)) : coinselectUtils_1.ZERO;

@@ -58,3 +54,3 @@ if (inAccum.gte(outAccumWithFee)) {

}
const fee = (0, coinselectUtils_1.getFee)(feeRate, bytesAccum, options, outputs);
const fee = (0, coinselectUtils_1.getFee)(inputs, outputs, feeRate, options);
return { fee };

@@ -61,0 +57,0 @@ }

@@ -9,4 +9,3 @@ "use strict";

const utxos = (0, coinselectUtils_1.filterCoinbase)(utxosOrig, coinbase);
const bytesAccum = (0, coinselectUtils_1.transactionBytes)(utxos, outputs);
const fee = (0, coinselectUtils_1.getFee)(feeRate, bytesAccum, options, outputs);
const fee = (0, coinselectUtils_1.getFee)(utxos, outputs, feeRate, options);
if (outputs.length === 0)

@@ -13,0 +12,0 @@ return { fee };

import { ComposeInput, ComposeOutput, CoinSelectPaymentType, CoinSelectSuccess, CoinSelectFailure } from '../types';
import type { Network } from '../networks';
export declare function coinselect(txType: CoinSelectPaymentType, utxos: ComposeInput[], rOutputs: ComposeOutput[], height: number, feeRate: number, longTermFeeRate: number | undefined, countMax: boolean, countMaxId: number, dustThreshold: number, network: Network, baseFee?: number, floorBaseFee?: boolean, dustOutputFee?: number, skipPermutation?: boolean): CoinSelectSuccess | CoinSelectFailure;
export declare function coinselect(txType: CoinSelectPaymentType, utxos: ComposeInput[], rOutputs: ComposeOutput[], height: number, feeRate: number, longTermFeeRate: number | undefined, countMax: boolean, countMaxId: number, dustThreshold: number, network: Network, baseFee?: number, floorBaseFee?: boolean, skipPermutation?: boolean): CoinSelectSuccess | CoinSelectFailure;
//# sourceMappingURL=coinselect.d.ts.map

@@ -9,5 +9,6 @@ "use strict";

const composeUtils_1 = require("./composeUtils");
function coinselect(txType, utxos, rOutputs, height, feeRate, longTermFeeRate, countMax, countMaxId, dustThreshold, network, baseFee, floorBaseFee, dustOutputFee, skipPermutation) {
function coinselect(txType, utxos, rOutputs, height, feeRate, longTermFeeRate, countMax, countMaxId, dustThreshold, network, baseFee, floorBaseFee, skipPermutation) {
const inputs0 = (0, composeUtils_1.convertInputs)(utxos, height, txType);
const outputs0 = (0, composeUtils_1.convertOutputs)(rOutputs, network, txType);
const feePolicy = (0, coinselectUtils_1.getFeePolicy)(network);
const options = {

@@ -19,4 +20,4 @@ txType,

floorBaseFee,
dustOutputFee,
skipPermutation,
feePolicy,
};

@@ -23,0 +24,0 @@ const algorithm = countMax ? split_1.split : coinselect_1.coinselect;

import { ComposeRequest, ComposeResult } from '../types';
export declare function composeTx({ txType, utxos, outputs, height, feeRate, longTermFeeRate, basePath, network, changeId, changeAddress, dustThreshold, baseFee, floorBaseFee, dustOutputFee, skipPermutation, }: ComposeRequest): ComposeResult;
export declare function composeTx({ txType, utxos, outputs, height, feeRate, longTermFeeRate, basePath, network, changeId, changeAddress, dustThreshold, baseFee, floorBaseFee, skipPermutation, }: ComposeRequest): ComposeResult;
//# sourceMappingURL=index.d.ts.map

@@ -9,3 +9,3 @@ "use strict";

const coinselect_1 = require("./coinselect");
function composeTx({ txType, utxos, outputs, height, feeRate, longTermFeeRate, basePath, network, changeId, changeAddress, dustThreshold, baseFee, floorBaseFee, dustOutputFee, skipPermutation, }) {
function composeTx({ txType, utxos, outputs, height, feeRate, longTermFeeRate, basePath, network, changeId, changeAddress, dustThreshold, baseFee, floorBaseFee, skipPermutation, }) {
if (outputs.length === 0) {

@@ -41,3 +41,3 @@ return result.empty;

try {
csResult = (0, coinselect_1.coinselect)(txType || 'p2pkh', utxos, outputs, height, feeRateNumber, longTermFeeRateNumber, countMax.exists, countMax.id, dustThreshold, network, baseFee, floorBaseFee, dustOutputFee, skipPermutation);
csResult = (0, coinselect_1.coinselect)(txType || 'p2pkh', utxos, outputs, height, feeRateNumber, longTermFeeRateNumber, countMax.exists, countMax.id, dustThreshold, network, baseFee, floorBaseFee, skipPermutation);
}

@@ -44,0 +44,0 @@ catch (e) {

@@ -32,13 +32,3 @@ export interface Bip32 {

export declare const decredSim: Network;
export declare const doge: {
messagePrefix: string;
bech32: string;
bip32: {
public: number;
private: number;
};
pubKeyHash: number;
scriptHash: number;
wif: number;
};
export declare const doge: Network;
declare const NETWORK_TYPES: {

@@ -51,2 +41,3 @@ bitcoinCash: Network[];

litecoin: Network[];
doge: Network[];
};

@@ -53,0 +44,0 @@ export type NetworkTypes = keyof typeof NETWORK_TYPES;

@@ -224,2 +224,3 @@ "use strict";

litecoin: [exports.litecoin, exports.litecoinTest],
doge: [exports.doge],
};

@@ -226,0 +227,0 @@ function isNetworkType(type, network) {

@@ -32,3 +32,3 @@ "use strict";

return;
return a.output.slice(1, -1);
return a.output.subarray(1, -1);
});

@@ -35,0 +35,0 @@ lazy.prop(o, 'signature', () => {

@@ -36,3 +36,3 @@ "use strict";

if (a.output)
return a.output.slice(3, 23);
return a.output.subarray(3, 23);
if (a.address)

@@ -100,3 +100,3 @@ return _address().hash;

throw new TypeError('Output is invalid');
const hash2 = a.output.slice(3, 23);
const hash2 = a.output.subarray(3, 23);
if (hash.length > 0 && !hash.equals(hash2))

@@ -103,0 +103,0 @@ throw new TypeError('Hash mismatch');

@@ -57,3 +57,3 @@ "use strict";

if (a.output)
return a.output.slice(2, 22);
return a.output.subarray(2, 22);
if (a.address)

@@ -113,3 +113,3 @@ return _address().hash;

throw new TypeError('Output is invalid');
const hash2 = a.output.slice(2, 22);
const hash2 = a.output.subarray(2, 22);
if (hash.length > 0 && !hash.equals(hash2))

@@ -116,0 +116,0 @@ throw new TypeError('Hash mismatch');

@@ -38,3 +38,3 @@ "use strict";

const offset = pubkey.length === 33 ? 1 : 0;
return pubkey.slice(offset);
return pubkey.subarray(offset);
};

@@ -72,3 +72,3 @@ function p2tr(a, opts) {

if (a.output)
return a.output.slice(2);
return a.output.subarray(2);
if (a.address)

@@ -106,3 +106,3 @@ return _address().data;

throw new TypeError('p2tr output is invalid');
const hash2 = a.output.slice(2);
const hash2 = a.output.subarray(2);
if (hash.length > 0 && !hash.equals(hash2))

@@ -109,0 +109,0 @@ throw new TypeError('Hash mismatch');

@@ -48,3 +48,3 @@ "use strict";

if (a.output)
return a.output.slice(2, 22);
return a.output.subarray(2, 22);
if (a.address)

@@ -105,6 +105,6 @@ return _address().data;

throw new TypeError('Output is invalid');
if (hash.length > 0 && !hash.equals(a.output.slice(2)))
if (hash.length > 0 && !hash.equals(a.output.subarray(2)))
throw new TypeError('Hash mismatch');
else
hash = a.output.slice(2);
hash = a.output.subarray(2);
}

@@ -111,0 +111,0 @@ if (a.pubkey) {

@@ -67,3 +67,3 @@ "use strict";

if (a.output)
return a.output.slice(2);
return a.output.subarray(2);
if (a.address)

@@ -139,3 +139,3 @@ return _address().data;

throw new TypeError('Output is invalid');
const hash2 = a.output.slice(2);
const hash2 = a.output.subarray(2);
if (hash.length > 0 && !hash.equals(hash2))

@@ -142,0 +142,0 @@ throw new TypeError('Hash mismatch');

@@ -30,3 +30,3 @@ "use strict";

if (a.output)
return a.output.slice(4, 24);
return a.output.subarray(4, 24);
if (a.address)

@@ -72,3 +72,3 @@ return _address().hash;

throw new TypeError('sstxchange output is invalid');
const hash2 = a.output.slice(4, 24);
const hash2 = a.output.subarray(4, 24);
if (hash.length > 0 && !hash.equals(hash2))

@@ -75,0 +75,0 @@ throw new TypeError('Hash mismatch');

@@ -32,3 +32,3 @@ "use strict";

if (a.output)
return a.output.slice(2, 22);
return a.output.subarray(2, 22);
if (a.address)

@@ -67,3 +67,3 @@ return _address().hash;

throw new TypeError('sstxcommitment output is invalid');
const hash2 = a.output.slice(2, 22);
const hash2 = a.output.subarray(2, 22);
if (hash.length > 0 && !hash.equals(hash2))

@@ -70,0 +70,0 @@ throw new TypeError('Hash mismatch');

@@ -30,3 +30,3 @@ "use strict";

if (a.output)
return a.output.slice(4, 24);
return a.output.subarray(4, 24);
if (a.address)

@@ -72,3 +72,3 @@ return _address().hash;

throw new TypeError('sstxpkh output is invalid');
const hash2 = a.output.slice(4, 24);
const hash2 = a.output.subarray(4, 24);
if (hash.length > 0 && !hash.equals(hash2))

@@ -75,0 +75,0 @@ throw new TypeError('Hash mismatch');

@@ -30,3 +30,3 @@ "use strict";

if (a.output)
return a.output.slice(3, 23);
return a.output.subarray(3, 23);
if (a.address)

@@ -63,3 +63,3 @@ return _address().hash;

throw new TypeError('sstxsh output is invalid');
const hash2 = a.output.slice(3, 23);
const hash2 = a.output.subarray(3, 23);
if (hash.length > 0 && !hash.equals(hash2))

@@ -66,0 +66,0 @@ throw new TypeError('Hash mismatch');

@@ -88,3 +88,3 @@ "use strict";

return [];
const data = buffer.slice(i, i + d.number);
const data = buffer.subarray(i, i + d.number);
i += d.number;

@@ -160,3 +160,3 @@ const op = asMinimalOP(data);

return false;
return bip66.check(buffer.slice(0, -1));
return bip66.check(buffer.subarray(0, -1));
}

@@ -163,0 +163,0 @@ exports.isCanonicalScriptSignature = isCanonicalScriptSignature;

@@ -14,3 +14,3 @@ "use strict";

return ZERO;
x = x.slice(i);
x = x.subarray(i);
if (x[0] & 0x80)

@@ -23,3 +23,3 @@ return Buffer.concat([ZERO, x], 1 + x.length);

if (x[0] === 0x00)
x = x.slice(1);
x = x.subarray(1);
const buffer = Buffer.alloc(32, 0);

@@ -36,3 +36,3 @@ const bstart = Math.max(0, 32 - x.length);

throw new Error(`Invalid hashType ${hashType}`);
const decoded = bip66.decode(buffer.slice(0, -1));
const decoded = bip66.decode(buffer.subarray(0, -1));
const r = fromDER(decoded.r);

@@ -54,4 +54,4 @@ const s = fromDER(decoded.s);

hashTypeBuffer.writeUInt8(hashType, 0);
const r = toDER(signature.slice(0, 32));
const s = toDER(signature.slice(32, 64));
const r = toDER(signature.subarray(0, 32));
const s = toDER(signature.subarray(32, 64));
return Buffer.concat([bip66.encode(r, s), hashTypeBuffer]);

@@ -58,0 +58,0 @@ }

@@ -47,3 +47,3 @@ "use strict";

if (initialOffset !== undefined)
return buffer.slice(initialOffset, bufferWriter.offset);
return buffer.subarray(initialOffset, bufferWriter.offset);
return buffer;

@@ -50,0 +50,0 @@ }

@@ -49,3 +49,3 @@ "use strict";

if (initialOffset !== undefined)
return buffer.slice(initialOffset, bufferWriter.offset);
return buffer.subarray(initialOffset, bufferWriter.offset);
return buffer;

@@ -52,0 +52,0 @@ }

@@ -71,3 +71,3 @@ "use strict";

if (initialOffset !== undefined)
return buffer.slice(initialOffset, bufferWriter.offset);
return buffer.subarray(initialOffset, bufferWriter.offset);
return buffer;

@@ -74,0 +74,0 @@ }

@@ -26,3 +26,3 @@ "use strict";

if (initialOffset !== undefined)
return buffer.slice(initialOffset, bufferWriter.offset);
return buffer.subarray(initialOffset, bufferWriter.offset);
return buffer;

@@ -29,0 +29,0 @@ }

@@ -180,3 +180,3 @@ "use strict";

if (initialOffset !== undefined)
return buffer.slice(initialOffset, bufferWriter.offset);
return buffer.subarray(initialOffset, bufferWriter.offset);
return buffer;

@@ -194,3 +194,3 @@ }

4;
return tx.toBuffer().slice(offset);
return tx.toBuffer().subarray(offset);
}

@@ -197,0 +197,0 @@ function getBlake2bDigestHash(buffer, personalization) {

@@ -11,4 +11,4 @@ export type CoinSelectPaymentType = 'p2pkh' | 'p2sh' | 'p2tr' | 'p2wpkh' | 'p2wsh';

floorBaseFee?: boolean;
dustOutputFee?: number;
skipPermutation?: boolean;
feePolicy?: 'bitcoin' | 'doge' | 'zcash';
}

@@ -15,0 +15,0 @@ export interface CoinSelectInput {

@@ -49,3 +49,2 @@ /// <reference types="node" />

floorBaseFee?: boolean;
dustOutputFee?: number;
skipUtxoSelection?: boolean;

@@ -52,0 +51,0 @@ skipPermutation?: boolean;

{
"name": "@trezor/utxo-lib",
"version": "1.0.10",
"version": "1.0.11",
"author": "Trezor <info@trezor.io>",

@@ -39,3 +39,3 @@ "homepage": "https://github.com/trezor/trezor-suite/tree/develop/packages/utxo-lib",

"dependencies": {
"@trezor/utils": "9.0.12",
"@trezor/utils": "9.0.13",
"bchaddrjs": "^0.5.2",

@@ -42,0 +42,0 @@ "bech32": "^2.0.0",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc