Skip to content

Commit 836c26b

Browse files
OttoAllmendingerllm-git
andcommitted
feat(abstract-utxo): always return txFormat if provided
Refactor `getTxFormat` method to prioritize explicitly requested txFormat when provided. Default to PSBT for certain wallet types only when no format is specified. Issue: BTC-2732 Co-authored-by: llm-git <[email protected]>
1 parent c29bc87 commit 836c26b

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

modules/abstract-utxo/src/abstractUtxoCoin.ts

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -999,27 +999,31 @@ export abstract class AbstractUtxoCoin extends BaseCoin {
999999
}
10001000
}
10011001

1002+
if (requestedTxFormat !== undefined) {
1003+
return requestedTxFormat as TxFormat;
1004+
}
1005+
10021006
const walletFlagMusigKp = wallet.flag('musigKp') === 'true';
10031007
const isHotWallet = wallet.type() === 'hot';
10041008

10051009
// if not txFormat is already specified figure out if we should default to psbt format
10061010
if (
1007-
requestedTxFormat === undefined &&
1008-
(wallet.subType() === 'distributedCustody' ||
1009-
// default to testnet for all utxo coins except zcash
1010-
(isTestnet(this.network) &&
1011-
// FIXME(BTC-1322): fix zcash PSBT support
1012-
getMainnet(this.network) !== utxolib.networks.zcash &&
1013-
isHotWallet) ||
1014-
// if mainnet, only default to psbt for btc hot wallets
1015-
(isMainnet(this.network) && getMainnet(this.network) === utxolib.networks.bitcoin && isHotWallet) ||
1016-
// default to psbt if it has the wallet flag
1017-
walletFlagMusigKp)
1011+
wallet.subType() === 'distributedCustody' ||
1012+
// default to testnet for all utxo coins except zcash
1013+
(isTestnet(this.network) &&
1014+
// FIXME(BTC-1322): fix zcash PSBT support
1015+
getMainnet(this.network) !== utxolib.networks.zcash &&
1016+
isHotWallet) ||
1017+
// if mainnet, only default to psbt for btc hot wallets
1018+
(isMainnet(this.network) && getMainnet(this.network) === utxolib.networks.bitcoin && isHotWallet) ||
1019+
// default to psbt if it has the wallet flag
1020+
walletFlagMusigKp
10181021
) {
10191022
return 'psbt';
10201023
}
10211024

1022-
return requestedTxFormat as TxFormat;
1025+
// let API decide
1026+
return undefined;
10231027
}
10241028

10251029
async getExtraPrebuildParams(buildParams: ExtraPrebuildParamsOptions & { wallet: Wallet }): Promise<{

0 commit comments

Comments
 (0)