@@ -3,14 +3,14 @@ import Bitcoin from '@ledgerhq/hw-app-btc'
33
44import { BigNumber } from 'bignumber.js'
55import { base58 , padHexStart } from '../../crypto'
6- import { pubKeyToAddress , addressToPubKeyHash , compressPubKey } from './BitcoinUtil'
6+ import { pubKeyToAddress , addressToPubKeyHash , compressPubKey , getAddressNetwork } from './BitcoinUtil'
77import Address from '../../Address'
88import networks from './networks'
99import bip32 from 'bip32'
1010
1111export default class BitcoinLedgerProvider extends LedgerProvider {
1212 constructor ( chain = { network : networks . bitcoin , segwit : false } , numberOfBlockConfirmation = 1 ) {
13- super ( Bitcoin , `${ chain . segwit ? '49' : '44' } '/${ chain . network . coinType } '/0'/` )
13+ super ( Bitcoin , `${ chain . segwit ? '49' : '44' } '/${ chain . network . coinType } '/0'/` , chain . network )
1414 this . _derivationPath = `${ chain . segwit ? '49' : '44' } '/${ chain . network . coinType } '/0'/`
1515 this . _network = chain . network
1616 this . _bjsnetwork = chain . network . name . replace ( 'bitcoin_' , '' ) // for bitcoin js
@@ -502,4 +502,10 @@ export default class BitcoinLedgerProvider extends LedgerProvider {
502502 async getAddresses ( startingIndex = 0 , numAddresses = 1 , change = false ) {
503503 return this . getLedgerAddresses ( startingIndex , numAddresses , change )
504504 }
505+
506+ async getConnectedNetwork ( ) {
507+ const walletPubKey = await this . getWalletPublicKey ( this . _baseDerivationPath )
508+ const network = getAddressNetwork ( walletPubKey . bitcoinAddress )
509+ return network
510+ }
505511}
0 commit comments