Fix hardcoded network for the default wallet account (#1277)

* Fix hardcoded network for the default wallet account

* Refactor call to HDUtil.getCoinType()
This commit is contained in:
Chris Stewart 2020-03-30 12:30:48 -05:00 committed by GitHub
parent 14b13eb612
commit 5eef801813
3 changed files with 12 additions and 4 deletions

View file

@ -1,5 +1,7 @@
package org.bitcoins.core.hd
import org.bitcoins.core.config.{MainNet, NetworkParameters, RegTest, TestNet3}
/**
* Represents a
* [[https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki#Coin_type BIP44]],
@ -33,4 +35,11 @@ object HDCoinType {
case _: Int =>
throw new IllegalArgumentException(s"$int is not valid coin type!")
}
def fromNetwork(np: NetworkParameters): HDCoinType = {
np match {
case MainNet => Bitcoin
case TestNet3 | RegTest => Testnet
}
}
}

View file

@ -74,8 +74,7 @@ object HDUtil {
}
}
def getCoinType(network: NetworkParameters): HDCoinType = network match {
case MainNet => HDCoinType.Bitcoin
case TestNet3 | RegTest => HDCoinType.Testnet
def getCoinType(network: NetworkParameters): HDCoinType = {
HDCoinType.fromNetwork(network)
}
}

View file

@ -51,7 +51,7 @@ case class WalletAppConfig(
lazy val defaultAccount: HDAccount = {
val purpose = defaultAccountKind
HDAccount(coin = HDCoin(purpose, HDCoinType.Testnet), index = 0)
HDAccount(coin = HDCoin(purpose, HDCoinType.fromNetwork(network)), index = 0)
}
lazy val bloomFalsePositiveRate: Double =