11import assert from 'assert' ;
2- import * as sinon from 'sinon' ;
32import { importMacaroon } from 'macaroon' ;
4- import * as statics from '@bitgo/statics' ;
53import * as utxolib from '@bitgo/utxo-lib' ;
64
75import { accounts , signerRootKey } from './createWatchOnlyFixture' ;
@@ -17,7 +15,6 @@ import {
1715 deriveLightningServiceSharedSecret ,
1816} from './../../../../src/bitgo/lightning/lightningUtils' ;
1917
20- import * as lightningUtils from '../../../../src/bitgo/lightning/lightningUtils' ;
2118import { getSharedSecret } from '../../../../src' ;
2219
2320describe ( 'lightning utils' , function ( ) {
@@ -91,25 +88,15 @@ describe('lightning utils', function () {
9188 it ( `deriveLightningServiceSharedSecret` , function ( ) {
9289 const userAuthXprv =
9390 'xprv9s21ZrQH143K4NPkV8riiTnFf72MRyQDVHMmmpekGF1w5QkS2MfTei9KXYvrZVMop4zQ4arnzSF7TRp3Cy73AWaDdADiYMCi5qpYW1bUa5m' ;
94- const lightningServicePubKey = '03b6fe266b3f8ae110b877d942765e9cea9e82faf03cdbb6d0effe980b6371b9c2' ;
95- const lightningServicePrvKey = '8b95613f4341e347743bd2625728d87bc6f0a119acb6ae9121afeee2b2a650f7' ;
96-
97- const coin = statics . coins . get ( 'tlnbtc' ) ;
98- assert ( coin instanceof statics . LightningCoin ) ;
99-
100- const getStaticsLightningNetworkStub = sinon . stub ( lightningUtils , 'getStaticsLightningNetwork' ) . returns ( {
101- ...coin . network ,
102- lightningServicePubKey,
103- } ) ;
104-
105- const secret = deriveLightningServiceSharedSecret ( 'tlnbtc' , userAuthXprv ) ;
106- getStaticsLightningNetworkStub . restore ( ) ;
91+ const lightningServicePubKey = getStaticsLightningNetwork ( 'tlnbtc' ) . lightningServicePubKey ;
10792
10893 const expectedSecret = getSharedSecret (
109- Buffer . from ( lightningServicePrvKey , 'hex' ) ,
110- utxolib . bip32 . fromBase58 ( userAuthXprv ) . neutered ( )
94+ utxolib . bip32 . fromBase58 ( userAuthXprv ) ,
95+ Buffer . from ( lightningServicePubKey , 'hex' )
11196 ) ;
11297
98+ const secret = deriveLightningServiceSharedSecret ( 'tlnbtc' , userAuthXprv ) ;
99+
113100 assert . deepStrictEqual ( secret , expectedSecret ) ;
114101 } ) ;
115102} ) ;
0 commit comments