Skip to content

Commit d13b3f5

Browse files
refactor(abstract-utxo): migrate bch.ts canonicalAddress to wasm-utxo
Replace utxo-lib addressFormat functions with wasm-utxo address module for BCH address format conversion (cashaddr/base58). Co-authored-by: Cursor <cursoragent@cursor.com> TICKET: BTC-2650
1 parent 703e07f commit d13b3f5

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

  • modules/abstract-utxo/src/impl/bch

modules/abstract-utxo/src/impl/bch/bch.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { BitGoBase } from '@bitgo/sdk-core';
2-
import * as utxolib from '@bitgo/utxo-lib';
2+
import { address as wasmAddress } from '@bitgo/wasm-utxo';
33

44
import { AbstractUtxoCoin } from '../../abstractUtxoCoin';
55
import { UtxoCoinName } from '../../names';
@@ -34,12 +34,13 @@ export class Bch extends AbstractUtxoCoin {
3434
}
3535

3636
if (version === 'base58') {
37-
return utxolib.addressFormat.toCanonicalFormat(address, this.network);
37+
const script = wasmAddress.toOutputScriptWithCoin(address, this.name);
38+
return wasmAddress.fromOutputScriptWithCoin(script, this.name, 'default');
3839
}
3940

4041
if (version === 'cashaddr') {
41-
const script = utxolib.addressFormat.toOutputScriptTryFormats(address, this.network);
42-
return utxolib.addressFormat.fromOutputScriptWithFormat(script, version, this.network);
42+
const script = wasmAddress.toOutputScriptWithCoin(address, this.name);
43+
return wasmAddress.fromOutputScriptWithCoin(script, this.name, 'cashaddr');
4344
}
4445

4546
throw new Error(`invalid version ${version}`);

0 commit comments

Comments
 (0)