Skip to content

Commit 8be1fa5

Browse files
Merge pull request #8109 from BitGo/BTC-2650.port-impl-btc-to-wasm-utxo.2
refactor(abstract-utxo): migrate to wasm-utxo and remove dead code
2 parents f370430 + d13b3f5 commit 8be1fa5

File tree

4 files changed

+5
-22
lines changed

4 files changed

+5
-22
lines changed

modules/abstract-utxo/src/abstractUtxoCoin.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -400,8 +400,6 @@ export abstract class AbstractUtxoCoin
400400
{
401401
abstract name: UtxoCoinName;
402402

403-
public altScriptHash?: number;
404-
public supportAltScriptDestination?: boolean;
405403
public readonly amountType: 'number' | 'bigint';
406404

407405
protected constructor(bitgo: BitGoBase, amountType: 'number' | 'bigint' = 'number') {

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}`);

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

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,11 @@
11
import { BitGoBase } from '@bitgo/sdk-core';
2-
import * as utxolib from '@bitgo/utxo-lib';
32

43
import { AbstractUtxoCoin } from '../../abstractUtxoCoin';
54
import { UtxoCoinName } from '../../names';
65

76
export class Ltc extends AbstractUtxoCoin {
87
readonly name: UtxoCoinName = 'ltc';
98

10-
constructor(bitgo: BitGoBase) {
11-
super(bitgo);
12-
// use legacy script hash version, which is the current Bitcoin one
13-
this.altScriptHash = utxolib.networks.bitcoin.scriptHash;
14-
// do not support alt destinations in prod
15-
this.supportAltScriptDestination = false;
16-
}
17-
189
static createInstance(bitgo: BitGoBase): Ltc {
1910
return new Ltc(bitgo);
2011
}

modules/abstract-utxo/src/impl/ltc/tltc.ts

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

43
import { UtxoCoinName } from '../../names';
54

@@ -8,12 +7,6 @@ import { Ltc } from './ltc';
87
export class Tltc extends Ltc {
98
readonly name: UtxoCoinName = 'tltc';
109

11-
constructor(bitgo: BitGoBase) {
12-
super(bitgo);
13-
this.altScriptHash = utxolib.networks.testnet.scriptHash;
14-
// support alt destinations on test
15-
this.supportAltScriptDestination = false;
16-
}
1710
static createInstance(bitgo: BitGoBase): Tltc {
1811
return new Tltc(bitgo);
1912
}

0 commit comments

Comments
 (0)