mirror of
https://github.com/bitcoin-s/bitcoin-s.git
synced 2025-03-03 18:47:38 +01:00
Add clightning listtransactions func (#3797)
This commit is contained in:
parent
aa748c012f
commit
cd5451adaa
5 changed files with 36 additions and 0 deletions
|
@ -332,4 +332,17 @@ object CLightningJsonModels {
|
|||
case class FundChannelCancelResult(
|
||||
cancelled: String
|
||||
) extends CLightningJsonModel
|
||||
|
||||
case class CLightningTransaction(
|
||||
hash: DoubleSha256DigestBE,
|
||||
rawtx: Transaction,
|
||||
blockheight: Int,
|
||||
txindex: Int,
|
||||
locktime: Long,
|
||||
version: Int
|
||||
) extends CLightningJsonModel
|
||||
|
||||
case class ListTransactionsResults(
|
||||
transactions: Vector[CLightningTransaction]
|
||||
) extends CLightningJsonModel
|
||||
}
|
||||
|
|
|
@ -698,6 +698,13 @@ object JsonSerializers {
|
|||
FundChannelCancelResult] =
|
||||
Json.reads[FundChannelCancelResult]
|
||||
|
||||
implicit val CLightningTransactionReads: Reads[CLightningTransaction] =
|
||||
Json.reads[CLightningTransaction]
|
||||
|
||||
implicit val CLightningListTransactionsResultsReads: Reads[
|
||||
ListTransactionsResults] =
|
||||
Json.reads[ListTransactionsResults]
|
||||
|
||||
implicit val byteVectorWrites: Writes[ByteVector] =
|
||||
Writes[ByteVector](bytes => JsString(bytes.toHex))
|
||||
|
||||
|
|
|
@ -22,10 +22,16 @@ class CLightningClientPairTest extends DualCLightningFixture {
|
|||
for {
|
||||
infoA <- clightningA.getInfo
|
||||
infoB <- clightningB.getInfo
|
||||
|
||||
txs <- clightningA.listTransactions()
|
||||
funds <- clightningB.listFunds
|
||||
} yield {
|
||||
assert(infoA.id != infoB.id)
|
||||
assert(infoA.blockheight >= 0)
|
||||
assert(infoB.blockheight >= 0)
|
||||
|
||||
assert(txs.nonEmpty)
|
||||
assert(funds.outputs.nonEmpty)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -55,4 +55,10 @@ class CLightningRpcClientTest extends CLightningFixture {
|
|||
assert(funds.channels.isEmpty)
|
||||
}
|
||||
}
|
||||
|
||||
it must "list txs" in { client =>
|
||||
for {
|
||||
txs <- client.listTransactions()
|
||||
} yield assert(txs.isEmpty)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -256,6 +256,10 @@ class CLightningRpcClient(val instance: CLightningInstanceLocal, binary: File)(
|
|||
clightningCall[CLightningPsbtResult]("signpsbt", params).map(_.signed_psbt)
|
||||
}
|
||||
|
||||
def listTransactions(): Future[Vector[CLightningTransaction]] =
|
||||
clightningCall[ListTransactionsResults]("listtransactions").map(
|
||||
_.transactions)
|
||||
|
||||
def withdraw(
|
||||
address: BitcoinAddress,
|
||||
amount: Satoshis): Future[WithdrawResult] =
|
||||
|
|
Loading…
Add table
Reference in a new issue