Socket
Socket
Sign inDemoInstall

@bitaccess/coinlib-common

Package Overview
Dependencies
Maintainers
21
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bitaccess/coinlib-common - npm Package Compare versions

Comparing version 7.0.7 to 7.0.8

367

dist/index.cjs.js

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

var t = require('io-ts');
var tsCommon = require('@bitaccess/ts-common');
var bip32$1 = require('bip32');
var ecpair$1 = require('ecpair');
var ecc = require('tiny-secp256k1');
var tsCommon = require('@bitaccess/ts-common');
var bs58 = require('bs58check');
var bip39 = require('bip39');
var crypto = require('crypto');
var coinlibTypes = require('@bitaccess/coinlib-types');

@@ -35,3 +35,2 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var t__namespace = /*#__PURE__*/_interopNamespace(t);
var ecc__namespace = /*#__PURE__*/_interopNamespace(ecc);

@@ -42,246 +41,2 @@ var bs58__default = /*#__PURE__*/_interopDefaultLegacy(bs58);

const NullableOptionalString = t__namespace.union([t__namespace.string, t__namespace.null, t__namespace.undefined]);
exports.NetworkType = void 0;
(function (NetworkType) {
NetworkType["Mainnet"] = "mainnet";
NetworkType["Testnet"] = "testnet";
})(exports.NetworkType || (exports.NetworkType = {}));
const NetworkTypeT = tsCommon.enumCodec(exports.NetworkType, 'NetworkType');
const BaseConfig = t__namespace.partial({
network: NetworkTypeT,
logger: tsCommon.Logger,
}, 'BaseConfig');
const KeyPairsConfigParam = t__namespace.union([
t__namespace.array(NullableOptionalString),
t__namespace.record(t__namespace.number, NullableOptionalString)
], 'KeyPairsConfigParam');
const Payport = tsCommon.requiredOptionalCodec({
address: t__namespace.string,
}, {
extraId: tsCommon.nullable(t__namespace.string),
signerAddress: t__namespace.string,
}, 'Payport');
const DerivablePayport = tsCommon.requiredOptionalCodec({
index: t__namespace.number
}, {
addressType: t__namespace.string
}, 'DerivablePayport');
const ResolveablePayport = t__namespace.union([Payport, DerivablePayport, t__namespace.string, t__namespace.number], 'ResolveablePayport');
const PayportOutput = t__namespace.type({
payport: ResolveablePayport,
amount: tsCommon.Numeric,
}, 'PayportOutput');
exports.FeeLevel = void 0;
(function (FeeLevel) {
FeeLevel["Custom"] = "custom";
FeeLevel["Low"] = "low";
FeeLevel["Medium"] = "medium";
FeeLevel["High"] = "high";
})(exports.FeeLevel || (exports.FeeLevel = {}));
const FeeLevelT = tsCommon.enumCodec(exports.FeeLevel, 'FeeLevel');
const AutoFeeLevels = t__namespace.union([
t__namespace.literal(exports.FeeLevel.Low),
t__namespace.literal(exports.FeeLevel.Medium),
t__namespace.literal(exports.FeeLevel.High),
], 'AutoFeeLevels');
exports.FeeRateType = void 0;
(function (FeeRateType) {
FeeRateType["Main"] = "main";
FeeRateType["Base"] = "base";
FeeRateType["BasePerWeight"] = "base/weight";
})(exports.FeeRateType || (exports.FeeRateType = {}));
const FeeRateTypeT = tsCommon.enumCodec(exports.FeeRateType, 'FeeRateType');
const FeeRate = t__namespace.type({
feeRate: t__namespace.string,
feeRateType: FeeRateTypeT,
}, 'FeeRate');
const FeeOptionCustom = tsCommon.extendCodec(FeeRate, {}, {
feeLevel: t__namespace.literal(exports.FeeLevel.Custom),
}, 'FeeOptionCustom');
const FeeOptionLevel = t__namespace.partial({
feeLevel: t__namespace.union([t__namespace.literal(exports.FeeLevel.High), t__namespace.literal(exports.FeeLevel.Medium), t__namespace.literal(exports.FeeLevel.Low)]),
}, 'FeeOptionLevel');
const FeeOption = t__namespace.union([FeeOptionCustom, FeeOptionLevel], 'FeeOption');
const UtxoInfo = tsCommon.requiredOptionalCodec({
txid: t__namespace.string,
vout: t__namespace.number,
value: t__namespace.string,
}, {
satoshis: t__namespace.union([t__namespace.number, t__namespace.string]),
confirmations: t__namespace.number,
height: t__namespace.string,
lockTime: t__namespace.string,
coinbase: t__namespace.boolean,
txHex: t__namespace.string,
scriptPubKeyHex: t__namespace.string,
address: t__namespace.string,
spent: t__namespace.boolean,
signer: t__namespace.number,
}, 'UtxoInfo');
const WeightedChangeOutput = t__namespace.type({
address: t__namespace.string,
weight: t__namespace.number,
}, 'WeightedChangeOutput');
const FilterChangeAddresses = tsCommon.functionT('FilterChangeAddresses');
const LookupTxDataByHashes = tsCommon.functionT('LookupTxDataByHash');
const CreateTransactionOptions = tsCommon.extendCodec(FeeOption, {}, {
sequenceNumber: tsCommon.Numeric,
payportBalance: tsCommon.Numeric,
forcedUtxos: t__namespace.array(UtxoInfo),
availableUtxos: t__namespace.array(UtxoInfo),
useAllUtxos: t__namespace.boolean,
useUnconfirmedUtxos: t__namespace.boolean,
recipientPaysFee: t__namespace.boolean,
maxFeePercent: tsCommon.Numeric,
changeAddress: t__namespace.union([t__namespace.string, t__namespace.array(t__namespace.string)]),
lookupTxDataByHashes: LookupTxDataByHashes,
}, 'CreateTransactionOptions');
const GetTransactionInfoOptions = t__namespace.partial({
changeAddress: t__namespace.union([t__namespace.string, t__namespace.array(t__namespace.string)]),
filterChangeAddresses: FilterChangeAddresses,
});
const GetPayportOptions = t__namespace.partial({}, 'GetPayportOptions');
const ResolvedFeeOption = t__namespace.type({
targetFeeLevel: FeeLevelT,
targetFeeRate: t__namespace.string,
targetFeeRateType: FeeRateTypeT,
feeBase: t__namespace.string,
feeMain: t__namespace.string,
}, 'ResolvedFeeOption');
const BalanceResult = tsCommon.requiredOptionalCodec({
confirmedBalance: t__namespace.string,
unconfirmedBalance: t__namespace.string,
spendableBalance: t__namespace.string,
requiresActivation: t__namespace.boolean,
sweepable: t__namespace.boolean,
}, {
minimumBalance: t__namespace.string,
}, 'BalanceResult');
exports.TransactionStatus = void 0;
(function (TransactionStatus) {
TransactionStatus["Unsigned"] = "unsigned";
TransactionStatus["Signed"] = "signed";
TransactionStatus["Pending"] = "pending";
TransactionStatus["Confirmed"] = "confirmed";
TransactionStatus["Failed"] = "failed";
})(exports.TransactionStatus || (exports.TransactionStatus = {}));
const TransactionStatusT = tsCommon.enumCodec(exports.TransactionStatus, 'TransactionStatus');
const TransactionOutput = tsCommon.requiredOptionalCodec({
address: t__namespace.string,
value: t__namespace.string,
}, {
extraId: tsCommon.nullable(t__namespace.string),
}, 'TransactionOutput');
const TransactionCommon = tsCommon.requiredOptionalCodec({
status: TransactionStatusT,
id: tsCommon.nullable(t__namespace.string),
fromAddress: tsCommon.nullable(t__namespace.string),
toAddress: tsCommon.nullable(t__namespace.string),
fromIndex: tsCommon.nullable(t__namespace.number),
toIndex: tsCommon.nullable(t__namespace.number),
amount: tsCommon.nullable(t__namespace.string),
fee: tsCommon.nullable(t__namespace.string),
}, {
fromExtraId: tsCommon.nullable(t__namespace.string),
toExtraId: tsCommon.nullable(t__namespace.string),
sequenceNumber: tsCommon.nullable(t__namespace.union([t__namespace.string, t__namespace.number])),
inputUtxos: t__namespace.array(UtxoInfo),
outputUtxos: t__namespace.array(UtxoInfo),
externalOutputs: t__namespace.array(TransactionOutput),
weight: t__namespace.number,
chainId: t__namespace.string,
}, 'TransactionCommon');
const BaseMultisigData = t__namespace.type({
m: t__namespace.number,
accountIds: t__namespace.array(t__namespace.string),
publicKeys: t__namespace.array(t__namespace.string),
signedAccountIds: t__namespace.array(t__namespace.string),
}, 'BitcoinMultisigData');
const AddressMultisigData = tsCommon.extendCodec(BaseMultisigData, {
signerIndex: t__namespace.number,
inputIndices: t__namespace.array(t__namespace.number),
}, 'AddressMultisigData');
const MultiInputMultisigData = t__namespace.record(t__namespace.string, AddressMultisigData, 'MultiInputMultisigData');
const MultisigData = t__namespace.union([BaseMultisigData, MultiInputMultisigData]);
const UnsignedCommon = tsCommon.extendCodec(TransactionCommon, {
fromAddress: t__namespace.string,
toAddress: t__namespace.string,
fromIndex: tsCommon.nullable(t__namespace.number),
targetFeeLevel: FeeLevelT,
targetFeeRate: tsCommon.nullable(t__namespace.string),
targetFeeRateType: tsCommon.nullable(FeeRateTypeT),
}, {
multisigData: MultisigData,
}, 'UnsignedCommon');
const BaseUnsignedTransaction = tsCommon.extendCodec(UnsignedCommon, {
status: t__namespace.literal(exports.TransactionStatus.Unsigned),
data: t__namespace.object,
}, 'BaseUnsignedTransaction');
const BaseSignedTransaction = tsCommon.extendCodec(UnsignedCommon, {
status: t__namespace.literal(exports.TransactionStatus.Signed),
id: t__namespace.string,
amount: t__namespace.string,
fee: t__namespace.string,
data: t__namespace.object,
}, 'BaseSignedTransaction');
const BaseTransactionInfo = tsCommon.extendCodec(TransactionCommon, {
id: t__namespace.string,
amount: t__namespace.string,
fee: t__namespace.string,
isExecuted: t__namespace.boolean,
isConfirmed: t__namespace.boolean,
confirmations: t__namespace.number,
confirmationId: tsCommon.nullable(t__namespace.string),
confirmationTimestamp: tsCommon.nullable(tsCommon.DateT),
data: t__namespace.object,
}, {
currentBlockNumber: t__namespace.union([t__namespace.string, t__namespace.number]),
confirmationNumber: t__namespace.union([t__namespace.string, t__namespace.number])
}, 'BaseTransactionInfo');
const BaseBroadcastResult = t__namespace.type({
id: t__namespace.string,
}, 'BaseBroadcastResult');
const BalanceActivityType = t__namespace.union([t__namespace.literal('in'), t__namespace.literal('out'), t__namespace.literal('fee')], 'BalanceActivityType');
const BalanceActivity = tsCommon.requiredOptionalCodec({
type: BalanceActivityType,
networkType: NetworkTypeT,
networkSymbol: t__namespace.string,
assetSymbol: t__namespace.string,
address: t__namespace.string,
extraId: tsCommon.nullable(t__namespace.string),
amount: t__namespace.string,
externalId: t__namespace.string,
activitySequence: t__namespace.string,
confirmationId: t__namespace.string,
confirmationNumber: t__namespace.union([t__namespace.string, t__namespace.number]),
timestamp: tsCommon.DateT,
}, {
confirmations: t__namespace.number,
utxosSpent: t__namespace.array(UtxoInfo),
utxosCreated: t__namespace.array(UtxoInfo),
tokenAddress: t__namespace.string,
}, 'BalanceActivity');
const BalanceMonitorConfig = BaseConfig;
const GetBalanceActivityOptions = t__namespace.partial({
from: t__namespace.union([tsCommon.Numeric, BalanceActivity]),
to: t__namespace.union([tsCommon.Numeric, BalanceActivity]),
}, 'GetBalanceActivityOptions');
const BalanceActivityCallback = tsCommon.functionT('BalanceActivityCallback');
const NewBlockCallback = tsCommon.functionT('NewBlockCallback');
const RetrieveBalanceActivitiesResult = t__namespace.type({
from: t__namespace.string,
to: t__namespace.string,
}, 'RetrieveBalanceActivitiesResult');
const BlockInfo = tsCommon.requiredOptionalCodec({
id: t__namespace.string,
height: t__namespace.number,
time: tsCommon.DateT,
}, {
previousId: t__namespace.string,
raw: t__namespace.object,
}, 'BlockInfo');
const GetFeeRecommendationOptions = t__namespace.partial({
source: t__namespace.string,
}, 'GetFeeRecommendationOptions');
const bip32 = bip32$1.BIP32Factory(ecc__namespace);

@@ -400,40 +155,4 @@ const ecpair = ecpair$1.ECPairFactory(ecc__namespace);

exports.PaymentsErrorCode = void 0;
(function (PaymentsErrorCode) {
PaymentsErrorCode["TxExpired"] = "PAYMENTS_TX_EXPIRED";
PaymentsErrorCode["TxSequenceTooHigh"] = "PAYMENTS_TX_SEQUENCE_TOO_HIGH";
PaymentsErrorCode["TxSequenceCollision"] = "PAYMENTS_TX_SEQUENCE_COLLISION";
PaymentsErrorCode["TxInsufficientBalance"] = "PAYMENTS_TX_INSUFFICIENT_BALANCE";
PaymentsErrorCode["TxFeeTooHigh"] = "PAYMENTS_TX_FEE_TOO_HIGH";
})(exports.PaymentsErrorCode || (exports.PaymentsErrorCode = {}));
class PaymentsError extends Error {
constructor(code, message) {
super(typeof message === 'undefined' ? code : `${code} - ${message.toString()}`);
this.code = code;
this.name = PaymentsError.name;
}
}
class StandardConnectionManager {
constructor() {
this.connections = {};
}
getConnection(connected) {
return connected.api;
}
getConnectionUrl(config) {
return config.server || null;
}
setConnection(config, connection) {
config.api = connection;
}
}
const DEFAULT_MAX_FEE_PERCENT = 50;
const BIP39_SEED_REGEX = /^[0-9a-f]{128}$/;
const BIP39_SEED_BYTES = 64;
const DERIVATION_PATH_REGEX = /^(m\/)?[0-9]+'?(\/[0-9]+'?)*$/;
function generateNewSeed() {
return crypto__default["default"].randomBytes(BIP39_SEED_BYTES);
return crypto__default["default"].randomBytes(coinlibTypes.BIP39_SEED_BYTES);
}

@@ -523,3 +242,3 @@ function splitDerivationPath(path) {

if (tsCommon.isString(root)) {
if (BIP39_SEED_REGEX.test(root)) {
if (coinlibTypes.BIP39_SEED_REGEX.test(root)) {
return bip32.fromSeed(Buffer.from(root, 'hex'));

@@ -541,4 +260,4 @@ }

else if (root instanceof Buffer) {
if (root.length !== BIP39_SEED_BYTES) {
throw new Error(`Invalid bip39 seed buffer provided with length ${root.length} when ${BIP39_SEED_BYTES} is expected`);
if (root.length !== coinlibTypes.BIP39_SEED_BYTES) {
throw new Error(`Invalid bip39 seed buffer provided with length ${root.length} when ${coinlibTypes.BIP39_SEED_BYTES} is expected`);
}

@@ -553,3 +272,3 @@ return bip32.fromSeed(root);

constructor(root, derivationPath, network) {
if (!DERIVATION_PATH_REGEX.test(derivationPath)) {
if (!coinlibTypes.DERIVATION_PATH_REGEX.test(derivationPath)) {
throw new Error(`Invalid derivation path: ${derivationPath}`);

@@ -588,2 +307,18 @@ }

class StandardConnectionManager {
constructor() {
this.connections = {};
}
getConnection(connected) {
return connected.api;
}
getConnectionUrl(config) {
return config.server || null;
}
setConnection(config, connection) {
config.api = connection;
}
}
exports.ecc = ecc__namespace;
Object.defineProperty(exports, 'BigNumber', {

@@ -593,3 +328,2 @@ enumerable: true,

});
exports.ecc = ecc__namespace;
Object.defineProperty(exports, 'bs58', {

@@ -604,54 +338,5 @@ enumerable: true,

exports.bip39 = bip39__namespace;
exports.AddressMultisigData = AddressMultisigData;
exports.AutoFeeLevels = AutoFeeLevels;
exports.BIP39_SEED_BYTES = BIP39_SEED_BYTES;
exports.BIP39_SEED_REGEX = BIP39_SEED_REGEX;
exports.BalanceActivity = BalanceActivity;
exports.BalanceActivityCallback = BalanceActivityCallback;
exports.BalanceActivityType = BalanceActivityType;
exports.BalanceMonitorConfig = BalanceMonitorConfig;
exports.BalanceResult = BalanceResult;
exports.BaseBroadcastResult = BaseBroadcastResult;
exports.BaseConfig = BaseConfig;
exports.BaseMultisigData = BaseMultisigData;
exports.BaseSignedTransaction = BaseSignedTransaction;
exports.BaseTransactionInfo = BaseTransactionInfo;
exports.BaseUnsignedTransaction = BaseUnsignedTransaction;
exports.BlockInfo = BlockInfo;
exports.CreateTransactionOptions = CreateTransactionOptions;
exports.DEFAULT_MAX_FEE_PERCENT = DEFAULT_MAX_FEE_PERCENT;
exports.DERIVATION_PATH_REGEX = DERIVATION_PATH_REGEX;
exports.DerivablePayport = DerivablePayport;
exports.FeeLevelT = FeeLevelT;
exports.FeeOption = FeeOption;
exports.FeeOptionCustom = FeeOptionCustom;
exports.FeeOptionLevel = FeeOptionLevel;
exports.FeeRate = FeeRate;
exports.FeeRateTypeT = FeeRateTypeT;
exports.FilterChangeAddresses = FilterChangeAddresses;
exports.GetBalanceActivityOptions = GetBalanceActivityOptions;
exports.GetFeeRecommendationOptions = GetFeeRecommendationOptions;
exports.GetPayportOptions = GetPayportOptions;
exports.GetTransactionInfoOptions = GetTransactionInfoOptions;
exports.HdKeyUtils = HdKeyUtils;
exports.KeyPairsConfigParam = KeyPairsConfigParam;
exports.LookupTxDataByHashes = LookupTxDataByHashes;
exports.MultiInputMultisigData = MultiInputMultisigData;
exports.MultisigData = MultisigData;
exports.NetworkTypeT = NetworkTypeT;
exports.NewBlockCallback = NewBlockCallback;
exports.NullableOptionalString = NullableOptionalString;
exports.PaymentsError = PaymentsError;
exports.PaymentsFactory = PaymentsFactory;
exports.Payport = Payport;
exports.PayportOutput = PayportOutput;
exports.ResolveablePayport = ResolveablePayport;
exports.ResolvedFeeOption = ResolvedFeeOption;
exports.RetrieveBalanceActivitiesResult = RetrieveBalanceActivitiesResult;
exports.StandardConnectionManager = StandardConnectionManager;
exports.TransactionCommon = TransactionCommon;
exports.TransactionOutput = TransactionOutput;
exports.TransactionStatusT = TransactionStatusT;
exports.UtxoInfo = UtxoInfo;
exports.WeightedChangeOutput = WeightedChangeOutput;
exports.bip32 = bip32;

@@ -678,2 +363,8 @@ exports.bip32MagicNumberToPrefix = bip32MagicNumberToPrefix;

exports.validateHdKey = validateHdKey;
Object.keys(coinlibTypes).forEach(function (k) {
if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, {
enumerable: true,
get: function () { return coinlibTypes[k]; }
});
});
//# sourceMappingURL=index.cjs.js.map

@@ -1,4 +0,1 @@

import * as t from 'io-ts';
import { enumCodec, Logger, requiredOptionalCodec, nullable, Numeric, extendCodec, functionT, DateT, BigNumber, isString } from '@bitaccess/ts-common';
export { BigNumber } from '@bitaccess/ts-common';
import { BIP32Factory } from 'bip32';

@@ -8,2 +5,4 @@ import { ECPairFactory } from 'ecpair';

export { ecc };
import { BigNumber, isString } from '@bitaccess/ts-common';
export { BigNumber } from '@bitaccess/ts-common';
import bs58 from 'bs58check';

@@ -14,247 +13,5 @@ export { default as bs58, default as bs58check } from 'bs58check';

import crypto from 'crypto';
import { BIP39_SEED_BYTES, BIP39_SEED_REGEX, DERIVATION_PATH_REGEX } from '@bitaccess/coinlib-types';
export * from '@bitaccess/coinlib-types';
const NullableOptionalString = t.union([t.string, t.null, t.undefined]);
var NetworkType;
(function (NetworkType) {
NetworkType["Mainnet"] = "mainnet";
NetworkType["Testnet"] = "testnet";
})(NetworkType || (NetworkType = {}));
const NetworkTypeT = enumCodec(NetworkType, 'NetworkType');
const BaseConfig = t.partial({
network: NetworkTypeT,
logger: Logger,
}, 'BaseConfig');
const KeyPairsConfigParam = t.union([
t.array(NullableOptionalString),
t.record(t.number, NullableOptionalString)
], 'KeyPairsConfigParam');
const Payport = requiredOptionalCodec({
address: t.string,
}, {
extraId: nullable(t.string),
signerAddress: t.string,
}, 'Payport');
const DerivablePayport = requiredOptionalCodec({
index: t.number
}, {
addressType: t.string
}, 'DerivablePayport');
const ResolveablePayport = t.union([Payport, DerivablePayport, t.string, t.number], 'ResolveablePayport');
const PayportOutput = t.type({
payport: ResolveablePayport,
amount: Numeric,
}, 'PayportOutput');
var FeeLevel;
(function (FeeLevel) {
FeeLevel["Custom"] = "custom";
FeeLevel["Low"] = "low";
FeeLevel["Medium"] = "medium";
FeeLevel["High"] = "high";
})(FeeLevel || (FeeLevel = {}));
const FeeLevelT = enumCodec(FeeLevel, 'FeeLevel');
const AutoFeeLevels = t.union([
t.literal(FeeLevel.Low),
t.literal(FeeLevel.Medium),
t.literal(FeeLevel.High),
], 'AutoFeeLevels');
var FeeRateType;
(function (FeeRateType) {
FeeRateType["Main"] = "main";
FeeRateType["Base"] = "base";
FeeRateType["BasePerWeight"] = "base/weight";
})(FeeRateType || (FeeRateType = {}));
const FeeRateTypeT = enumCodec(FeeRateType, 'FeeRateType');
const FeeRate = t.type({
feeRate: t.string,
feeRateType: FeeRateTypeT,
}, 'FeeRate');
const FeeOptionCustom = extendCodec(FeeRate, {}, {
feeLevel: t.literal(FeeLevel.Custom),
}, 'FeeOptionCustom');
const FeeOptionLevel = t.partial({
feeLevel: t.union([t.literal(FeeLevel.High), t.literal(FeeLevel.Medium), t.literal(FeeLevel.Low)]),
}, 'FeeOptionLevel');
const FeeOption = t.union([FeeOptionCustom, FeeOptionLevel], 'FeeOption');
const UtxoInfo = requiredOptionalCodec({
txid: t.string,
vout: t.number,
value: t.string,
}, {
satoshis: t.union([t.number, t.string]),
confirmations: t.number,
height: t.string,
lockTime: t.string,
coinbase: t.boolean,
txHex: t.string,
scriptPubKeyHex: t.string,
address: t.string,
spent: t.boolean,
signer: t.number,
}, 'UtxoInfo');
const WeightedChangeOutput = t.type({
address: t.string,
weight: t.number,
}, 'WeightedChangeOutput');
const FilterChangeAddresses = functionT('FilterChangeAddresses');
const LookupTxDataByHashes = functionT('LookupTxDataByHash');
const CreateTransactionOptions = extendCodec(FeeOption, {}, {
sequenceNumber: Numeric,
payportBalance: Numeric,
forcedUtxos: t.array(UtxoInfo),
availableUtxos: t.array(UtxoInfo),
useAllUtxos: t.boolean,
useUnconfirmedUtxos: t.boolean,
recipientPaysFee: t.boolean,
maxFeePercent: Numeric,
changeAddress: t.union([t.string, t.array(t.string)]),
lookupTxDataByHashes: LookupTxDataByHashes,
}, 'CreateTransactionOptions');
const GetTransactionInfoOptions = t.partial({
changeAddress: t.union([t.string, t.array(t.string)]),
filterChangeAddresses: FilterChangeAddresses,
});
const GetPayportOptions = t.partial({}, 'GetPayportOptions');
const ResolvedFeeOption = t.type({
targetFeeLevel: FeeLevelT,
targetFeeRate: t.string,
targetFeeRateType: FeeRateTypeT,
feeBase: t.string,
feeMain: t.string,
}, 'ResolvedFeeOption');
const BalanceResult = requiredOptionalCodec({
confirmedBalance: t.string,
unconfirmedBalance: t.string,
spendableBalance: t.string,
requiresActivation: t.boolean,
sweepable: t.boolean,
}, {
minimumBalance: t.string,
}, 'BalanceResult');
var TransactionStatus;
(function (TransactionStatus) {
TransactionStatus["Unsigned"] = "unsigned";
TransactionStatus["Signed"] = "signed";
TransactionStatus["Pending"] = "pending";
TransactionStatus["Confirmed"] = "confirmed";
TransactionStatus["Failed"] = "failed";
})(TransactionStatus || (TransactionStatus = {}));
const TransactionStatusT = enumCodec(TransactionStatus, 'TransactionStatus');
const TransactionOutput = requiredOptionalCodec({
address: t.string,
value: t.string,
}, {
extraId: nullable(t.string),
}, 'TransactionOutput');
const TransactionCommon = requiredOptionalCodec({
status: TransactionStatusT,
id: nullable(t.string),
fromAddress: nullable(t.string),
toAddress: nullable(t.string),
fromIndex: nullable(t.number),
toIndex: nullable(t.number),
amount: nullable(t.string),
fee: nullable(t.string),
}, {
fromExtraId: nullable(t.string),
toExtraId: nullable(t.string),
sequenceNumber: nullable(t.union([t.string, t.number])),
inputUtxos: t.array(UtxoInfo),
outputUtxos: t.array(UtxoInfo),
externalOutputs: t.array(TransactionOutput),
weight: t.number,
chainId: t.string,
}, 'TransactionCommon');
const BaseMultisigData = t.type({
m: t.number,
accountIds: t.array(t.string),
publicKeys: t.array(t.string),
signedAccountIds: t.array(t.string),
}, 'BitcoinMultisigData');
const AddressMultisigData = extendCodec(BaseMultisigData, {
signerIndex: t.number,
inputIndices: t.array(t.number),
}, 'AddressMultisigData');
const MultiInputMultisigData = t.record(t.string, AddressMultisigData, 'MultiInputMultisigData');
const MultisigData = t.union([BaseMultisigData, MultiInputMultisigData]);
const UnsignedCommon = extendCodec(TransactionCommon, {
fromAddress: t.string,
toAddress: t.string,
fromIndex: nullable(t.number),
targetFeeLevel: FeeLevelT,
targetFeeRate: nullable(t.string),
targetFeeRateType: nullable(FeeRateTypeT),
}, {
multisigData: MultisigData,
}, 'UnsignedCommon');
const BaseUnsignedTransaction = extendCodec(UnsignedCommon, {
status: t.literal(TransactionStatus.Unsigned),
data: t.object,
}, 'BaseUnsignedTransaction');
const BaseSignedTransaction = extendCodec(UnsignedCommon, {
status: t.literal(TransactionStatus.Signed),
id: t.string,
amount: t.string,
fee: t.string,
data: t.object,
}, 'BaseSignedTransaction');
const BaseTransactionInfo = extendCodec(TransactionCommon, {
id: t.string,
amount: t.string,
fee: t.string,
isExecuted: t.boolean,
isConfirmed: t.boolean,
confirmations: t.number,
confirmationId: nullable(t.string),
confirmationTimestamp: nullable(DateT),
data: t.object,
}, {
currentBlockNumber: t.union([t.string, t.number]),
confirmationNumber: t.union([t.string, t.number])
}, 'BaseTransactionInfo');
const BaseBroadcastResult = t.type({
id: t.string,
}, 'BaseBroadcastResult');
const BalanceActivityType = t.union([t.literal('in'), t.literal('out'), t.literal('fee')], 'BalanceActivityType');
const BalanceActivity = requiredOptionalCodec({
type: BalanceActivityType,
networkType: NetworkTypeT,
networkSymbol: t.string,
assetSymbol: t.string,
address: t.string,
extraId: nullable(t.string),
amount: t.string,
externalId: t.string,
activitySequence: t.string,
confirmationId: t.string,
confirmationNumber: t.union([t.string, t.number]),
timestamp: DateT,
}, {
confirmations: t.number,
utxosSpent: t.array(UtxoInfo),
utxosCreated: t.array(UtxoInfo),
tokenAddress: t.string,
}, 'BalanceActivity');
const BalanceMonitorConfig = BaseConfig;
const GetBalanceActivityOptions = t.partial({
from: t.union([Numeric, BalanceActivity]),
to: t.union([Numeric, BalanceActivity]),
}, 'GetBalanceActivityOptions');
const BalanceActivityCallback = functionT('BalanceActivityCallback');
const NewBlockCallback = functionT('NewBlockCallback');
const RetrieveBalanceActivitiesResult = t.type({
from: t.string,
to: t.string,
}, 'RetrieveBalanceActivitiesResult');
const BlockInfo = requiredOptionalCodec({
id: t.string,
height: t.number,
time: DateT,
}, {
previousId: t.string,
raw: t.object,
}, 'BlockInfo');
const GetFeeRecommendationOptions = t.partial({
source: t.string,
}, 'GetFeeRecommendationOptions');
const bip32 = BIP32Factory(ecc);

@@ -373,38 +130,2 @@ const ecpair = ECPairFactory(ecc);

var PaymentsErrorCode;
(function (PaymentsErrorCode) {
PaymentsErrorCode["TxExpired"] = "PAYMENTS_TX_EXPIRED";
PaymentsErrorCode["TxSequenceTooHigh"] = "PAYMENTS_TX_SEQUENCE_TOO_HIGH";
PaymentsErrorCode["TxSequenceCollision"] = "PAYMENTS_TX_SEQUENCE_COLLISION";
PaymentsErrorCode["TxInsufficientBalance"] = "PAYMENTS_TX_INSUFFICIENT_BALANCE";
PaymentsErrorCode["TxFeeTooHigh"] = "PAYMENTS_TX_FEE_TOO_HIGH";
})(PaymentsErrorCode || (PaymentsErrorCode = {}));
class PaymentsError extends Error {
constructor(code, message) {
super(typeof message === 'undefined' ? code : `${code} - ${message.toString()}`);
this.code = code;
this.name = PaymentsError.name;
}
}
class StandardConnectionManager {
constructor() {
this.connections = {};
}
getConnection(connected) {
return connected.api;
}
getConnectionUrl(config) {
return config.server || null;
}
setConnection(config, connection) {
config.api = connection;
}
}
const DEFAULT_MAX_FEE_PERCENT = 50;
const BIP39_SEED_REGEX = /^[0-9a-f]{128}$/;
const BIP39_SEED_BYTES = 64;
const DERIVATION_PATH_REGEX = /^(m\/)?[0-9]+'?(\/[0-9]+'?)*$/;
function generateNewSeed() {

@@ -558,3 +279,18 @@ return crypto.randomBytes(BIP39_SEED_BYTES);

export { AddressMultisigData, AutoFeeLevels, BIP39_SEED_BYTES, BIP39_SEED_REGEX, BalanceActivity, BalanceActivityCallback, BalanceActivityType, BalanceMonitorConfig, BalanceResult, BaseBroadcastResult, BaseConfig, BaseMultisigData, BaseSignedTransaction, BaseTransactionInfo, BaseUnsignedTransaction, BlockInfo, CreateTransactionOptions, DEFAULT_MAX_FEE_PERCENT, DERIVATION_PATH_REGEX, DerivablePayport, FeeLevel, FeeLevelT, FeeOption, FeeOptionCustom, FeeOptionLevel, FeeRate, FeeRateType, FeeRateTypeT, FilterChangeAddresses, GetBalanceActivityOptions, GetFeeRecommendationOptions, GetPayportOptions, GetTransactionInfoOptions, HdKeyUtils, KeyPairsConfigParam, LookupTxDataByHashes, MultiInputMultisigData, MultisigData, NetworkType, NetworkTypeT, NewBlockCallback, NullableOptionalString, PaymentsError, PaymentsErrorCode, PaymentsFactory, Payport, PayportOutput, ResolveablePayport, ResolvedFeeOption, RetrieveBalanceActivitiesResult, StandardConnectionManager, TransactionCommon, TransactionOutput, TransactionStatus, TransactionStatusT, UtxoInfo, WeightedChangeOutput, bip32, bip32MagicNumberToPrefix, buffToHex, convertXPrefixHdKeys, createUnitConverters, deriveHDNode, determineHdNode, ecpair, generateNewSeed, hdKeyToHdNode, hexToBuff, isMatchingError, isValidHdKey, isValidXprv, isValidXpub, keysOf, numericToHex, prepend0x, splitDerivationPath, strip0x, validateHdKey };
class StandardConnectionManager {
constructor() {
this.connections = {};
}
getConnection(connected) {
return connected.api;
}
getConnectionUrl(config) {
return config.server || null;
}
setConnection(config, connection) {
config.api = connection;
}
}
export { HdKeyUtils, PaymentsFactory, StandardConnectionManager, bip32, bip32MagicNumberToPrefix, buffToHex, convertXPrefixHdKeys, createUnitConverters, deriveHDNode, determineHdNode, ecpair, generateNewSeed, hdKeyToHdNode, hexToBuff, isMatchingError, isValidHdKey, isValidXprv, isValidXpub, keysOf, numericToHex, prepend0x, splitDerivationPath, strip0x, validateHdKey };
//# sourceMappingURL=index.es.js.map
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('io-ts'), require('@bitaccess/ts-common'), require('bip32'), require('ecpair'), require('tiny-secp256k1'), require('bs58check'), require('bip39'), require('crypto')) :
typeof define === 'function' && define.amd ? define(['exports', 'io-ts', '@bitaccess/ts-common', 'bip32', 'ecpair', 'tiny-secp256k1', 'bs58check', 'bip39', 'crypto'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.bitaccessCoinlibCommon = {}, global.t, global.tsCommon, global.bip32$1, global.ecpair$1, global.ecc, global.bs58, global.bip39, global.crypto));
})(this, (function (exports, t, tsCommon, bip32$1, ecpair$1, ecc, bs58, bip39, crypto) { 'use strict';
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('bip32'), require('ecpair'), require('tiny-secp256k1'), require('@bitaccess/ts-common'), require('bs58check'), require('bip39'), require('crypto'), require('@bitaccess/coinlib-types')) :
typeof define === 'function' && define.amd ? define(['exports', 'bip32', 'ecpair', 'tiny-secp256k1', '@bitaccess/ts-common', 'bs58check', 'bip39', 'crypto', '@bitaccess/coinlib-types'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.bitaccessCoinlibCommon = {}, global.bip32$1, global.ecpair$1, global.ecc, global.tsCommon, global.bs58, global.bip39, global.crypto, global.coinlibTypes));
})(this, (function (exports, bip32$1, ecpair$1, ecc, tsCommon, bs58, bip39, crypto, coinlibTypes) { 'use strict';

@@ -27,3 +27,2 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var t__namespace = /*#__PURE__*/_interopNamespace(t);
var ecc__namespace = /*#__PURE__*/_interopNamespace(ecc);

@@ -34,246 +33,2 @@ var bs58__default = /*#__PURE__*/_interopDefaultLegacy(bs58);

const NullableOptionalString = t__namespace.union([t__namespace.string, t__namespace.null, t__namespace.undefined]);
exports.NetworkType = void 0;
(function (NetworkType) {
NetworkType["Mainnet"] = "mainnet";
NetworkType["Testnet"] = "testnet";
})(exports.NetworkType || (exports.NetworkType = {}));
const NetworkTypeT = tsCommon.enumCodec(exports.NetworkType, 'NetworkType');
const BaseConfig = t__namespace.partial({
network: NetworkTypeT,
logger: tsCommon.Logger,
}, 'BaseConfig');
const KeyPairsConfigParam = t__namespace.union([
t__namespace.array(NullableOptionalString),
t__namespace.record(t__namespace.number, NullableOptionalString)
], 'KeyPairsConfigParam');
const Payport = tsCommon.requiredOptionalCodec({
address: t__namespace.string,
}, {
extraId: tsCommon.nullable(t__namespace.string),
signerAddress: t__namespace.string,
}, 'Payport');
const DerivablePayport = tsCommon.requiredOptionalCodec({
index: t__namespace.number
}, {
addressType: t__namespace.string
}, 'DerivablePayport');
const ResolveablePayport = t__namespace.union([Payport, DerivablePayport, t__namespace.string, t__namespace.number], 'ResolveablePayport');
const PayportOutput = t__namespace.type({
payport: ResolveablePayport,
amount: tsCommon.Numeric,
}, 'PayportOutput');
exports.FeeLevel = void 0;
(function (FeeLevel) {
FeeLevel["Custom"] = "custom";
FeeLevel["Low"] = "low";
FeeLevel["Medium"] = "medium";
FeeLevel["High"] = "high";
})(exports.FeeLevel || (exports.FeeLevel = {}));
const FeeLevelT = tsCommon.enumCodec(exports.FeeLevel, 'FeeLevel');
const AutoFeeLevels = t__namespace.union([
t__namespace.literal(exports.FeeLevel.Low),
t__namespace.literal(exports.FeeLevel.Medium),
t__namespace.literal(exports.FeeLevel.High),
], 'AutoFeeLevels');
exports.FeeRateType = void 0;
(function (FeeRateType) {
FeeRateType["Main"] = "main";
FeeRateType["Base"] = "base";
FeeRateType["BasePerWeight"] = "base/weight";
})(exports.FeeRateType || (exports.FeeRateType = {}));
const FeeRateTypeT = tsCommon.enumCodec(exports.FeeRateType, 'FeeRateType');
const FeeRate = t__namespace.type({
feeRate: t__namespace.string,
feeRateType: FeeRateTypeT,
}, 'FeeRate');
const FeeOptionCustom = tsCommon.extendCodec(FeeRate, {}, {
feeLevel: t__namespace.literal(exports.FeeLevel.Custom),
}, 'FeeOptionCustom');
const FeeOptionLevel = t__namespace.partial({
feeLevel: t__namespace.union([t__namespace.literal(exports.FeeLevel.High), t__namespace.literal(exports.FeeLevel.Medium), t__namespace.literal(exports.FeeLevel.Low)]),
}, 'FeeOptionLevel');
const FeeOption = t__namespace.union([FeeOptionCustom, FeeOptionLevel], 'FeeOption');
const UtxoInfo = tsCommon.requiredOptionalCodec({
txid: t__namespace.string,
vout: t__namespace.number,
value: t__namespace.string,
}, {
satoshis: t__namespace.union([t__namespace.number, t__namespace.string]),
confirmations: t__namespace.number,
height: t__namespace.string,
lockTime: t__namespace.string,
coinbase: t__namespace.boolean,
txHex: t__namespace.string,
scriptPubKeyHex: t__namespace.string,
address: t__namespace.string,
spent: t__namespace.boolean,
signer: t__namespace.number,
}, 'UtxoInfo');
const WeightedChangeOutput = t__namespace.type({
address: t__namespace.string,
weight: t__namespace.number,
}, 'WeightedChangeOutput');
const FilterChangeAddresses = tsCommon.functionT('FilterChangeAddresses');
const LookupTxDataByHashes = tsCommon.functionT('LookupTxDataByHash');
const CreateTransactionOptions = tsCommon.extendCodec(FeeOption, {}, {
sequenceNumber: tsCommon.Numeric,
payportBalance: tsCommon.Numeric,
forcedUtxos: t__namespace.array(UtxoInfo),
availableUtxos: t__namespace.array(UtxoInfo),
useAllUtxos: t__namespace.boolean,
useUnconfirmedUtxos: t__namespace.boolean,
recipientPaysFee: t__namespace.boolean,
maxFeePercent: tsCommon.Numeric,
changeAddress: t__namespace.union([t__namespace.string, t__namespace.array(t__namespace.string)]),
lookupTxDataByHashes: LookupTxDataByHashes,
}, 'CreateTransactionOptions');
const GetTransactionInfoOptions = t__namespace.partial({
changeAddress: t__namespace.union([t__namespace.string, t__namespace.array(t__namespace.string)]),
filterChangeAddresses: FilterChangeAddresses,
});
const GetPayportOptions = t__namespace.partial({}, 'GetPayportOptions');
const ResolvedFeeOption = t__namespace.type({
targetFeeLevel: FeeLevelT,
targetFeeRate: t__namespace.string,
targetFeeRateType: FeeRateTypeT,
feeBase: t__namespace.string,
feeMain: t__namespace.string,
}, 'ResolvedFeeOption');
const BalanceResult = tsCommon.requiredOptionalCodec({
confirmedBalance: t__namespace.string,
unconfirmedBalance: t__namespace.string,
spendableBalance: t__namespace.string,
requiresActivation: t__namespace.boolean,
sweepable: t__namespace.boolean,
}, {
minimumBalance: t__namespace.string,
}, 'BalanceResult');
exports.TransactionStatus = void 0;
(function (TransactionStatus) {
TransactionStatus["Unsigned"] = "unsigned";
TransactionStatus["Signed"] = "signed";
TransactionStatus["Pending"] = "pending";
TransactionStatus["Confirmed"] = "confirmed";
TransactionStatus["Failed"] = "failed";
})(exports.TransactionStatus || (exports.TransactionStatus = {}));
const TransactionStatusT = tsCommon.enumCodec(exports.TransactionStatus, 'TransactionStatus');
const TransactionOutput = tsCommon.requiredOptionalCodec({
address: t__namespace.string,
value: t__namespace.string,
}, {
extraId: tsCommon.nullable(t__namespace.string),
}, 'TransactionOutput');
const TransactionCommon = tsCommon.requiredOptionalCodec({
status: TransactionStatusT,
id: tsCommon.nullable(t__namespace.string),
fromAddress: tsCommon.nullable(t__namespace.string),
toAddress: tsCommon.nullable(t__namespace.string),
fromIndex: tsCommon.nullable(t__namespace.number),
toIndex: tsCommon.nullable(t__namespace.number),
amount: tsCommon.nullable(t__namespace.string),
fee: tsCommon.nullable(t__namespace.string),
}, {
fromExtraId: tsCommon.nullable(t__namespace.string),
toExtraId: tsCommon.nullable(t__namespace.string),
sequenceNumber: tsCommon.nullable(t__namespace.union([t__namespace.string, t__namespace.number])),
inputUtxos: t__namespace.array(UtxoInfo),
outputUtxos: t__namespace.array(UtxoInfo),
externalOutputs: t__namespace.array(TransactionOutput),
weight: t__namespace.number,
chainId: t__namespace.string,
}, 'TransactionCommon');
const BaseMultisigData = t__namespace.type({
m: t__namespace.number,
accountIds: t__namespace.array(t__namespace.string),
publicKeys: t__namespace.array(t__namespace.string),
signedAccountIds: t__namespace.array(t__namespace.string),
}, 'BitcoinMultisigData');
const AddressMultisigData = tsCommon.extendCodec(BaseMultisigData, {
signerIndex: t__namespace.number,
inputIndices: t__namespace.array(t__namespace.number),
}, 'AddressMultisigData');
const MultiInputMultisigData = t__namespace.record(t__namespace.string, AddressMultisigData, 'MultiInputMultisigData');
const MultisigData = t__namespace.union([BaseMultisigData, MultiInputMultisigData]);
const UnsignedCommon = tsCommon.extendCodec(TransactionCommon, {
fromAddress: t__namespace.string,
toAddress: t__namespace.string,
fromIndex: tsCommon.nullable(t__namespace.number),
targetFeeLevel: FeeLevelT,
targetFeeRate: tsCommon.nullable(t__namespace.string),
targetFeeRateType: tsCommon.nullable(FeeRateTypeT),
}, {
multisigData: MultisigData,
}, 'UnsignedCommon');
const BaseUnsignedTransaction = tsCommon.extendCodec(UnsignedCommon, {
status: t__namespace.literal(exports.TransactionStatus.Unsigned),
data: t__namespace.object,
}, 'BaseUnsignedTransaction');
const BaseSignedTransaction = tsCommon.extendCodec(UnsignedCommon, {
status: t__namespace.literal(exports.TransactionStatus.Signed),
id: t__namespace.string,
amount: t__namespace.string,
fee: t__namespace.string,
data: t__namespace.object,
}, 'BaseSignedTransaction');
const BaseTransactionInfo = tsCommon.extendCodec(TransactionCommon, {
id: t__namespace.string,
amount: t__namespace.string,
fee: t__namespace.string,
isExecuted: t__namespace.boolean,
isConfirmed: t__namespace.boolean,
confirmations: t__namespace.number,
confirmationId: tsCommon.nullable(t__namespace.string),
confirmationTimestamp: tsCommon.nullable(tsCommon.DateT),
data: t__namespace.object,
}, {
currentBlockNumber: t__namespace.union([t__namespace.string, t__namespace.number]),
confirmationNumber: t__namespace.union([t__namespace.string, t__namespace.number])
}, 'BaseTransactionInfo');
const BaseBroadcastResult = t__namespace.type({
id: t__namespace.string,
}, 'BaseBroadcastResult');
const BalanceActivityType = t__namespace.union([t__namespace.literal('in'), t__namespace.literal('out'), t__namespace.literal('fee')], 'BalanceActivityType');
const BalanceActivity = tsCommon.requiredOptionalCodec({
type: BalanceActivityType,
networkType: NetworkTypeT,
networkSymbol: t__namespace.string,
assetSymbol: t__namespace.string,
address: t__namespace.string,
extraId: tsCommon.nullable(t__namespace.string),
amount: t__namespace.string,
externalId: t__namespace.string,
activitySequence: t__namespace.string,
confirmationId: t__namespace.string,
confirmationNumber: t__namespace.union([t__namespace.string, t__namespace.number]),
timestamp: tsCommon.DateT,
}, {
confirmations: t__namespace.number,
utxosSpent: t__namespace.array(UtxoInfo),
utxosCreated: t__namespace.array(UtxoInfo),
tokenAddress: t__namespace.string,
}, 'BalanceActivity');
const BalanceMonitorConfig = BaseConfig;
const GetBalanceActivityOptions = t__namespace.partial({
from: t__namespace.union([tsCommon.Numeric, BalanceActivity]),
to: t__namespace.union([tsCommon.Numeric, BalanceActivity]),
}, 'GetBalanceActivityOptions');
const BalanceActivityCallback = tsCommon.functionT('BalanceActivityCallback');
const NewBlockCallback = tsCommon.functionT('NewBlockCallback');
const RetrieveBalanceActivitiesResult = t__namespace.type({
from: t__namespace.string,
to: t__namespace.string,
}, 'RetrieveBalanceActivitiesResult');
const BlockInfo = tsCommon.requiredOptionalCodec({
id: t__namespace.string,
height: t__namespace.number,
time: tsCommon.DateT,
}, {
previousId: t__namespace.string,
raw: t__namespace.object,
}, 'BlockInfo');
const GetFeeRecommendationOptions = t__namespace.partial({
source: t__namespace.string,
}, 'GetFeeRecommendationOptions');
const bip32 = bip32$1.BIP32Factory(ecc__namespace);

@@ -392,40 +147,4 @@ const ecpair = ecpair$1.ECPairFactory(ecc__namespace);

exports.PaymentsErrorCode = void 0;
(function (PaymentsErrorCode) {
PaymentsErrorCode["TxExpired"] = "PAYMENTS_TX_EXPIRED";
PaymentsErrorCode["TxSequenceTooHigh"] = "PAYMENTS_TX_SEQUENCE_TOO_HIGH";
PaymentsErrorCode["TxSequenceCollision"] = "PAYMENTS_TX_SEQUENCE_COLLISION";
PaymentsErrorCode["TxInsufficientBalance"] = "PAYMENTS_TX_INSUFFICIENT_BALANCE";
PaymentsErrorCode["TxFeeTooHigh"] = "PAYMENTS_TX_FEE_TOO_HIGH";
})(exports.PaymentsErrorCode || (exports.PaymentsErrorCode = {}));
class PaymentsError extends Error {
constructor(code, message) {
super(typeof message === 'undefined' ? code : `${code} - ${message.toString()}`);
this.code = code;
this.name = PaymentsError.name;
}
}
class StandardConnectionManager {
constructor() {
this.connections = {};
}
getConnection(connected) {
return connected.api;
}
getConnectionUrl(config) {
return config.server || null;
}
setConnection(config, connection) {
config.api = connection;
}
}
const DEFAULT_MAX_FEE_PERCENT = 50;
const BIP39_SEED_REGEX = /^[0-9a-f]{128}$/;
const BIP39_SEED_BYTES = 64;
const DERIVATION_PATH_REGEX = /^(m\/)?[0-9]+'?(\/[0-9]+'?)*$/;
function generateNewSeed() {
return crypto__default["default"].randomBytes(BIP39_SEED_BYTES);
return crypto__default["default"].randomBytes(coinlibTypes.BIP39_SEED_BYTES);
}

@@ -515,3 +234,3 @@ function splitDerivationPath(path) {

if (tsCommon.isString(root)) {
if (BIP39_SEED_REGEX.test(root)) {
if (coinlibTypes.BIP39_SEED_REGEX.test(root)) {
return bip32.fromSeed(Buffer.from(root, 'hex'));

@@ -533,4 +252,4 @@ }

else if (root instanceof Buffer) {
if (root.length !== BIP39_SEED_BYTES) {
throw new Error(`Invalid bip39 seed buffer provided with length ${root.length} when ${BIP39_SEED_BYTES} is expected`);
if (root.length !== coinlibTypes.BIP39_SEED_BYTES) {
throw new Error(`Invalid bip39 seed buffer provided with length ${root.length} when ${coinlibTypes.BIP39_SEED_BYTES} is expected`);
}

@@ -545,3 +264,3 @@ return bip32.fromSeed(root);

constructor(root, derivationPath, network) {
if (!DERIVATION_PATH_REGEX.test(derivationPath)) {
if (!coinlibTypes.DERIVATION_PATH_REGEX.test(derivationPath)) {
throw new Error(`Invalid derivation path: ${derivationPath}`);

@@ -580,2 +299,18 @@ }

class StandardConnectionManager {
constructor() {
this.connections = {};
}
getConnection(connected) {
return connected.api;
}
getConnectionUrl(config) {
return config.server || null;
}
setConnection(config, connection) {
config.api = connection;
}
}
exports.ecc = ecc__namespace;
Object.defineProperty(exports, 'BigNumber', {

@@ -585,3 +320,2 @@ enumerable: true,

});
exports.ecc = ecc__namespace;
Object.defineProperty(exports, 'bs58', {

@@ -596,54 +330,5 @@ enumerable: true,

exports.bip39 = bip39__namespace;
exports.AddressMultisigData = AddressMultisigData;
exports.AutoFeeLevels = AutoFeeLevels;
exports.BIP39_SEED_BYTES = BIP39_SEED_BYTES;
exports.BIP39_SEED_REGEX = BIP39_SEED_REGEX;
exports.BalanceActivity = BalanceActivity;
exports.BalanceActivityCallback = BalanceActivityCallback;
exports.BalanceActivityType = BalanceActivityType;
exports.BalanceMonitorConfig = BalanceMonitorConfig;
exports.BalanceResult = BalanceResult;
exports.BaseBroadcastResult = BaseBroadcastResult;
exports.BaseConfig = BaseConfig;
exports.BaseMultisigData = BaseMultisigData;
exports.BaseSignedTransaction = BaseSignedTransaction;
exports.BaseTransactionInfo = BaseTransactionInfo;
exports.BaseUnsignedTransaction = BaseUnsignedTransaction;
exports.BlockInfo = BlockInfo;
exports.CreateTransactionOptions = CreateTransactionOptions;
exports.DEFAULT_MAX_FEE_PERCENT = DEFAULT_MAX_FEE_PERCENT;
exports.DERIVATION_PATH_REGEX = DERIVATION_PATH_REGEX;
exports.DerivablePayport = DerivablePayport;
exports.FeeLevelT = FeeLevelT;
exports.FeeOption = FeeOption;
exports.FeeOptionCustom = FeeOptionCustom;
exports.FeeOptionLevel = FeeOptionLevel;
exports.FeeRate = FeeRate;
exports.FeeRateTypeT = FeeRateTypeT;
exports.FilterChangeAddresses = FilterChangeAddresses;
exports.GetBalanceActivityOptions = GetBalanceActivityOptions;
exports.GetFeeRecommendationOptions = GetFeeRecommendationOptions;
exports.GetPayportOptions = GetPayportOptions;
exports.GetTransactionInfoOptions = GetTransactionInfoOptions;
exports.HdKeyUtils = HdKeyUtils;
exports.KeyPairsConfigParam = KeyPairsConfigParam;
exports.LookupTxDataByHashes = LookupTxDataByHashes;
exports.MultiInputMultisigData = MultiInputMultisigData;
exports.MultisigData = MultisigData;
exports.NetworkTypeT = NetworkTypeT;
exports.NewBlockCallback = NewBlockCallback;
exports.NullableOptionalString = NullableOptionalString;
exports.PaymentsError = PaymentsError;
exports.PaymentsFactory = PaymentsFactory;
exports.Payport = Payport;
exports.PayportOutput = PayportOutput;
exports.ResolveablePayport = ResolveablePayport;
exports.ResolvedFeeOption = ResolvedFeeOption;
exports.RetrieveBalanceActivitiesResult = RetrieveBalanceActivitiesResult;
exports.StandardConnectionManager = StandardConnectionManager;
exports.TransactionCommon = TransactionCommon;
exports.TransactionOutput = TransactionOutput;
exports.TransactionStatusT = TransactionStatusT;
exports.UtxoInfo = UtxoInfo;
exports.WeightedChangeOutput = WeightedChangeOutput;
exports.bip32 = bip32;

@@ -670,2 +355,8 @@ exports.bip32MagicNumberToPrefix = bip32MagicNumberToPrefix;

exports.validateHdKey = validateHdKey;
Object.keys(coinlibTypes).forEach(function (k) {
if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, {
enumerable: true,
get: function () { return coinlibTypes[k]; }
});
});

@@ -672,0 +363,0 @@ Object.defineProperty(exports, '__esModule', { value: true });

2

dist/lib/HdKeyUtils.d.ts
/// <reference types="node" />
import { HDNode } from './SharedDependencies';
import { Bip32Network } from './types';
import { Bip32Network } from '@bitaccess/coinlib-types';
export declare function generateNewSeed(): Buffer;

@@ -5,0 +5,0 @@ export declare function splitDerivationPath(path: string): string[];

import crypto from 'crypto';
import { isString } from '@bitaccess/ts-common';
import { bip32, bip39, bs58 } from './SharedDependencies';
import { BIP39_SEED_REGEX, BIP39_SEED_BYTES, DERIVATION_PATH_REGEX } from './constants';
import { BIP39_SEED_REGEX, BIP39_SEED_BYTES, DERIVATION_PATH_REGEX, } from '@bitaccess/coinlib-types';
export function generateNewSeed() {

@@ -6,0 +6,0 @@ return crypto.randomBytes(BIP39_SEED_BYTES);

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

export * from './types';
export * from './utils';
export * from './BasePayments';
export * from './PaymentsFactory';
export * from './PaymentsUtils';
export * from './BalanceMonitor';
export * from './errors';
export * from './PaymentsConnectionManager';
export * from './StandardConnectionManager';
export * from './constants';
export * from './SharedDependencies';
export * from './HdKeyUtils';
export * from './StandardConnectionManager';
export * from '@bitaccess/coinlib-types';

@@ -1,13 +0,7 @@

export * from './types';
export * from './utils';
export * from './BasePayments';
export * from './PaymentsFactory';
export * from './PaymentsUtils';
export * from './BalanceMonitor';
export * from './errors';
export * from './PaymentsConnectionManager';
export * from './StandardConnectionManager';
export * from './constants';
export * from './SharedDependencies';
export * from './HdKeyUtils';
export * from './StandardConnectionManager';
export * from '@bitaccess/coinlib-types';
//# sourceMappingURL=index.js.map

@@ -1,6 +0,2 @@

import { BalanceMonitor } from './BalanceMonitor';
import { AnyPayments } from './BasePayments';
import { PaymentsConnectionManager } from './PaymentsConnectionManager';
import { PaymentsUtils } from './PaymentsUtils';
import { BaseConfig } from './types';
import { PaymentsConnectionManager, PaymentsUtils, BaseConfig, AnyPayments, BalanceMonitor } from '@bitaccess/coinlib-types';
export declare abstract class PaymentsFactory<C extends BaseConfig = BaseConfig, U extends PaymentsUtils = PaymentsUtils, P extends AnyPayments<C> = AnyPayments<C>, B extends BalanceMonitor = BalanceMonitor> {

@@ -7,0 +3,0 @@ abstract readonly packageName: string;

@@ -1,3 +0,2 @@

import { PaymentsConnectionManager } from './PaymentsConnectionManager';
import { BaseConfig } from './types';
import { BaseConfig, PaymentsConnectionManager } from '@bitaccess/coinlib-types';
export declare class StandardConnectionManager<Connection, Config extends {

@@ -4,0 +3,0 @@ api?: Connection;

{
"name": "@bitaccess/coinlib-common",
"version": "7.0.7",
"version": "7.0.8",
"description": "Common module used by coinlib",

@@ -46,2 +46,3 @@ "main": "dist/index.cjs.js",

"dependencies": {
"@bitaccess/coinlib-types": "^7.0.8",
"@bitaccess/ts-common": "^1.0.2",

@@ -55,3 +56,3 @@ "bip32": "^3.0.1",

},
"gitHead": "56e1f4a5b524fd37d96ea9ea223ddfb1669524bf"
"gitHead": "2ff12321d227d0a92513590fa05c81d9452a368d"
}

@@ -5,4 +5,8 @@ import crypto from 'crypto'

import { bip32, bip39, bs58, HDNode } from './SharedDependencies'
import { Bip32Network } from './types'
import { BIP39_SEED_REGEX, BIP39_SEED_BYTES, DERIVATION_PATH_REGEX } from './constants'
import {
Bip32Network,
BIP39_SEED_REGEX,
BIP39_SEED_BYTES,
DERIVATION_PATH_REGEX,
} from '@bitaccess/coinlib-types'

@@ -9,0 +13,0 @@ export function generateNewSeed(): Buffer {

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

export * from './types'
export * from './utils'
export * from './BasePayments'
export * from './PaymentsFactory'
export * from './PaymentsUtils'
export * from './BalanceMonitor'
export * from './errors'
export * from './PaymentsConnectionManager'
export * from './StandardConnectionManager'
export * from './constants'
export * from './SharedDependencies'
export * from './HdKeyUtils'
export * from './StandardConnectionManager'
export * from '@bitaccess/coinlib-types'

@@ -1,6 +0,8 @@

import { BalanceMonitor } from './BalanceMonitor'
import { AnyPayments } from './BasePayments'
import { PaymentsConnectionManager } from './PaymentsConnectionManager'
import { PaymentsUtils } from './PaymentsUtils'
import { BaseConfig } from './types'
import {
PaymentsConnectionManager,
PaymentsUtils,
BaseConfig,
AnyPayments,
BalanceMonitor,
} from '@bitaccess/coinlib-types'

@@ -7,0 +9,0 @@ /**

@@ -1,6 +0,2 @@

import { PaymentsConnectionManager } from './PaymentsConnectionManager'
import { AnyPayments } from './BasePayments';
import { BaseConfig } from './types';
import { BalanceMonitor } from './BalanceMonitor';
import { PaymentsUtils } from './PaymentsUtils';
import { BaseConfig, PaymentsConnectionManager } from '@bitaccess/coinlib-types'

@@ -7,0 +3,0 @@ export class StandardConnectionManager<

@@ -1,4 +0,3 @@

import { BigNumber, bip32, HDNode, bs58 } from './SharedDependencies'
import { BigNumber } from './SharedDependencies'
import { Numeric } from '@bitaccess/ts-common'
import { Bip32Network } from './types'

@@ -5,0 +4,0 @@ export function isMatchingError(e: Error, partialMessages: string[]) {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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