Merge pull request #903 from shocknet/bump-fee-api

bimp fee
This commit is contained in:
Justin (shocknet) 2026-03-04 13:27:32 -05:00 committed by GitHub
commit a2b7ac1673
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 18 additions and 7 deletions

View file

@ -3,7 +3,7 @@ const zkpInit = (secp256k1ZkpModule as any).default || secp256k1ZkpModule;
// import bolt11 from 'bolt11'; // import bolt11 from 'bolt11';
import { import {
Musig, SwapTreeSerializer, TaprootUtils, constructRefundTransaction, Musig, SwapTreeSerializer, TaprootUtils, constructRefundTransaction,
detectSwap, OutputType detectSwap, OutputType, targetFee
} from 'boltz-core'; } from 'boltz-core';
import { randomBytes, createHash } from 'crypto'; import { randomBytes, createHash } from 'crypto';
import { ECPairFactory, ECPairInterface } from 'ecpair'; import { ECPairFactory, ECPairInterface } from 'ecpair';
@ -184,14 +184,17 @@ export class SubmarineSwaps {
} }
] ]
const outputScript = address.toOutputScript(refundAddress, network) const outputScript = address.toOutputScript(refundAddress, network)
// Construct the refund transaction // Construct the refund transaction: targetFee converts sat/vbyte rate to flat fee
const refundTx = constructRefundTransaction( const refundTx = targetFee(
feePerVbyte,
(fee) => constructRefundTransaction(
details, details,
outputScript, outputScript,
cooperative ? 0 : timeoutBlockHeight, cooperative ? 0 : timeoutBlockHeight,
feePerVbyte, fee,
true true
) )
)
if (!cooperative) { if (!cooperative) {
return { return {

View file

@ -91,6 +91,14 @@ export default (mainHandler: Main): Types.ServerMethods => {
if (err != null) throw new Error(err.message) if (err != null) throw new Error(err.message)
return mainHandler.adminManager.CloseChannel(req) return mainHandler.adminManager.CloseChannel(req)
}, },
BumpTx: async ({ ctx, req }) => {
const err = Types.BumpTxValidate(req, {
txid_CustomCheck: txid => txid !== '',
sat_per_vbyte_CustomCheck: spv => spv > 0
})
if (err != null) throw new Error(err.message)
return mainHandler.adminManager.BumpTx(req)
},
GetAdminTransactionSwapQuotes: async ({ ctx, req }) => { GetAdminTransactionSwapQuotes: async ({ ctx, req }) => {
const err = Types.TransactionSwapRequestValidate(req, { const err = Types.TransactionSwapRequestValidate(req, {
transaction_amount_sats_CustomCheck: amt => amt > 0 transaction_amount_sats_CustomCheck: amt => amt > 0