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.0 to 0.23.2

18

lib/client.d.ts
/// <reference types="node" />
import { AssetInfo, FeeRate, TxHash, TxParams, UTXO, UTXOClient, UtxoClientParams } from '@xchainjs/xchain-client';
import { AssetInfo, FeeRate, PreparedTx, TxHash, TxParams, UTXO, UTXOClient, UtxoClientParams } from '@xchainjs/xchain-client';
import { Address } from '@xchainjs/xchain-util';

@@ -81,2 +81,7 @@ import * as Bitcoin from 'bitcoinjs-lib';

}): Promise<TxHash>;
/**
*
* @param param0
* @deprecated
*/
buildTx({ amount, recipient, memo, feeRate, sender, spendPendingUTXO, }: TxParams & {

@@ -92,3 +97,14 @@ feeRate: FeeRate;

}>;
/**
* Prepare transfer.
*
* @param {TxParams&Address&FeeRate&boolean} params The transfer options.
* @returns {PreparedTx} The raw unsigned transaction.
*/
prepareTx({ sender, memo, amount, recipient, spendPendingUTXO, feeRate, }: TxParams & {
sender: Address;
feeRate: FeeRate;
spendPendingUTXO?: boolean;
}): Promise<PreparedTx>;
}
export { Client };

@@ -313,8 +313,9 @@ import { ExplorerProvider, Network, UTXOClient, FeeOption, checkFeeBounds } from '@xchainjs/xchain-client';

return __awaiter(this, void 0, void 0, function* () {
const fromAddressIndex = (params === null || params === void 0 ? void 0 : params.walletIndex) || 0;
// set the default fee rate to `fast`
const feeRate = params.feeRate || (yield this.getFeeRates())[FeeOption.Fast];
checkFeeBounds(this.feeBounds, feeRate);
const { psbt } = yield this.buildTx(Object.assign(Object.assign({}, params), { feeRate, sender: this.getAddress(fromAddressIndex) }));
const fromAddressIndex = (params === null || params === void 0 ? void 0 : params.walletIndex) || 0;
const { rawUnsignedTx } = yield this.prepareTx(Object.assign(Object.assign({}, params), { sender: this.getAddress(fromAddressIndex), feeRate }));
const btcKeys = this.getBtcKeys(this.phrase, fromAddressIndex);
const psbt = Bitcoin.Psbt.fromBase64(rawUnsignedTx);
psbt.signAllInputs(btcKeys); // Sign all inputs

@@ -334,4 +335,8 @@ psbt.finalizeAllInputs(); // Finalise inputs

}
buildTx({ amount, recipient, memo, feeRate, sender, spendPendingUTXO = true, // default: prevent spending uncomfirmed UTXOs
}) {
/**
*
* @param param0
* @deprecated
*/
buildTx({ amount, recipient, memo, feeRate, sender, spendPendingUTXO = true, }) {
return __awaiter(this, void 0, void 0, function* () {

@@ -391,2 +396,21 @@ if (memo && memo.length > 80) {

}
/**
* Prepare transfer.
*
* @param {TxParams&Address&FeeRate&boolean} params The transfer options.
* @returns {PreparedTx} The raw unsigned transaction.
*/
prepareTx({ sender, memo, amount, recipient, spendPendingUTXO = true, feeRate, }) {
return __awaiter(this, void 0, void 0, function* () {
const { psbt } = yield this.buildTx({
sender,
recipient,
amount,
feeRate,
memo,
spendPendingUTXO,
});
return { rawUnsignedTx: psbt.toBase64() };
});
}
}

@@ -393,0 +417,0 @@

@@ -341,8 +341,9 @@ 'use strict';

return __awaiter(this, void 0, void 0, function* () {
const fromAddressIndex = (params === null || params === void 0 ? void 0 : params.walletIndex) || 0;
// set the default fee rate to `fast`
const feeRate = params.feeRate || (yield this.getFeeRates())[xchainClient.FeeOption.Fast];
xchainClient.checkFeeBounds(this.feeBounds, feeRate);
const { psbt } = yield this.buildTx(Object.assign(Object.assign({}, params), { feeRate, sender: this.getAddress(fromAddressIndex) }));
const fromAddressIndex = (params === null || params === void 0 ? void 0 : params.walletIndex) || 0;
const { rawUnsignedTx } = yield this.prepareTx(Object.assign(Object.assign({}, params), { sender: this.getAddress(fromAddressIndex), feeRate }));
const btcKeys = this.getBtcKeys(this.phrase, fromAddressIndex);
const psbt = Bitcoin__namespace.Psbt.fromBase64(rawUnsignedTx);
psbt.signAllInputs(btcKeys); // Sign all inputs

@@ -362,4 +363,8 @@ psbt.finalizeAllInputs(); // Finalise inputs

}
buildTx({ amount, recipient, memo, feeRate, sender, spendPendingUTXO = true, // default: prevent spending uncomfirmed UTXOs
}) {
/**
*
* @param param0
* @deprecated
*/
buildTx({ amount, recipient, memo, feeRate, sender, spendPendingUTXO = true, }) {
return __awaiter(this, void 0, void 0, function* () {

@@ -419,2 +424,21 @@ if (memo && memo.length > 80) {

}
/**
* Prepare transfer.
*
* @param {TxParams&Address&FeeRate&boolean} params The transfer options.
* @returns {PreparedTx} The raw unsigned transaction.
*/
prepareTx({ sender, memo, amount, recipient, spendPendingUTXO = true, feeRate, }) {
return __awaiter(this, void 0, void 0, function* () {
const { psbt } = yield this.buildTx({
sender,
recipient,
amount,
feeRate,
memo,
spendPendingUTXO,
});
return { rawUnsignedTx: psbt.toBase64() };
});
}
}

@@ -421,0 +445,0 @@

6

package.json
{
"name": "@xchainjs/xchain-bitcoin",
"version": "0.23.0",
"version": "0.23.2",
"description": "Custom Bitcoin client and utilities used by XChainJS clients",

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

"@types/wif": "^2.0.2",
"@xchainjs/xchain-client": "^0.15.0",
"@xchainjs/xchain-client": "^0.15.1",
"@xchainjs/xchain-crypto": "^0.3.0",

@@ -49,3 +49,3 @@ "@xchainjs/xchain-util": "^0.13.1",

"peerDependencies": {
"@xchainjs/xchain-client": "^0.15.0",
"@xchainjs/xchain-client": "^0.15.1",
"@xchainjs/xchain-crypto": "^0.3.0",

@@ -52,0 +52,0 @@ "@xchainjs/xchain-util": "^0.13.1",

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