Merge pull request #160 from Christewart/address_factory_tostring

Adding AddressFactory.fromStringExn to throw the exception instead of…
This commit is contained in:
Chris Stewart 2018-05-11 10:54:35 -04:00 committed by GitHub
commit 00408a3b0a

View file

@ -3,13 +3,19 @@ package org.bitcoins.core.protocol
import org.bitcoins.core.config.NetworkParameters
import org.bitcoins.core.protocol.script.ScriptPubKey
import scala.util.Try
import scala.util.{ Failure, Success, Try }
abstract class AddressFactory[T] {
/** Attempts to create an address from the given String */
def fromString(str: String): Try[T]
/** Same as fromString, but throws the exception */
def fromStringExn(str: String): T = fromString(str) match {
case Success(addr) => addr
case Failure(exn) => throw exn
}
/**
* Attempts to create a address from the given [[org.bitcoins.core.protocol.script.ScriptPubKey]]
* and [[NetworkParameters]]