mirror of
https://github.com/bitcoin-s/bitcoin-s.git
synced 2025-03-15 20:30:17 +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")
|
cmd("getutxos")
|
||||||
.action((_, conf) => conf.copy(command = GetUtxos))
|
.action((_, conf) => conf.copy(command = GetUtxos))
|
||||||
.text("Returns list of all wallet utxos"),
|
.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")
|
cmd("getaddresses")
|
||||||
.action((_, conf) => conf.copy(command = GetAddresses))
|
.action((_, conf) => conf.copy(command = GetAddresses))
|
||||||
.text("Returns list of all wallet addresses currently being watched"),
|
.text("Returns list of all wallet addresses currently being watched"),
|
||||||
|
@ -1114,6 +1117,8 @@ object ConsoleCli {
|
||||||
val requestParam: RequestParam = command match {
|
val requestParam: RequestParam = command match {
|
||||||
case GetUtxos =>
|
case GetUtxos =>
|
||||||
RequestParam("getutxos")
|
RequestParam("getutxos")
|
||||||
|
case ListReservedUtxos =>
|
||||||
|
RequestParam("listreservedutxos")
|
||||||
case GetAddresses =>
|
case GetAddresses =>
|
||||||
RequestParam("getaddresses")
|
RequestParam("getaddresses")
|
||||||
case GetSpentAddresses =>
|
case GetSpentAddresses =>
|
||||||
|
@ -1529,6 +1534,7 @@ object CliCommand {
|
||||||
|
|
||||||
case class GetNewAddress(labelOpt: Option[AddressLabelTag]) extends CliCommand
|
case class GetNewAddress(labelOpt: Option[AddressLabelTag]) extends CliCommand
|
||||||
case object GetUtxos extends CliCommand
|
case object GetUtxos extends CliCommand
|
||||||
|
case object ListReservedUtxos extends CliCommand
|
||||||
case object GetAddresses extends CliCommand
|
case object GetAddresses extends CliCommand
|
||||||
case object GetSpentAddresses extends CliCommand
|
case object GetSpentAddresses extends CliCommand
|
||||||
case object GetFundedAddresses 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 {
|
"return the wallet addresses" in {
|
||||||
val addressDb = LegacyAddressDb(
|
val addressDb = LegacyAddressDb(
|
||||||
LegacyHDPath(HDCoinType.Testnet, 0, HDChainType.External, 0),
|
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.api.wallet.db.SpendingInfoDb
|
||||||
import org.bitcoins.core.currency._
|
import org.bitcoins.core.currency._
|
||||||
import org.bitcoins.core.protocol.transaction.Transaction
|
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 org.bitcoins.crypto.NetworkElement
|
||||||
import ujson._
|
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", _) =>
|
case ServerCommand("getaddresses", _) =>
|
||||||
complete {
|
complete {
|
||||||
wallet.listAddresses().map { addressDbs =>
|
wallet.listAddresses().map { addressDbs =>
|
||||||
|
|
Loading…
Add table
Reference in a new issue