mirror of
https://github.com/bitcoin-s/bitcoin-s.git
synced 2025-02-23 22:56:52 +01:00
Merge pull request #108 from Christewart/features_for_rpc_client
Add 'toBigDecimal' method to CurrencyUnit api
This commit is contained in:
commit
2df52bf4cc
2 changed files with 9 additions and 2 deletions
|
@ -49,6 +49,8 @@ sealed abstract class CurrencyUnit extends NetworkElement {
|
|||
Satoshis(- satoshis.underlying)
|
||||
}
|
||||
override def bytes = satoshis.bytes
|
||||
|
||||
def toBigDecimal: BigDecimal
|
||||
}
|
||||
|
||||
sealed abstract class Satoshis extends CurrencyUnit {
|
||||
|
@ -57,7 +59,11 @@ sealed abstract class Satoshis extends CurrencyUnit {
|
|||
override def satoshis: Satoshis = this
|
||||
|
||||
def toLong = underlying.toLong
|
||||
|
||||
def toBigInt: BigInt = BigInt(toLong)
|
||||
|
||||
override def toBigDecimal = BigDecimal(toBigInt)
|
||||
|
||||
def ==(satoshis: Satoshis): Boolean = underlying == satoshis.underlying
|
||||
}
|
||||
|
||||
|
@ -80,6 +86,8 @@ sealed abstract class Bitcoins extends CurrencyUnit {
|
|||
val sat = underlying * CurrencyUnits.btcToSatoshiScalar
|
||||
Satoshis(Int64(sat.toLongExact))
|
||||
}
|
||||
|
||||
override def toBigDecimal: BigDecimal = underlying
|
||||
override def hex = satoshis.hex
|
||||
}
|
||||
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
package org.bitcoins.core.protocol.transaction
|
||||
|
||||
import org.bitcoins.core.crypto.TxSigComponent
|
||||
import org.bitcoins.core.number.{Int32, UInt32}
|
||||
import org.bitcoins.core.number.UInt32
|
||||
import org.bitcoins.core.protocol.script._
|
||||
import org.bitcoins.core.protocol.transaction.testprotocol.CoreTransactionTestCase
|
||||
import org.bitcoins.core.protocol.transaction.testprotocol.CoreTransactionTestCaseProtocol._
|
||||
import org.bitcoins.core.script.ScriptProgram
|
||||
import org.bitcoins.core.script.crypto.HashType
|
||||
import org.bitcoins.core.script.interpreter.ScriptInterpreter
|
||||
import org.bitcoins.core.script.result.ScriptOk
|
||||
import org.bitcoins.core.serializers.transaction.RawBaseTransactionParser
|
||||
|
|
Loading…
Add table
Reference in a new issue