Skip to content

Commit f8710c6

Browse files
Merge pull request #5946 from BitGo/BTC-1966.add-forceFinalize
feat(utxo-staking): add utility function to force finalize PSBTs
2 parents 874fa08 + ddbf39e commit f8710c6

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

modules/utxo-staking/src/babylon/delegationMessage.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,19 @@ export function getSignedPsbt(
4444
return bitcoinjslib.Psbt.fromBuffer(Buffer.from(wrappedPsbt.serialize()));
4545
}
4646

47+
/**
48+
* Utility method to work around a bug in btc-staking-ts
49+
* https://github.com/babylonlabs-io/btc-staking-ts/issues/71
50+
* @param buffer
51+
* @param network
52+
*/
53+
export function forceFinalizePsbt(buffer: Buffer, network: BabylonNetworkLike): bitcoinjslib.Psbt {
54+
const psbt = bitcoinjslib.Psbt.fromBuffer(buffer, { network: toBitcoinJsNetwork(network) });
55+
// this only works with certain bitcoinjslib versions
56+
psbt.finalizeAllInputs();
57+
return psbt;
58+
}
59+
4760
export function getBtcProviderForECKey(
4861
descriptorBuilder: BabylonDescriptorBuilder,
4962
stakerKey: utxolib.ECPairInterface

0 commit comments

Comments
 (0)