Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions modules/abstract-lightning/src/abstractLightningCoin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,25 @@ import {
VerifyAddressOptions,
VerifyTransactionOptions,
} from '@bitgo/sdk-core';
import { BaseCoin as StaticsBaseCoin } from '@bitgo/statics';
import * as utxolib from '@bitgo/utxo-lib';
import { randomBytes } from 'crypto';
import { bip32 } from '@bitgo/utxo-lib';

export abstract class AbstractLightningCoin extends BaseCoin {
protected readonly _staticsCoin: Readonly<StaticsBaseCoin>;
private readonly _network: utxolib.Network;
protected constructor(bitgo: BitGoBase, network: utxolib.Network) {
protected constructor(bitgo: BitGoBase, network: utxolib.Network, staticsCoin?: Readonly<StaticsBaseCoin>) {
super(bitgo);
if (!staticsCoin) {
throw new Error('missing required constructor parameter staticsCoin');
}
this._staticsCoin = staticsCoin;
this._network = network;
}

getBaseFactor(): number {
return 1e11;
return Math.pow(10, this._staticsCoin.decimalPlaces);
}

verifyTransaction(params: VerifyTransactionOptions): Promise<boolean> {
Expand Down
1 change: 1 addition & 0 deletions modules/sdk-coin-lnbtc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"dependencies": {
"@bitgo/abstract-lightning": "^7.8.3",
"@bitgo/sdk-core": "^36.34.0",
"@bitgo/statics": "^58.30.0",
"@bitgo/utxo-lib": "^11.21.0"
},
"devDependencies": {
Expand Down
9 changes: 5 additions & 4 deletions modules/sdk-coin-lnbtc/src/lnbtc.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import { AbstractLightningCoin } from '@bitgo/abstract-lightning';
import { BitGoBase, BaseCoin } from '@bitgo/sdk-core';
import { BaseCoin as StaticsBaseCoin } from '@bitgo/statics';
import * as utxolib from '@bitgo/utxo-lib';

export class Lnbtc extends AbstractLightningCoin {
constructor(bitgo: BitGoBase, network?: utxolib.Network) {
super(bitgo, network || utxolib.networks.bitcoin);
constructor(bitgo: BitGoBase, network?: utxolib.Network, staticsCoin?: Readonly<StaticsBaseCoin>) {
super(bitgo, network || utxolib.networks.bitcoin, staticsCoin);
}

static createInstance(bitgo: BitGoBase): BaseCoin {
return new Lnbtc(bitgo);
static createInstance(bitgo: BitGoBase, staticsCoin?: Readonly<StaticsBaseCoin>): BaseCoin {
return new Lnbtc(bitgo, undefined, staticsCoin);
}

getChain(): string {
Expand Down
9 changes: 5 additions & 4 deletions modules/sdk-coin-lnbtc/src/tlnbtc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@
* @prettier
*/
import { BaseCoin, BitGoBase } from '@bitgo/sdk-core';
import { BaseCoin as StaticsBaseCoin } from '@bitgo/statics';
import { Lnbtc } from './lnbtc';
import * as utxolib from '@bitgo/utxo-lib';

export class Tlnbtc extends Lnbtc {
constructor(bitgo: BitGoBase) {
super(bitgo, utxolib.networks.testnet);
constructor(bitgo: BitGoBase, staticsCoin?: Readonly<StaticsBaseCoin>) {
super(bitgo, utxolib.networks.testnet, staticsCoin);
}

static createInstance(bitgo: BitGoBase): BaseCoin {
return new Tlnbtc(bitgo);
static createInstance(bitgo: BitGoBase, staticsCoin?: Readonly<StaticsBaseCoin>): BaseCoin {
return new Tlnbtc(bitgo, staticsCoin);
}

getChain(): string {
Expand Down
Loading