From a517e7354facc16170611a2cfaef465632310347 Mon Sep 17 00:00:00 2001 From: Otto Allmendinger Date: Fri, 5 Dec 2025 14:44:04 +0100 Subject: [PATCH] feat(abstract-utxo): add default SDK backend property Add a `defaultSdkBackend` property to AbstractUtxoCoin and use it as the default value for `decodeTransaction`. This allows changing the default value at the site where the class instance is created. Issue: BTC-2806 Co-authored-by: llm-git --- modules/abstract-utxo/src/abstractUtxoCoin.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/modules/abstract-utxo/src/abstractUtxoCoin.ts b/modules/abstract-utxo/src/abstractUtxoCoin.ts index ff0227e422..29203be6a3 100644 --- a/modules/abstract-utxo/src/abstractUtxoCoin.ts +++ b/modules/abstract-utxo/src/abstractUtxoCoin.ts @@ -371,6 +371,7 @@ export abstract class AbstractUtxoCoin { public altScriptHash?: number; public supportAltScriptDestination?: boolean; + public defaultSdkBackend: SdkBackend = 'utxolib'; public readonly amountType: 'number' | 'bigint'; private readonly _network: utxolib.Network; @@ -536,7 +537,7 @@ export abstract class AbstractUtxoCoin decodeTransaction( input: Buffer | string, - decodeWith?: SdkBackend + decodeWith: SdkBackend = this.defaultSdkBackend ): DecodedTransaction { if (typeof input === 'string') { const buffer = stringToBufferTryFormats(input, ['hex', 'base64']); @@ -544,9 +545,9 @@ export abstract class AbstractUtxoCoin } if (utxolib.bitgo.isPsbt(input)) { - return decodePsbtWith(input, this.network, decodeWith ?? 'utxolib'); + return decodePsbtWith(input, this.network, decodeWith); } else { - if (decodeWith ?? 'utxolib' !== 'utxolib') { + if (decodeWith !== 'utxolib') { console.error('received decodeWith hint %s, ignoring for legacy transaction', decodeWith); } return utxolib.bitgo.createTransactionFromBuffer(input, this.network, {