mirror of
https://github.com/bitcoin-s/bitcoin-s.git
synced 2025-02-23 22:56:52 +01:00
Merge pull request #160 from Christewart/address_factory_tostring
Adding AddressFactory.fromStringExn to throw the exception instead of…
This commit is contained in:
commit
00408a3b0a
1 changed files with 7 additions and 1 deletions
|
@ -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]]
|
||||
|
|
Loading…
Add table
Reference in a new issue