mirror of
https://github.com/bitcoin-s/bitcoin-s.git
synced 2025-01-19 05:43:51 +01:00
Fix bug where getbalances was always retruning sats (#3750)
This commit is contained in:
parent
94e219befd
commit
80d498d288
@ -355,6 +355,31 @@ class RoutesSpec extends AnyWordSpec with ScalatestRouteTest with MockFactory {
|
||||
spendingTxIdOpt = Some(DoubleSha256DigestBE.empty)
|
||||
)
|
||||
|
||||
"return the wallet's balances in bitcoin" in {
|
||||
(mockWalletApi.getConfirmedBalance: () => Future[CurrencyUnit])
|
||||
.expects()
|
||||
.returning(Future.successful(Bitcoins(50)))
|
||||
|
||||
(mockWalletApi.getUnconfirmedBalance: () => Future[CurrencyUnit])
|
||||
.expects()
|
||||
.returning(Future.successful(Bitcoins(50)))
|
||||
|
||||
(mockWalletApi
|
||||
.listUtxos(_: TxoState))
|
||||
.expects(TxoState.Reserved)
|
||||
.returning(Future.successful(Vector(spendingInfoDb)))
|
||||
|
||||
val route =
|
||||
walletRoutes.handleCommand(
|
||||
ServerCommand("getbalances", Arr(Bool(false))))
|
||||
|
||||
Get() ~> route ~> check {
|
||||
assert(contentType == `application/json`)
|
||||
assert(
|
||||
responseAs[String] == """{"result":{"confirmed":50,"unconfirmed":50,"reserved":-1.0E-8,"total":99.99999999},"error":null}""")
|
||||
}
|
||||
}
|
||||
|
||||
"return the wallet's balances in sats" in {
|
||||
(mockWalletApi.getConfirmedBalance: () => Future[CurrencyUnit])
|
||||
.expects()
|
||||
|
@ -856,7 +856,7 @@ case class WalletRoutes(wallet: AnyDLCHDWalletApi)(implicit
|
||||
if (isSats) {
|
||||
currencyUnit.satoshis.toBigDecimal.toDouble
|
||||
} else {
|
||||
currencyUnit.toBigDecimal.toDouble
|
||||
Bitcoins(currencyUnit.satoshis).toBigDecimal.toDouble
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user