Skip to content

Commit 7410da3

Browse files
OttoAllmendingerllm-git
andcommitted
feat(abstract-utxo): force PSBT for testnet bitcoin
Force PSBT for testnet Bitcoin by rejecting 'legacy' format and defaulting to 'psbt-lite' for Bitcoin testnet networks. Add new error class for deprecated transaction formats. Issue: BTC-2732 Co-authored-by: llm-git <[email protected]>
1 parent 9e82ee2 commit 7410da3

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

modules/abstract-utxo/src/abstractUtxoCoin.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,12 @@ class ErrorInvalidTxFormat extends Error {
9696
}
9797
}
9898

99+
class ErrorDeprecatedTxFormat extends Error {
100+
constructor(txFormat: unknown) {
101+
super(`Deprecated txFormat: ${txFormat} for this network`);
102+
}
103+
}
104+
99105
type UtxoCustomSigningFunction<TNumber extends number | bigint> = {
100106
(params: {
101107
coin: IBaseCoin;
@@ -997,6 +1003,14 @@ export abstract class AbstractUtxoCoin extends BaseCoin {
9971003
if (requestedTxFormat !== undefined && !isTxFormat(requestedTxFormat)) {
9981004
throw new ErrorInvalidTxFormat(requestedTxFormat);
9991005
}
1006+
1007+
if (utxolib.getMainnet(this.network) === utxolib.networks.bitcoin) {
1008+
if (requestedTxFormat === 'legacy') {
1009+
throw new ErrorDeprecatedTxFormat(requestedTxFormat);
1010+
}
1011+
1012+
return 'psbt-lite';
1013+
}
10001014
}
10011015

10021016
if (requestedTxFormat !== undefined) {

0 commit comments

Comments
 (0)