Skip to content

Commit b0c2a65

Browse files
Merge pull request #7726 from BitGo/BTC-2806.signtx-route.defaultBackend
feat(abstract-utxo): add default SDK backend property
2 parents 5180ad0 + a517e73 commit b0c2a65

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

modules/abstract-utxo/src/abstractUtxoCoin.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,7 @@ export abstract class AbstractUtxoCoin
371371
{
372372
public altScriptHash?: number;
373373
public supportAltScriptDestination?: boolean;
374+
public defaultSdkBackend: SdkBackend = 'utxolib';
374375
public readonly amountType: 'number' | 'bigint';
375376
private readonly _network: utxolib.Network;
376377

@@ -536,17 +537,17 @@ export abstract class AbstractUtxoCoin
536537

537538
decodeTransaction<TNumber extends number | bigint>(
538539
input: Buffer | string,
539-
decodeWith?: SdkBackend
540+
decodeWith: SdkBackend = this.defaultSdkBackend
540541
): DecodedTransaction<TNumber> {
541542
if (typeof input === 'string') {
542543
const buffer = stringToBufferTryFormats(input, ['hex', 'base64']);
543544
return this.decodeTransaction(buffer, decodeWith);
544545
}
545546

546547
if (utxolib.bitgo.isPsbt(input)) {
547-
return decodePsbtWith(input, this.network, decodeWith ?? 'utxolib');
548+
return decodePsbtWith(input, this.network, decodeWith);
548549
} else {
549-
if (decodeWith ?? 'utxolib' !== 'utxolib') {
550+
if (decodeWith !== 'utxolib') {
550551
console.error('received decodeWith hint %s, ignoring for legacy transaction', decodeWith);
551552
}
552553
return utxolib.bitgo.createTransactionFromBuffer(input, this.network, {

0 commit comments

Comments
 (0)