New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

sbtc-bridge-lib

Package Overview
Dependencies
Maintainers
1
Versions
127
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sbtc-bridge-lib - npm Package Compare versions

Comparing version 1.0.80 to 1.0.81

4

dist/deposit_utils.js

@@ -27,3 +27,3 @@ import * as btc from '@scure/btc-signer';

// no reveal fee for op_return
addInputs(network, uiPayload.amountSats, 0, tx, false, addressInfo.utxos, uiPayload.userPaymentPubKey);
addInputs(network, uiPayload.amountSats, 0, tx, false, addressInfo.utxos, uiPayload.paymentPublicKey);
tx.addOutput({ script: btc.Script.encode(['RETURN', data]), amount: BigInt(0) });

@@ -48,3 +48,3 @@ tx.addOutputAddress(sbtcWalletAddress, BigInt(uiPayload.amountSats), net);

const tx = new btc.Transaction({ allowUnknowInput: true, allowUnknowOutput: true, allowUnknownInputs: true, allowUnknownOutputs: true });
addInputs(network, uiPayload.amountSats, revealPayment, tx, false, addressInfo.utxos, uiPayload.userPaymentPubKey);
addInputs(network, uiPayload.amountSats, revealPayment, tx, false, addressInfo.utxos, uiPayload.paymentPublicKey);
tx.addOutputAddress(commitTxAddress, BigInt(uiPayload.amountSats), net);

@@ -51,0 +51,0 @@ const changeAmount = inputAmt(tx) - (uiPayload.amountSats + txFees[1]);

@@ -263,3 +263,3 @@ export type SbtcMiniContractsI = {

bitcoinAddress: string;
userPaymentPubKey: string;
paymentPublicKey: string;
principal: string;

@@ -273,5 +273,5 @@ amountSats: number;

signature?: string | undefined;
userPaymentPubKey: string;
paymentPublicKey: string;
principal: string;
amountSats: number;
};

@@ -26,4 +26,4 @@ import * as btc from '@scure/btc-signer';

* @param utxos - the utxos being spent from
* @param userPaymentPubKey - pubkey used in script hash payments
export function addInputs (network:string, amount:number, revealPayment:number, tx:btc.Transaction, feeCalc:boolean, utxos:Array<UTXO>, userPaymentPubKey:string, userSchnorrPubKey:string) {
* @param paymentPublicKey - pubkey used in script hash payments
export function addInputs (network:string, amount:number, revealPayment:number, tx:btc.Transaction, feeCalc:boolean, utxos:Array<UTXO>, paymentPublicKey:string, userSchnorrPubKey:string) {
const bar = revealPayment + amount;

@@ -50,9 +50,9 @@ let amt = 0;

if (wrappedType === 'witness_v0_keyhash') {
p2shObj = btc.p2sh(btc.p2wpkh(hex.decode(userPaymentPubKey)), net)
p2shObj = btc.p2sh(btc.p2wpkh(hex.decode(paymentPublicKey)), net)
} else if (wrappedType === 'witness_v1_taproot') {
p2shObj = btc.p2sh(btc.p2tr(hex.decode(userSchnorrPubKey)), net)
} else if (wrappedType.indexOf('multi') > -1) {
p2shObj = btc.p2sh(btc.p2ms(1, [hex.decode(userPaymentPubKey)]), net)
p2shObj = btc.p2sh(btc.p2ms(1, [hex.decode(paymentPublicKey)]), net)
} else {
p2shObj = btc.p2sh(btc.p2pkh(hex.decode(userPaymentPubKey)), net)
p2shObj = btc.p2sh(btc.p2pkh(hex.decode(paymentPublicKey)), net)
}

@@ -89,3 +89,3 @@ const nextI:btc.TransactionInput = {

*/
export declare function addInputs(network: string, amount: number, revealPayment: number, transaction: btc.Transaction, feeCalc: boolean, utxos: Array<UTXO>, userPaymentPubKey: string): void;
export declare function addInputs(network: string, amount: number, revealPayment: number, transaction: btc.Transaction, feeCalc: boolean, utxos: Array<UTXO>, paymentPublicKey: string): void;
export declare function getAddressFromOutScript(network: string, script: Uint8Array): string;

@@ -92,0 +92,0 @@ export declare function inputAmt(tx: btc.Transaction): number;

@@ -118,4 +118,4 @@ import * as secp from '@noble/secp256k1';

* @param utxos - the utxos being spent from
* @param userPaymentPubKey - pubkey used in script hash payments
export function addInputs (network:string, amount:number, revealPayment:number, tx:btc.Transaction, feeCalc:boolean, utxos:Array<UTXO>, userPaymentPubKey:string, userSchnorrPubKey:string) {
* @param paymentPublicKey - pubkey used in script hash payments
export function addInputs (network:string, amount:number, revealPayment:number, tx:btc.Transaction, feeCalc:boolean, utxos:Array<UTXO>, paymentPublicKey:string, userSchnorrPubKey:string) {
const bar = revealPayment + amount;

@@ -142,9 +142,9 @@ let amt = 0;

if (wrappedType === 'witness_v0_keyhash') {
p2shObj = btc.p2sh(btc.p2wpkh(hex.decode(userPaymentPubKey)), net)
p2shObj = btc.p2sh(btc.p2wpkh(hex.decode(paymentPublicKey)), net)
} else if (wrappedType === 'witness_v1_taproot') {
p2shObj = btc.p2sh(btc.p2tr(hex.decode(userSchnorrPubKey)), net)
} else if (wrappedType.indexOf('multi') > -1) {
p2shObj = btc.p2sh(btc.p2ms(1, [hex.decode(userPaymentPubKey)]), net)
p2shObj = btc.p2sh(btc.p2ms(1, [hex.decode(paymentPublicKey)]), net)
} else {
p2shObj = btc.p2sh(btc.p2pkh(hex.decode(userPaymentPubKey)), net)
p2shObj = btc.p2sh(btc.p2pkh(hex.decode(paymentPublicKey)), net)
}

@@ -181,3 +181,3 @@ const nextI:btc.TransactionInput = {

*/
export function addInputs(network, amount, revealPayment, transaction, feeCalc, utxos, userPaymentPubKey) {
export function addInputs(network, amount, revealPayment, transaction, feeCalc, utxos, paymentPublicKey) {
const net = (network === 'testnet') ? btc.TEST_NETWORK : btc.NETWORK;

@@ -203,21 +203,21 @@ const bar = revealPayment + amount;

if (i === 0) {
p2shObj = btc.p2sh(btc.p2wpkh(hex.decode(userPaymentPubKey)), net);
p2shObj = btc.p2sh(btc.p2wpkh(hex.decode(paymentPublicKey)), net);
}
else if (i === 1) {
p2shObj = btc.p2sh(btc.p2wsh(btc.p2wpkh(hex.decode(userPaymentPubKey))), net);
p2shObj = btc.p2sh(btc.p2wsh(btc.p2wpkh(hex.decode(paymentPublicKey))), net);
}
else if (i === 2) {
p2shObj = btc.p2sh(btc.p2wsh(btc.p2pkh(hex.decode(userPaymentPubKey)), net));
p2shObj = btc.p2sh(btc.p2wsh(btc.p2pkh(hex.decode(paymentPublicKey)), net));
}
else if (i === 3) {
p2shObj = btc.p2sh(btc.p2ms(1, [hex.decode(userPaymentPubKey)]), net);
p2shObj = btc.p2sh(btc.p2ms(1, [hex.decode(paymentPublicKey)]), net);
}
else if (i === 4) {
p2shObj = btc.p2sh(btc.p2pkh(hex.decode(userPaymentPubKey)), net);
p2shObj = btc.p2sh(btc.p2pkh(hex.decode(paymentPublicKey)), net);
}
else if (i === 5) {
p2shObj = btc.p2sh(btc.p2sh(btc.p2pkh(hex.decode(userPaymentPubKey)), net));
p2shObj = btc.p2sh(btc.p2sh(btc.p2pkh(hex.decode(paymentPublicKey)), net));
}
else if (i === 6) {
p2shObj = btc.p2sh(btc.p2sh(btc.p2wpkh(hex.decode(userPaymentPubKey)), net));
p2shObj = btc.p2sh(btc.p2sh(btc.p2wpkh(hex.decode(paymentPublicKey)), net));
}

@@ -250,3 +250,3 @@ if (i < 3) {

else if (spendScr.type === 'wsh') {
//const p2shObj = btc.p2wsh(btc.p2wpkh(hex.decode(userPaymentPubKey), net))
//const p2shObj = btc.p2wsh(btc.p2wpkh(hex.decode(paymentPublicKey), net))
let witnessUtxo = {

@@ -271,3 +271,3 @@ script: script.outputs[utxo.vout].script,

else if (spendScr.type === 'pkh') {
//const p2shObj = btc.p2pkh(hex.decode(userPaymentPubKey), net)
//const p2shObj = btc.p2pkh(hex.decode(paymentPublicKey), net)
const nextI = {

@@ -282,3 +282,3 @@ txid: hex.decode(utxo.txid),

else {
//const p2shObj = btc.p2wpkh(hex.decode(userPaymentPubKey), net)
//const p2shObj = btc.p2wpkh(hex.decode(paymentPublicKey), net)
const nextI = {

@@ -285,0 +285,0 @@ txid: hex.decode(utxo.txid),

@@ -12,3 +12,3 @@ import * as btc from '@scure/btc-signer';

high_fee_per_kb: number;
}, sbtcWalletAddress: string, changeAddress: string, userPaymentPubKey: string, data: Uint8Array | undefined): number[];
}, sbtcWalletAddress: string, changeAddress: string, paymentPublicKey: string, data: Uint8Array | undefined): number[];
export declare function getWithdrawScript(network: string, data: Uint8Array, sbtcWalletAddress: string, fromBtcAddress: string): {

@@ -15,0 +15,0 @@ type: string;

@@ -17,5 +17,5 @@ import * as btc from '@scure/btc-signer';

const data = buildData(network, uiPayload.amountSats, uiPayload.signature, false);
const txFees = calculateWithdrawFees(network, false, addressInfo, uiPayload.amountSats, btcFeeRates, sbtcWalletAddress, uiPayload.bitcoinAddress, uiPayload.userPaymentPubKey, data);
const txFees = calculateWithdrawFees(network, false, addressInfo, uiPayload.amountSats, btcFeeRates, sbtcWalletAddress, uiPayload.bitcoinAddress, uiPayload.paymentPublicKey, data);
const tx = new btc.Transaction({ allowUnknowOutput: true, allowUnknownInputs: true, allowUnknownOutputs: true });
addInputs(network, uiPayload.amountSats, revealPayment, tx, false, addressInfo.utxos, uiPayload.userPaymentPubKey);
addInputs(network, uiPayload.amountSats, revealPayment, tx, false, addressInfo.utxos, uiPayload.paymentPublicKey);
tx.addOutput({ script: btc.Script.encode(['RETURN', data]), amount: BigInt(0) });

@@ -33,5 +33,5 @@ const change = inputAmt(tx) - (dust + txFees[1]);

const sbtcWalletAddress = getPegWalletAddressFromPublicKey(network, uiPayload.sbtcWalletPublicKey);
const txFees = calculateWithdrawFees(network, true, addressInfo, uiPayload.amountSats, btcFeeRates, sbtcWalletAddress, uiPayload.bitcoinAddress, uiPayload.userPaymentPubKey, undefined);
const txFees = calculateWithdrawFees(network, true, addressInfo, uiPayload.amountSats, btcFeeRates, sbtcWalletAddress, uiPayload.bitcoinAddress, uiPayload.paymentPublicKey, undefined);
const tx = new btc.Transaction({ allowUnknowOutput: true, allowUnknownInputs: true, allowUnknownOutputs: true });
addInputs(network, uiPayload.amountSats, revealPayment, tx, false, addressInfo.utxos, uiPayload.userPaymentPubKey);
addInputs(network, uiPayload.amountSats, revealPayment, tx, false, addressInfo.utxos, uiPayload.paymentPublicKey);
const data = buildData(network, uiPayload.amountSats, uiPayload.signature, true);

@@ -52,3 +52,3 @@ const csvScript = getWithdrawScript(network, data, sbtcWalletAddress, uiPayload.bitcoinAddress);

}
export function calculateWithdrawFees(network, opDrop, addressInfo, amount, feeInfo, sbtcWalletAddress, changeAddress, userPaymentPubKey, data) {
export function calculateWithdrawFees(network, opDrop, addressInfo, amount, feeInfo, sbtcWalletAddress, changeAddress, paymentPublicKey, data) {
try {

@@ -58,3 +58,3 @@ let vsize = 0;

const tx = new btc.Transaction({ allowUnknowOutput: true, allowUnknownInputs: true, allowUnknownOutputs: true });
addInputs(network, amount, revealPayment, tx, true, addressInfo.utxos, userPaymentPubKey);
addInputs(network, amount, revealPayment, tx, true, addressInfo.utxos, paymentPublicKey);
if (!opDrop) {

@@ -61,0 +61,0 @@ if (data)

{
"name": "sbtc-bridge-lib",
"version": "1.0.80",
"version": "1.0.81",
"description": "Library for sBTC Bridge web client and API apps ",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -30,3 +30,3 @@ import * as btc from '@scure/btc-signer';

// no reveal fee for op_return
addInputs(network, uiPayload.amountSats, 0, tx, false, addressInfo.utxos, uiPayload.userPaymentPubKey);
addInputs(network, uiPayload.amountSats, 0, tx, false, addressInfo.utxos, uiPayload.paymentPublicKey);
tx.addOutput({ script: btc.Script.encode(['RETURN', data]), amount: BigInt(0) });

@@ -51,3 +51,3 @@ tx.addOutputAddress(sbtcWalletAddress, BigInt(uiPayload.amountSats), net);

const tx = new btc.Transaction({ allowUnknowInput: true, allowUnknowOutput: true, allowUnknownInputs:true, allowUnknownOutputs:true });
addInputs(network, uiPayload.amountSats, revealPayment, tx, false, addressInfo.utxos, uiPayload.userPaymentPubKey);
addInputs(network, uiPayload.amountSats, revealPayment, tx, false, addressInfo.utxos, uiPayload.paymentPublicKey);
tx.addOutputAddress(commitTxAddress, BigInt(uiPayload.amountSats), net );

@@ -54,0 +54,0 @@ const changeAmount = inputAmt(tx) - (uiPayload.amountSats + txFees[1]);

@@ -262,3 +262,3 @@ export type SbtcMiniContractsI = {

bitcoinAddress:string;
userPaymentPubKey: string;
paymentPublicKey: string;
principal:string;

@@ -272,5 +272,5 @@ amountSats:number;

signature?: string|undefined;
userPaymentPubKey: string;
paymentPublicKey: string;
principal:string;
amountSats:number;
}

@@ -118,4 +118,4 @@ import * as secp from '@noble/secp256k1';

* @param utxos - the utxos being spent from
* @param userPaymentPubKey - pubkey used in script hash payments
export function addInputs (network:string, amount:number, revealPayment:number, tx:btc.Transaction, feeCalc:boolean, utxos:Array<UTXO>, userPaymentPubKey:string, userSchnorrPubKey:string) {
* @param paymentPublicKey - pubkey used in script hash payments
export function addInputs (network:string, amount:number, revealPayment:number, tx:btc.Transaction, feeCalc:boolean, utxos:Array<UTXO>, paymentPublicKey:string, userSchnorrPubKey:string) {
const bar = revealPayment + amount;

@@ -142,9 +142,9 @@ let amt = 0;

if (wrappedType === 'witness_v0_keyhash') {
p2shObj = btc.p2sh(btc.p2wpkh(hex.decode(userPaymentPubKey)), net)
p2shObj = btc.p2sh(btc.p2wpkh(hex.decode(paymentPublicKey)), net)
} else if (wrappedType === 'witness_v1_taproot') {
p2shObj = btc.p2sh(btc.p2tr(hex.decode(userSchnorrPubKey)), net)
} else if (wrappedType.indexOf('multi') > -1) {
p2shObj = btc.p2sh(btc.p2ms(1, [hex.decode(userPaymentPubKey)]), net)
p2shObj = btc.p2sh(btc.p2ms(1, [hex.decode(paymentPublicKey)]), net)
} else {
p2shObj = btc.p2sh(btc.p2pkh(hex.decode(userPaymentPubKey)), net)
p2shObj = btc.p2sh(btc.p2pkh(hex.decode(paymentPublicKey)), net)
}

@@ -181,3 +181,3 @@ const nextI:btc.TransactionInput = {

*/
export function addInputs (network:string, amount:number, revealPayment:number, transaction:btc.Transaction, feeCalc:boolean, utxos:Array<UTXO>, userPaymentPubKey:string) {
export function addInputs (network:string, amount:number, revealPayment:number, transaction:btc.Transaction, feeCalc:boolean, utxos:Array<UTXO>, paymentPublicKey:string) {
const net = (network === 'testnet') ? btc.TEST_NETWORK : btc.NETWORK;

@@ -202,15 +202,15 @@ const bar = revealPayment + amount;

if (i === 0) {
p2shObj = btc.p2sh(btc.p2wpkh(hex.decode(userPaymentPubKey)), net)
p2shObj = btc.p2sh(btc.p2wpkh(hex.decode(paymentPublicKey)), net)
} else if (i === 1) {
p2shObj = btc.p2sh(btc.p2wsh(btc.p2wpkh(hex.decode(userPaymentPubKey))), net)
p2shObj = btc.p2sh(btc.p2wsh(btc.p2wpkh(hex.decode(paymentPublicKey))), net)
} else if (i === 2) {
p2shObj = btc.p2sh(btc.p2wsh(btc.p2pkh(hex.decode(userPaymentPubKey)), net))
p2shObj = btc.p2sh(btc.p2wsh(btc.p2pkh(hex.decode(paymentPublicKey)), net))
} else if (i === 3) {
p2shObj = btc.p2sh(btc.p2ms(1, [hex.decode(userPaymentPubKey)]), net)
p2shObj = btc.p2sh(btc.p2ms(1, [hex.decode(paymentPublicKey)]), net)
} else if (i === 4) {
p2shObj = btc.p2sh(btc.p2pkh(hex.decode(userPaymentPubKey)), net)
p2shObj = btc.p2sh(btc.p2pkh(hex.decode(paymentPublicKey)), net)
} else if (i === 5) {
p2shObj = btc.p2sh(btc.p2sh(btc.p2pkh(hex.decode(userPaymentPubKey)), net))
p2shObj = btc.p2sh(btc.p2sh(btc.p2pkh(hex.decode(paymentPublicKey)), net))
} else if (i === 6) {
p2shObj = btc.p2sh(btc.p2sh(btc.p2wpkh(hex.decode(userPaymentPubKey)), net))
p2shObj = btc.p2sh(btc.p2sh(btc.p2wpkh(hex.decode(paymentPublicKey)), net))
}

@@ -244,3 +244,3 @@ if (i < 3) {

} else if (spendScr.type === 'wsh') {
//const p2shObj = btc.p2wsh(btc.p2wpkh(hex.decode(userPaymentPubKey), net))
//const p2shObj = btc.p2wsh(btc.p2wpkh(hex.decode(paymentPublicKey), net))
let witnessUtxo = {

@@ -264,3 +264,3 @@ script: script.outputs[utxo.vout].script,

} else if (spendScr.type === 'pkh') {
//const p2shObj = btc.p2pkh(hex.decode(userPaymentPubKey), net)
//const p2shObj = btc.p2pkh(hex.decode(paymentPublicKey), net)
const nextI:btc.TransactionInput = {

@@ -274,3 +274,3 @@ txid: hex.decode(utxo.txid),

} else {
//const p2shObj = btc.p2wpkh(hex.decode(userPaymentPubKey), net)
//const p2shObj = btc.p2wpkh(hex.decode(paymentPublicKey), net)
const nextI:btc.TransactionInput = {

@@ -277,0 +277,0 @@ txid: hex.decode(utxo.txid),

@@ -21,5 +21,5 @@ import * as btc from '@scure/btc-signer';

const data = buildData(network, uiPayload.amountSats, uiPayload.signature, false)
const txFees = calculateWithdrawFees(network, false, addressInfo, uiPayload.amountSats, btcFeeRates, sbtcWalletAddress, uiPayload.bitcoinAddress, uiPayload.userPaymentPubKey, data)
const txFees = calculateWithdrawFees(network, false, addressInfo, uiPayload.amountSats, btcFeeRates, sbtcWalletAddress, uiPayload.bitcoinAddress, uiPayload.paymentPublicKey, data)
const tx = new btc.Transaction({ allowUnknowOutput: true, allowUnknownInputs:true, allowUnknownOutputs:true });
addInputs(network, uiPayload.amountSats, revealPayment, tx, false, addressInfo.utxos, uiPayload.userPaymentPubKey);
addInputs(network, uiPayload.amountSats, revealPayment, tx, false, addressInfo.utxos, uiPayload.paymentPublicKey);
tx.addOutput({ script: btc.Script.encode(['RETURN', data]), amount: BigInt(0) });

@@ -36,5 +36,5 @@ const change = inputAmt(tx) - (dust + txFees[1]);

const sbtcWalletAddress = getPegWalletAddressFromPublicKey(network, uiPayload.sbtcWalletPublicKey)
const txFees = calculateWithdrawFees(network, true, addressInfo, uiPayload.amountSats, btcFeeRates, sbtcWalletAddress, uiPayload.bitcoinAddress, uiPayload.userPaymentPubKey, undefined)
const txFees = calculateWithdrawFees(network, true, addressInfo, uiPayload.amountSats, btcFeeRates, sbtcWalletAddress, uiPayload.bitcoinAddress, uiPayload.paymentPublicKey, undefined)
const tx = new btc.Transaction({ allowUnknowOutput: true, allowUnknownInputs:true, allowUnknownOutputs:true });
addInputs(network, uiPayload.amountSats, revealPayment, tx, false, addressInfo.utxos, uiPayload.userPaymentPubKey);
addInputs(network, uiPayload.amountSats, revealPayment, tx, false, addressInfo.utxos, uiPayload.paymentPublicKey);
const data = buildData(network, uiPayload.amountSats, uiPayload.signature, true)

@@ -55,3 +55,3 @@ const csvScript = getWithdrawScript(network, data, sbtcWalletAddress, uiPayload.bitcoinAddress);

export function calculateWithdrawFees(network:string, opDrop:boolean, addressInfo:any, amount:number, feeInfo:{ low_fee_per_kb:number, medium_fee_per_kb:number, high_fee_per_kb:number }, sbtcWalletAddress:string, changeAddress:string, userPaymentPubKey:string, data:Uint8Array|undefined) {
export function calculateWithdrawFees(network:string, opDrop:boolean, addressInfo:any, amount:number, feeInfo:{ low_fee_per_kb:number, medium_fee_per_kb:number, high_fee_per_kb:number }, sbtcWalletAddress:string, changeAddress:string, paymentPublicKey:string, data:Uint8Array|undefined) {
try {

@@ -61,3 +61,3 @@ let vsize = 0;

const tx = new btc.Transaction({ allowUnknowOutput: true, allowUnknownInputs:true, allowUnknownOutputs:true });
addInputs(network, amount, revealPayment, tx, true, addressInfo.utxos, userPaymentPubKey);
addInputs(network, amount, revealPayment, tx, true, addressInfo.utxos, paymentPublicKey);
if (!opDrop) {

@@ -64,0 +64,0 @@ if (data) tx.addOutput({ script: btc.Script.encode(['RETURN', data]), amount: BigInt(0) });

@@ -13,3 +13,3 @@ import type { BridgeTransactionType } from '../src/index';

reclaimPublicKey: 'tb1qxj5tpfsz836fyh5c3gfu2t9spjpzf924etnrsp',
userPaymentPubKey: 'tb1qxj5tpfsz836fyh5c3gfu2t9spjpzf924etnrsp',
paymentPublicKey: 'tb1qxj5tpfsz836fyh5c3gfu2t9spjpzf924etnrsp',
sbtcWalletPublicKey: 'tb1p4m8lyp5m3tjfwq2288429rk7sxnp5xjqslxkvatkujtsr8kkxlgqu9r4cd',

@@ -16,0 +16,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