Add toAddress on HDChain

This commit is contained in:
Torkel Rogstad 2019-06-18 18:03:05 +02:00
parent 4435d942d9
commit 75bf52a431
2 changed files with 12 additions and 0 deletions

View File

@ -29,6 +29,15 @@ class HDPathTest extends BitcoinSUnitTest {
}
}
behavior of "HDChain"
it must "be convertable to an address" in {
forAll(HDGenerators.hdChain, NumberGenerator.positiveInts) { (chain, i) =>
val addr = chain.toAddress(i)
assert(addr.chain == chain)
}
}
behavior of "HDAddress"
it must "fail to make addresses with neagtives indices" in {

View File

@ -20,6 +20,9 @@ sealed abstract class HDChain extends BIP32Path {
def toInt: Int = chainType.index
/** Given a index, creates a HD address */
def toAddress(index: Int): HDAddress = HDAddress(this, index = index)
}
object HDChain {