Skip to content

Commit 7f4c3b2

Browse files
OttoAllmendingerllm-git
andcommitted
feat(abstract-utxo): default to psbt-lite for testnet
Change the default transaction format on testnets from 'psbt' to 'psbt-lite', which uses a more efficient serialization that omits full prevTx data. Add documentation for transaction format options. Issue: BTC-2732 Co-authored-by: llm-git <[email protected]>
1 parent 4c23213 commit 7f4c3b2

File tree

2 files changed

+22
-5
lines changed

2 files changed

+22
-5
lines changed

modules/abstract-utxo/src/abstractUtxoCoin.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,18 @@ import { isDescriptorWalletData } from './descriptor/descriptorWallet';
8484

8585
import ScriptType2Of3 = utxolib.bitgo.outputScripts.ScriptType2Of3;
8686

87-
export type TxFormat = 'legacy' | 'psbt';
87+
export type TxFormat =
88+
// This is a legacy transaction format based around the bitcoinjs-lib serialization of unsigned transactions
89+
// does not include prevOut data and is a bit painful to work with
90+
// going to be deprecated in favor of psbt
91+
// @deprecated
92+
| 'legacy'
93+
// This is the standard psbt format, including the full prevTx data for legacy transactions.
94+
// This will remain supported but is not the default, since the data sizes can become prohibitively large.
95+
| 'psbt'
96+
// This is a nonstandard psbt version where legacy inputs are serialized as if they were segwit inputs.
97+
// While this prevents us to fully verify the transaction fee, we have other checks in place to ensure the fee is within bounds.
98+
| 'psbt-lite';
8899

89100
type UtxoCustomSigningFunction<TNumber extends number | bigint> = {
90101
(params: {
@@ -972,7 +983,7 @@ export abstract class AbstractUtxoCoin extends BaseCoin {
972983
}
973984

974985
if (isTestnet(this.network)) {
975-
return 'psbt';
986+
return 'psbt-lite';
976987
}
977988

978989
const walletFlagMusigKp = wallet.flag('musigKp') === 'true';

modules/abstract-utxo/test/unit/txFormat.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,11 @@ function runTest(params: {
103103

104104
describe('txFormat', function () {
105105
describe('getDefaultTxFormat', function () {
106-
// All testnet wallets default to PSBT
106+
// All testnet wallets default to PSBT-lite
107107
runTest({
108-
description: 'should always return psbt for testnet',
108+
description: 'should always return psbt-lite for testnet',
109109
coinFilter: (coin) => utxolib.isTestnet(coin.network),
110-
expectedTxFormat: 'psbt',
110+
expectedTxFormat: 'psbt-lite',
111111
});
112112

113113
// DistributedCustody wallets default to PSBT (mainnet only, testnet already covered)
@@ -161,5 +161,11 @@ describe('txFormat', function () {
161161
expectedTxFormat: 'psbt',
162162
requestedTxFormat: 'psbt',
163163
});
164+
165+
runTest({
166+
description: 'should respect explicitly requested psbt-lite format',
167+
expectedTxFormat: 'psbt-lite',
168+
requestedTxFormat: 'psbt-lite',
169+
});
164170
});
165171
});

0 commit comments

Comments
 (0)