mirror of
https://github.com/bitcoin-s/bitcoin-s.git
synced 2025-03-13 11:35:40 +01:00
Add listreservedutxos cli command (#2247)
This commit is contained in:
parent
491c42bc95
commit
b02eb07cf0
3 changed files with 32 additions and 1 deletions
|
@ -578,6 +578,9 @@ object ConsoleCli {
|
|||
cmd("getutxos")
|
||||
.action((_, conf) => conf.copy(command = GetUtxos))
|
||||
.text("Returns list of all wallet utxos"),
|
||||
cmd("listreservedutxos")
|
||||
.action((_, conf) => conf.copy(command = ListReservedUtxos))
|
||||
.text("Returns list of all reserved wallet utxos"),
|
||||
cmd("getaddresses")
|
||||
.action((_, conf) => conf.copy(command = GetAddresses))
|
||||
.text("Returns list of all wallet addresses currently being watched"),
|
||||
|
@ -1114,6 +1117,8 @@ object ConsoleCli {
|
|||
val requestParam: RequestParam = command match {
|
||||
case GetUtxos =>
|
||||
RequestParam("getutxos")
|
||||
case ListReservedUtxos =>
|
||||
RequestParam("listreservedutxos")
|
||||
case GetAddresses =>
|
||||
RequestParam("getaddresses")
|
||||
case GetSpentAddresses =>
|
||||
|
@ -1529,6 +1534,7 @@ object CliCommand {
|
|||
|
||||
case class GetNewAddress(labelOpt: Option[AddressLabelTag]) extends CliCommand
|
||||
case object GetUtxos extends CliCommand
|
||||
case object ListReservedUtxos extends CliCommand
|
||||
case object GetAddresses extends CliCommand
|
||||
case object GetSpentAddresses extends CliCommand
|
||||
case object GetFundedAddresses extends CliCommand
|
||||
|
|
|
@ -350,6 +350,23 @@ class RoutesSpec extends AnyWordSpec with ScalatestRouteTest with MockFactory {
|
|||
}
|
||||
}
|
||||
|
||||
"return the reserved wallet utxos" in {
|
||||
|
||||
(mockWalletApi
|
||||
.listUtxos(_: TxoState))
|
||||
.expects(TxoState.Reserved)
|
||||
.returning(Future.successful(Vector(spendingInfoDb)))
|
||||
|
||||
val route =
|
||||
walletRoutes.handleCommand(ServerCommand("listreservedutxos", Arr()))
|
||||
|
||||
Get() ~> route ~> check {
|
||||
assert(contentType == `application/json`)
|
||||
assert(
|
||||
responseAs[String] == """{"result":[{"outpoint":"000000000000000000000000000000000000000000000000000000000000000000000000","value":-1}],"error":null}""")
|
||||
}
|
||||
}
|
||||
|
||||
"return the wallet addresses" in {
|
||||
val addressDb = LegacyAddressDb(
|
||||
LegacyHDPath(HDCoinType.Testnet, 0, HDChainType.External, 0),
|
||||
|
|
|
@ -8,7 +8,7 @@ import org.bitcoins.core.api.wallet.AnyHDWalletApi
|
|||
import org.bitcoins.core.api.wallet.db.SpendingInfoDb
|
||||
import org.bitcoins.core.currency._
|
||||
import org.bitcoins.core.protocol.transaction.Transaction
|
||||
import org.bitcoins.core.wallet.utxo.AddressLabelTagType
|
||||
import org.bitcoins.core.wallet.utxo.{AddressLabelTagType, TxoState}
|
||||
import org.bitcoins.crypto.NetworkElement
|
||||
import ujson._
|
||||
|
||||
|
@ -329,6 +329,14 @@ case class WalletRoutes(wallet: AnyHDWalletApi)(implicit system: ActorSystem)
|
|||
}
|
||||
}
|
||||
|
||||
case ServerCommand("listreservedutxos", _) =>
|
||||
complete {
|
||||
wallet.listUtxos(TxoState.Reserved).map { utxos =>
|
||||
val json = utxos.map(spendingInfoDbToJson)
|
||||
Server.httpSuccess(json)
|
||||
}
|
||||
}
|
||||
|
||||
case ServerCommand("getaddresses", _) =>
|
||||
complete {
|
||||
wallet.listAddresses().map { addressDbs =>
|
||||
|
|
Loading…
Add table
Reference in a new issue