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.34 to 1.0.35

4

dist/deposit_utils.d.ts
import * as btc from '@scure/btc-signer';
import type { PeginRequestI, UTXO } from './types/sbtc_types.js';
export declare const revealPayment = 10001;
export declare function buildOpReturnTransaction(network: string, revealFeeWithGas: number, fromBtcAddress: any, btcFeeRates: any, addressInfo: any, stacksAddress: string, sbtcWalletAddress: string, cardinal: string, ordinal: string): btc.Transaction;
export declare function buildOpReturnTransaction(network: string, amount: number, btcFeeRates: any, addressInfo: any, stacksAddress: string, sbtcWalletAddress: string, cardinal: string): btc.Transaction;
export declare function buildOpDropTransaction(network: string, revealFeeWithGas: number, commitKeys: any, btcFeeRates: any, addressInfo: any, stacksAddress: string, sbtcWalletAddress: string, cardinal: string, ordinal: string): {

@@ -9,3 +9,5 @@ peginReqest: PeginRequestI;

};
export declare function getOpReturnPeginRequest(network: string, amount: number, commitKeys: any, stacksAddress: string, sbtcWalletAddress: string, cardinal: string): PeginRequestI;
export declare function getOpDropPeginRequest(network: string, revealFee: number, commitKeys: any, stacksAddress: string, sbtcWalletAddress: string, cardinal: string): PeginRequestI;
export declare function maxCommit(addressInfo: any): any;
export declare function calculateFees(network: string, amount: number, feeInfo: {

@@ -12,0 +14,0 @@ low_fee_per_kb: number;

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

export const revealPayment = 10001;
export function buildOpReturnTransaction(network, revealFeeWithGas, fromBtcAddress, btcFeeRates, addressInfo, stacksAddress, sbtcWalletAddress, cardinal, ordinal) {
const amount = revealFeeWithGas;
export function buildOpReturnTransaction(network, amount, btcFeeRates, addressInfo, stacksAddress, sbtcWalletAddress, cardinal) {
const net = (network === 'testnet') ? btc.TEST_NETWORK : btc.NETWORK;

@@ -16,6 +15,6 @@ if (!stacksAddress)

const utxos = addressInfo.utxos;
const txFees = calculateFees(network, amount, btcFeeRates.feeInfo, utxos, ordinal, cardinal);
const txFees = calculateFees(network, amount, btcFeeRates.feeInfo, utxos, sbtcWalletAddress, cardinal);
const tx = new btc.Transaction({ allowUnknowInput: true, allowUnknowOutput: true });
addInputs(amount, tx, false, utxos);
const data = buildData(network, stacksAddress, revealFeeWithGas, false);
const data = buildDepositPayloadOpReturn(network, stacksAddress);
tx.addOutput({ script: btc.Script.encode(['RETURN', data]), amount: BigInt(0) });

@@ -25,3 +24,3 @@ tx.addOutputAddress(sbtcWalletAddress, BigInt(amount), net);

if (changeAmount > 0)
tx.addOutputAddress(fromBtcAddress, BigInt(changeAmount), net);
tx.addOutputAddress(cardinal, BigInt(changeAmount), net);
return tx;

@@ -45,2 +44,24 @@ }

}
export function getOpReturnPeginRequest(network, amount, commitKeys, stacksAddress, sbtcWalletAddress, cardinal) {
if (!stacksAddress)
throw new Error('Stacks address missing');
const data = buildDepositPayloadOpReturn(network, stacksAddress);
console.log('reclaimAddr.pubkey: ' + commitKeys.reclaimPub);
console.log('revealAddr.pubkey: ' + commitKeys.revealPub);
const req = {
originator: stacksAddress,
fromBtcAddress: cardinal,
revealPub: commitKeys.revealPub,
reclaimPub: commitKeys.reclaimPub,
status: 1,
tries: 0,
mode: 'op_return',
amount: amount,
requestType: 'deposit',
wallet: hex.encode(data),
stacksAddress: stacksAddress,
sbtcWalletAddress: sbtcWalletAddress,
};
return req;
}
export function getOpDropPeginRequest(network, revealFee, commitKeys, stacksAddress, sbtcWalletAddress, cardinal) {

@@ -82,2 +103,9 @@ const net = (network === 'testnet') ? btc.TEST_NETWORK : btc.NETWORK;

}
export function maxCommit(addressInfo) {
var _a;
if (!addressInfo || !addressInfo.utxos || addressInfo.utxos.length === 0)
return 0;
const summ = (_a = addressInfo === null || addressInfo === void 0 ? void 0 : addressInfo.utxos) === null || _a === void 0 ? void 0 : _a.map((item) => item.value).reduce((prev, curr) => prev + curr, 0);
return summ || 0;
}
export function calculateFees(network, amount, feeInfo, utxos, commitTxScriptAddress, changeAddress) {

@@ -84,0 +112,0 @@ try {

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

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

@@ -14,15 +14,14 @@ import * as btc from '@scure/btc-signer';

export function buildOpReturnTransaction(network:string, revealFeeWithGas:number, fromBtcAddress:any, btcFeeRates:any, addressInfo:any, stacksAddress:string, sbtcWalletAddress:string, cardinal:string, ordinal:string) {
const amount = revealFeeWithGas;
export function buildOpReturnTransaction(network:string, amount:number, btcFeeRates:any, addressInfo:any, stacksAddress:string, sbtcWalletAddress:string, cardinal:string) {
const net = (network === 'testnet') ? btc.TEST_NETWORK : btc.NETWORK;
if (!stacksAddress) throw new Error('Stacks address required!');
const utxos = addressInfo.utxos;
const txFees = calculateFees(network, amount, btcFeeRates.feeInfo, utxos, ordinal, cardinal)
const txFees = calculateFees(network, amount, btcFeeRates.feeInfo, utxos, sbtcWalletAddress, cardinal)
const tx = new btc.Transaction({ allowUnknowInput: true, allowUnknowOutput: true });
addInputs(amount, tx, false, utxos);
const data = buildData(network, stacksAddress, revealFeeWithGas, false);
const data = buildDepositPayloadOpReturn(network, stacksAddress);
tx.addOutput({ script: btc.Script.encode(['RETURN', data]), amount: BigInt(0) });
tx.addOutputAddress(sbtcWalletAddress, BigInt(amount), net);
const changeAmount = inputAmt(tx) - (amount + txFees[1]);
if (changeAmount > 0) tx.addOutputAddress(fromBtcAddress, BigInt(changeAmount), net);
if (changeAmount > 0) tx.addOutputAddress(cardinal, BigInt(changeAmount), net);
return tx;

@@ -46,2 +45,25 @@ }

export function getOpReturnPeginRequest(network:string, amount:number, commitKeys:any, stacksAddress:string, sbtcWalletAddress:string, cardinal:string):PeginRequestI {
if (!stacksAddress) throw new Error('Stacks address missing')
const data = buildDepositPayloadOpReturn(network, stacksAddress);
console.log('reclaimAddr.pubkey: ' + commitKeys.reclaimPub)
console.log('revealAddr.pubkey: ' + commitKeys.revealPub)
const req:PeginRequestI = {
originator: stacksAddress,
fromBtcAddress: cardinal,
revealPub: commitKeys.revealPub,
reclaimPub: commitKeys.reclaimPub,
status: 1,
tries: 0,
mode: 'op_return',
amount: amount,
requestType: 'deposit',
wallet: hex.encode(data),
stacksAddress: stacksAddress,
sbtcWalletAddress: sbtcWalletAddress,
}
return req;
}
export function getOpDropPeginRequest(network:string, revealFee:number, commitKeys:any, stacksAddress:string, sbtcWalletAddress:string, cardinal:string):PeginRequestI {

@@ -85,2 +107,8 @@ const net = (network === 'testnet') ? btc.TEST_NETWORK : btc.NETWORK;

export function maxCommit(addressInfo:any) {
if (!addressInfo || !addressInfo.utxos || addressInfo.utxos.length === 0) return 0;
const summ = addressInfo?.utxos?.map((item:{value:number}) => item.value).reduce((prev:number, curr:number) => prev + curr, 0);
return summ || 0;
}
export function calculateFees (network:string, amount:number, feeInfo:{ low_fee_per_kb:number, medium_fee_per_kb:number, high_fee_per_kb:number }, utxos:Array<UTXO>, commitTxScriptAddress:string, changeAddress:string) {

@@ -87,0 +115,0 @@ try {

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