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

@xchainjs/xchain-bitcoin

Package Overview
Dependencies
Maintainers
10
Versions
91
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@xchainjs/xchain-bitcoin - npm Package Compare versions

Comparing version 0.23.4 to 0.23.6

1

lib/client.d.ts

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

validateAddress(address: string): boolean;
protected getSuggestedFeeRate(): Promise<FeeRate>;
/**

@@ -60,0 +59,0 @@ * Compile memo.

3

lib/const.d.ts

@@ -11,3 +11,3 @@ import { ExplorerProvider, UtxoOnlineDataProviders } from '@xchainjs/xchain-client';

export declare const LOWER_FEE_BOUND = 1;
export declare const UPPER_FEE_BOUND = 500;
export declare const UPPER_FEE_BOUND = 1000;
export declare const BTC_SYMBOL = "\u20BF";

@@ -35,1 +35,2 @@ export declare const BTC_SATOSHI_SYMBOL = "\u26A1";

export declare const BlockcypherDataProviders: UtxoOnlineDataProviders;
export declare const BitgoProviders: UtxoOnlineDataProviders;
import { ExplorerProvider, Network, UTXOClient, FeeOption, checkFeeBounds } from '@xchainjs/xchain-client';
import { getSeed } from '@xchainjs/xchain-crypto';
import axios from 'axios';
import * as Bitcoin from 'bitcoinjs-lib';
import accumulative from 'coinselect/accumulative';
import { SochainProvider, SochainNetwork, HaskoinProvider, HaskoinNetwork, BlockcypherProvider, BlockcypherNetwork } from '@xchainjs/xchain-utxo-providers';
import { SochainProvider, SochainNetwork, HaskoinProvider, HaskoinNetwork, BlockcypherProvider, BlockcypherNetwork, BitgoProvider } from '@xchainjs/xchain-utxo-providers';

@@ -41,3 +40,3 @@ /******************************************************************************

const LOWER_FEE_BOUND = 1;
const UPPER_FEE_BOUND = 500;
const UPPER_FEE_BOUND = 1000;
const BTC_SYMBOL = '₿';

@@ -67,4 +66,4 @@ const BTC_SATOSHI_SYMBOL = '⚡';

//======================
const testnetSochainProvider = new SochainProvider('https://sochain.com/api/v3', process.env['SOCHAIN_API_KEY'] || '', BTCChain, AssetBTC, 8, SochainNetwork.BTCTEST);
const mainnetSochainProvider = new SochainProvider('https://sochain.com/api/v3', process.env['SOCHAIN_API_KEY'] || '', BTCChain, AssetBTC, 8, SochainNetwork.BTC);
const testnetSochainProvider = new SochainProvider('https://sochain.com/api/v3', process.env.SOCHAIN_API_KEY || '', BTCChain, AssetBTC, 8, SochainNetwork.BTCTEST);
const mainnetSochainProvider = new SochainProvider('https://sochain.com/api/v3', process.env.SOCHAIN_API_KEY || '', BTCChain, AssetBTC, 8, SochainNetwork.BTC);
const SochainDataProviders = {

@@ -88,4 +87,4 @@ [Network.Testnet]: testnetSochainProvider,

//======================
const testnetBlockcypherProvider = new BlockcypherProvider('https://api.blockcypher.com/v1', BTCChain, AssetBTC, 8, BlockcypherNetwork.BTCTEST, process.env['BlOCKCYPHER_API_KEY'] || '');
const mainnetBlockcypherProvider = new BlockcypherProvider('https://api.blockcypher.com/v1', BTCChain, AssetBTC, 8, BlockcypherNetwork.BTC, process.env['BlOCKCYPHER_API_KEY'] || '');
const testnetBlockcypherProvider = new BlockcypherProvider('https://api.blockcypher.com/v1', BTCChain, AssetBTC, 8, BlockcypherNetwork.BTCTEST, process.env.BLOCKCYPHER_API_KEY || '');
const mainnetBlockcypherProvider = new BlockcypherProvider('https://api.blockcypher.com/v1', BTCChain, AssetBTC, 8, BlockcypherNetwork.BTC, process.env.BLOCKCYPHER_API_KEY || '');
const BlockcypherDataProviders = {

@@ -96,2 +95,14 @@ [Network.Testnet]: testnetBlockcypherProvider,

};
//======================
// Bitgo
//======================
const mainnetBitgoProvider = new BitgoProvider({
baseUrl: 'https://app.bitgo.com',
chain: BTCChain,
});
const BitgoProviders = {
[Network.Testnet]: undefined,
[Network.Stagenet]: mainnetBitgoProvider,
[Network.Mainnet]: mainnetBitgoProvider,
};

@@ -155,3 +166,2 @@ const TX_EMPTY_SIZE = 4 + 1 + 1 + 4; //10

const DEFAULT_SUGGESTED_TRANSACTION_FEE = 127;
const defaultBTCParams = {

@@ -161,3 +171,3 @@ network: Network.Mainnet,

explorerProviders: blockstreamExplorerProviders,
dataProviders: [BlockcypherDataProviders],
dataProviders: [BitgoProviders, BlockcypherDataProviders],
rootDerivationPaths: {

@@ -270,15 +280,2 @@ [Network.Mainnet]: `84'/0'/0'/0/`,

}
getSuggestedFeeRate() {
return __awaiter(this, void 0, void 0, function* () {
//use Bitgo API for fee estimation
//Refer: https://app.bitgo.com/docs/#operation/v2.tx.getfeeestimate
try {
const response = yield axios.get('https://app.bitgo.com/api/v2/btc/tx/fee');
return response.data.feePerKb / 1000; // feePerKb to feePerByte
}
catch (error) {
return DEFAULT_SUGGESTED_TRANSACTION_FEE;
}
});
}
/**

@@ -430,3 +427,3 @@ * Compile memo.

export { AssetBTC, BTCChain, BTC_DECIMAL, BTC_SATOSHI_SYMBOL, BTC_SYMBOL, BlockcypherDataProviders, Client, HaskoinDataProviders, LOWER_FEE_BOUND, MIN_TX_FEE, SochainDataProviders, UPPER_FEE_BOUND, blockstreamExplorerProviders, defaultBTCParams, getPrefix, validateAddress };
export { AssetBTC, BTCChain, BTC_DECIMAL, BTC_SATOSHI_SYMBOL, BTC_SYMBOL, BitgoProviders, BlockcypherDataProviders, Client, HaskoinDataProviders, LOWER_FEE_BOUND, MIN_TX_FEE, SochainDataProviders, UPPER_FEE_BOUND, blockstreamExplorerProviders, defaultBTCParams, getPrefix, validateAddress };
//# sourceMappingURL=index.esm.js.map

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

var xchainCrypto = require('@xchainjs/xchain-crypto');
var axios = require('axios');
var Bitcoin = require('bitcoinjs-lib');

@@ -33,3 +32,2 @@ var accumulative = require('coinselect/accumulative');

var axios__default = /*#__PURE__*/_interopDefaultLegacy(axios);
var Bitcoin__namespace = /*#__PURE__*/_interopNamespace(Bitcoin);

@@ -71,3 +69,3 @@ var accumulative__default = /*#__PURE__*/_interopDefaultLegacy(accumulative);

const LOWER_FEE_BOUND = 1;
const UPPER_FEE_BOUND = 500;
const UPPER_FEE_BOUND = 1000;
const BTC_SYMBOL = '₿';

@@ -97,4 +95,4 @@ const BTC_SATOSHI_SYMBOL = '⚡';

//======================
const testnetSochainProvider = new xchainUtxoProviders.SochainProvider('https://sochain.com/api/v3', process.env['SOCHAIN_API_KEY'] || '', BTCChain, AssetBTC, 8, xchainUtxoProviders.SochainNetwork.BTCTEST);
const mainnetSochainProvider = new xchainUtxoProviders.SochainProvider('https://sochain.com/api/v3', process.env['SOCHAIN_API_KEY'] || '', BTCChain, AssetBTC, 8, xchainUtxoProviders.SochainNetwork.BTC);
const testnetSochainProvider = new xchainUtxoProviders.SochainProvider('https://sochain.com/api/v3', process.env.SOCHAIN_API_KEY || '', BTCChain, AssetBTC, 8, xchainUtxoProviders.SochainNetwork.BTCTEST);
const mainnetSochainProvider = new xchainUtxoProviders.SochainProvider('https://sochain.com/api/v3', process.env.SOCHAIN_API_KEY || '', BTCChain, AssetBTC, 8, xchainUtxoProviders.SochainNetwork.BTC);
const SochainDataProviders = {

@@ -118,4 +116,4 @@ [xchainClient.Network.Testnet]: testnetSochainProvider,

//======================
const testnetBlockcypherProvider = new xchainUtxoProviders.BlockcypherProvider('https://api.blockcypher.com/v1', BTCChain, AssetBTC, 8, xchainUtxoProviders.BlockcypherNetwork.BTCTEST, process.env['BlOCKCYPHER_API_KEY'] || '');
const mainnetBlockcypherProvider = new xchainUtxoProviders.BlockcypherProvider('https://api.blockcypher.com/v1', BTCChain, AssetBTC, 8, xchainUtxoProviders.BlockcypherNetwork.BTC, process.env['BlOCKCYPHER_API_KEY'] || '');
const testnetBlockcypherProvider = new xchainUtxoProviders.BlockcypherProvider('https://api.blockcypher.com/v1', BTCChain, AssetBTC, 8, xchainUtxoProviders.BlockcypherNetwork.BTCTEST, process.env.BLOCKCYPHER_API_KEY || '');
const mainnetBlockcypherProvider = new xchainUtxoProviders.BlockcypherProvider('https://api.blockcypher.com/v1', BTCChain, AssetBTC, 8, xchainUtxoProviders.BlockcypherNetwork.BTC, process.env.BLOCKCYPHER_API_KEY || '');
const BlockcypherDataProviders = {

@@ -126,2 +124,14 @@ [xchainClient.Network.Testnet]: testnetBlockcypherProvider,

};
//======================
// Bitgo
//======================
const mainnetBitgoProvider = new xchainUtxoProviders.BitgoProvider({
baseUrl: 'https://app.bitgo.com',
chain: BTCChain,
});
const BitgoProviders = {
[xchainClient.Network.Testnet]: undefined,
[xchainClient.Network.Stagenet]: mainnetBitgoProvider,
[xchainClient.Network.Mainnet]: mainnetBitgoProvider,
};

@@ -185,3 +195,2 @@ const TX_EMPTY_SIZE = 4 + 1 + 1 + 4; //10

const DEFAULT_SUGGESTED_TRANSACTION_FEE = 127;
const defaultBTCParams = {

@@ -191,3 +200,3 @@ network: xchainClient.Network.Mainnet,

explorerProviders: blockstreamExplorerProviders,
dataProviders: [BlockcypherDataProviders],
dataProviders: [BitgoProviders, BlockcypherDataProviders],
rootDerivationPaths: {

@@ -300,15 +309,2 @@ [xchainClient.Network.Mainnet]: `84'/0'/0'/0/`,

}
getSuggestedFeeRate() {
return __awaiter(this, void 0, void 0, function* () {
//use Bitgo API for fee estimation
//Refer: https://app.bitgo.com/docs/#operation/v2.tx.getfeeestimate
try {
const response = yield axios__default["default"].get('https://app.bitgo.com/api/v2/btc/tx/fee');
return response.data.feePerKb / 1000; // feePerKb to feePerByte
}
catch (error) {
return DEFAULT_SUGGESTED_TRANSACTION_FEE;
}
});
}
/**

@@ -465,2 +461,3 @@ * Compile memo.

exports.BTC_SYMBOL = BTC_SYMBOL;
exports.BitgoProviders = BitgoProviders;
exports.BlockcypherDataProviders = BlockcypherDataProviders;

@@ -467,0 +464,0 @@ exports.Client = Client;

{
"name": "@xchainjs/xchain-bitcoin",
"version": "0.23.4",
"version": "0.23.6",
"description": "Custom Bitcoin client and utilities used by XChainJS clients",

@@ -37,6 +37,6 @@ "keywords": [

"@types/wif": "^2.0.2",
"@xchainjs/xchain-client": "^0.15.3",
"@xchainjs/xchain-client": "^0.15.4",
"@xchainjs/xchain-crypto": "^0.3.0",
"@xchainjs/xchain-util": "^0.13.1",
"@xchainjs/xchain-utxo-providers": "^0.2.7",
"@xchainjs/xchain-utxo-providers": "^0.2.8",
"axios": "^1.3.6",

@@ -49,6 +49,6 @@ "axios-mock-adapter": "^1.20.0",

"peerDependencies": {
"@xchainjs/xchain-client": "^0.15.3",
"@xchainjs/xchain-client": "^0.15.4",
"@xchainjs/xchain-crypto": "^0.3.0",
"@xchainjs/xchain-util": "^0.13.1",
"@xchainjs/xchain-utxo-providers": "^0.2.7",
"@xchainjs/xchain-utxo-providers": "^0.2.8",
"axios": "^1.3.6",

@@ -62,2 +62,2 @@ "bitcoinjs-lib": "5.2.0",

}
}
}

@@ -102,10 +102,10 @@ # `@xchainjs/xchain-bitcoin`

// override with your API key
SochainDataProviders[Network.Mainnet].apiKey = 'YOU_SOCHAIN_API_KEY'
SochainDataProviders[Network.Mainnet].apiKey = 'YOUR_SOCHAIN_API_KEY'
// or set in env variables so default config can access.
`SOCHAIN_API_KEY={YOURKEY}`
`BLOCKCYPHER_API_KEY={YOURKEY}`
`SOCHAIN_API_KEY={YOUR_SOCHAIN_API_KEY}`
`BLOCKCYPHER_API_KEY={YOUR_BLOCKCYPHER_API_KEY}`
//Default config can access.
process.env["BLOCKCYPHER_API_KEY"]
process.env["SOCHAIN_API_KEY"]
process.env.BLOCKCYPHER_API_KEY
process.env.SOCHAIN_API_KEY

@@ -116,3 +116,3 @@ //overridde the default init params with your onfig

dataProviders: [SochainDataProviders, BlockcypherDataProviders]// use sochain first and blockcypher as fallback
phrase: process.env.YOURPHRASE,
phrase: process.env.PHRASE,
}

@@ -119,0 +119,0 @@ const btcClient = new Client(sochainParams)

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