mirror of
https://github.com/bitcoin-s/bitcoin-s.git
synced 2025-02-22 14:33:06 +01:00
parent
77cd94ac41
commit
bf831ae32e
8 changed files with 60 additions and 31 deletions
|
@ -154,8 +154,7 @@ object Picklers {
|
|||
|
||||
implicit val lockUnspentOutputParameterPickler: ReadWriter[
|
||||
LockUnspentOutputParameter] =
|
||||
readwriter[String].bimap(_.toJson.render(),
|
||||
LockUnspentOutputParameter.fromJsonString)
|
||||
readwriter[Value].bimap(_.toJson, LockUnspentOutputParameter.fromJson)
|
||||
|
||||
implicit val offeredW: Writer[Offered] =
|
||||
writer[Obj].comap { offered =>
|
||||
|
|
|
@ -263,13 +263,20 @@ object CliReaders {
|
|||
val reads: String => Sha256DigestBE = Sha256DigestBE.fromHex
|
||||
}
|
||||
|
||||
implicit val lockUnspentOutputParameterReads: Read[
|
||||
LockUnspentOutputParameter] =
|
||||
new Read[LockUnspentOutputParameter] {
|
||||
val arity: Int = 1
|
||||
implicit val lockUnspentOutputParametersReads: Read[
|
||||
Vector[LockUnspentOutputParameter]] =
|
||||
new Read[Vector[LockUnspentOutputParameter]] {
|
||||
override val arity: Int = 1
|
||||
|
||||
val reads: String => LockUnspentOutputParameter =
|
||||
LockUnspentOutputParameter.fromJsonString
|
||||
override val reads: String => Vector[LockUnspentOutputParameter] = { s =>
|
||||
val json = ujson.read(s)
|
||||
json.objOpt match {
|
||||
case Some(value) =>
|
||||
Vector(LockUnspentOutputParameter.fromJson(value))
|
||||
case None =>
|
||||
json.arr.toVector.map(LockUnspentOutputParameter.fromJson)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
implicit val sha256DigestReads: Read[Sha256Digest] =
|
||||
|
|
|
@ -813,13 +813,13 @@ object ConsoleCli {
|
|||
lockUnspent.copy(unlock = unlock)
|
||||
case other => other
|
||||
})),
|
||||
arg[Seq[LockUnspentOutputParameter]]("transactions")
|
||||
.text("The transaction outpoints to unlock/lock")
|
||||
.required()
|
||||
arg[Vector[LockUnspentOutputParameter]]("transactions")
|
||||
.text("The transaction outpoints to unlock/lock, empty to apply to all utxos")
|
||||
.optional()
|
||||
.action((outPoints, conf) =>
|
||||
conf.copy(command = conf.command match {
|
||||
case lockUnspent: LockUnspent =>
|
||||
lockUnspent.copy(outPoints = outPoints.toVector)
|
||||
lockUnspent.copy(outPoints = outPoints)
|
||||
case other => other
|
||||
}))
|
||||
),
|
||||
|
|
|
@ -590,6 +590,12 @@ class RoutesSpec extends AnyWordSpec with ScalatestRouteTest with MockFactory {
|
|||
.returning(Future.successful(Vector(spendingInfoDb)))
|
||||
.anyNumberOfTimes()
|
||||
|
||||
(mockWalletApi
|
||||
.listUtxos(_: TxoState))
|
||||
.expects(TxoState.Reserved)
|
||||
.returning(Future.successful(Vector(spendingInfoDb)))
|
||||
.anyNumberOfTimes()
|
||||
|
||||
(mockWalletApi
|
||||
.markUTXOsAsReserved(_: Vector[SpendingInfoDb]))
|
||||
.expects(Vector(spendingInfoDb))
|
||||
|
|
|
@ -156,24 +156,19 @@ case class WalletRoutes(wallet: AnyHDWalletApi)(implicit
|
|||
}
|
||||
|
||||
for {
|
||||
utxos <- {
|
||||
utxos <-
|
||||
if (unlock) {
|
||||
wallet.listUtxos(TxoState.Reserved)
|
||||
} else wallet.listUtxos()
|
||||
|
||||
filtered =
|
||||
if (outputParams.nonEmpty) {
|
||||
wallet
|
||||
.listUtxos()
|
||||
.map(_.filter(utxo =>
|
||||
outputParams.exists(_.outPoint == utxo.outPoint)))
|
||||
} else {
|
||||
wallet.listUtxos()
|
||||
}
|
||||
}
|
||||
reserved <- func(utxos)
|
||||
} yield {
|
||||
if (reserved.nonEmpty) {
|
||||
Server.httpSuccess(true)
|
||||
} else {
|
||||
Server.httpSuccess(false)
|
||||
}
|
||||
}
|
||||
utxos.filter(utxo =>
|
||||
outputParams.exists(_.outPoint == utxo.outPoint))
|
||||
} else utxos
|
||||
|
||||
reserved <- func(filtered)
|
||||
} yield Server.httpSuccess(reserved.nonEmpty)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -205,7 +205,7 @@ the `-p 9999:9999` port mapping on the docker container to adjust for this.
|
|||
- `txid` - The transaction id
|
||||
- `lockunspent` `unlock` `transactions` - Temporarily lock (unlock=false) or unlock (unlock=true) specified transaction outputs.
|
||||
- `unlock` - Whether to unlock (true) or lock (false) the specified transactions
|
||||
- `transactions` - The transaction outpoints to unlock/lock
|
||||
- `transactions` - The transaction outpoints to unlock/lock, empty to apply to all utxos
|
||||
- `importseed` `walletname` `words` `passphrase` - Imports a mnemonic seed as a new seed file
|
||||
- `walletname` - Name to associate with this seed
|
||||
- `words` - Mnemonic seed words, space separated
|
||||
|
|
21
docs/wallet/wallet-rpc.md
Normal file
21
docs/wallet/wallet-rpc.md
Normal file
|
@ -0,0 +1,21 @@
|
|||
---
|
||||
title: Wallet RPC Examples
|
||||
id: wallet-rpc
|
||||
---
|
||||
|
||||
### `lockunspent`
|
||||
|
||||
Locks all utxos in the wallet
|
||||
```bash
|
||||
bitcoin-s-cli lockunspent false
|
||||
```
|
||||
|
||||
Unlocks utxo `1c22634fa282e71866a8b8c6732ec89eb5c46d30f9773486b0ae32770e8109e1:1`
|
||||
```bash
|
||||
bitcoin-s-cli lockunspent true '{"txid" : "1c22634fa282e71866a8b8c6732ec89eb5c46d30f9773486b0ae32770e8109e1","vout" : 1}'
|
||||
```
|
||||
|
||||
Locks utxos `1c22634fa282e71866a8b8c6732ec89eb5c46d30f9773486b0ae32770e8109e1:1` and `4c63268a688d103caeb26137cecd4053566bd3626504e079055581c104c4de5b:0`
|
||||
```bash
|
||||
bitcoin-s-cli lockunspent false '[{"txid" : "1c22634fa282e71866a8b8c6732ec89eb5c46d30f9773486b0ae32770e8109e1","vout" : 1}, {"txid" : "4c63268a688d103caeb26137cecd4053566bd3626504e079055581c104c4de5b","vout" : 0}]'
|
||||
```
|
|
@ -55,7 +55,8 @@
|
|||
"wallet/address-tagging",
|
||||
"wallet/dlc",
|
||||
"wallet/wallet-rescan",
|
||||
"wallet/wallet-sync"
|
||||
"wallet/wallet-sync",
|
||||
"wallet/wallet-rpc"
|
||||
],
|
||||
"RPC Clients": [
|
||||
"rpc/rpc-clients-intro",
|
||||
|
|
Loading…
Add table
Reference in a new issue