mirror of
https://github.com/bitcoin-s/bitcoin-s.git
synced 2025-02-22 14:33:06 +01:00
Add from file ability for AddDLCSigsAndBroadcast DLCs (#3219)
This commit is contained in:
parent
1af9465881
commit
5036c419be
3 changed files with 37 additions and 1 deletions
|
@ -329,6 +329,21 @@ object ConsoleCli {
|
|||
case other => other
|
||||
}))
|
||||
),
|
||||
cmd("adddlcsigsandbroadcastfromfile")
|
||||
.action((_, conf) =>
|
||||
conf.copy(command =
|
||||
AddDLCSigsAndBroadcastFromFile(new File("").toPath)))
|
||||
.text("Adds DLC Signatures into the database and broadcasts the funding transaction")
|
||||
.children(
|
||||
arg[Path]("path")
|
||||
.required()
|
||||
.action((path, conf) =>
|
||||
conf.copy(command = conf.command match {
|
||||
case addDLCSigs: AddDLCSigsAndBroadcastFromFile =>
|
||||
addDLCSigs.copy(path = path)
|
||||
case other => other
|
||||
}))
|
||||
),
|
||||
cmd("getdlcfundingtx")
|
||||
.action((_, conf) => conf.copy(command = GetDLCFundingTx(null)))
|
||||
.text("Returns the Funding Tx corresponding to the DLC with the given contractId")
|
||||
|
@ -1506,6 +1521,8 @@ object ConsoleCli {
|
|||
RequestParam("adddlcsigsfromfile", Seq(up.writeJs(path)))
|
||||
case AddDLCSigsAndBroadcast(sigs) =>
|
||||
RequestParam("adddlcsigsandbroadcast", Seq(up.writeJs(sigs)))
|
||||
case AddDLCSigsAndBroadcastFromFile(path) =>
|
||||
RequestParam("adddlcsigsandbroadcastfromfile", Seq(up.writeJs(path)))
|
||||
case ExecuteDLC(contractId, oracleSigs, noBroadcast) =>
|
||||
RequestParam("executedlc",
|
||||
Seq(up.writeJs(contractId),
|
||||
|
@ -1880,6 +1897,9 @@ object CliCommand {
|
|||
case class AddDLCSigsAndBroadcast(sigs: LnMessage[DLCSignTLV])
|
||||
extends AddDLCSigsCliCommand
|
||||
|
||||
case class AddDLCSigsAndBroadcastFromFile(path: Path)
|
||||
extends AddDLCSigsCliCommand
|
||||
|
||||
case class GetDLCFundingTx(contractId: ByteVector) extends AppServerCliCommand
|
||||
|
||||
case class BroadcastDLCFundingTx(contractId: ByteVector)
|
||||
|
|
|
@ -33,7 +33,7 @@ class BroadcastDLCDialog
|
|||
case Some(file) =>
|
||||
signDLCFile = None // reset
|
||||
signFileChosenLabel.text = "" // reset
|
||||
AddDLCSigsFromFile(file.toPath)
|
||||
AddDLCSigsAndBroadcastFromFile(file.toPath)
|
||||
case None =>
|
||||
val signHex = readStringFromNode(inputs(dlcSigStr))
|
||||
|
||||
|
|
|
@ -433,6 +433,22 @@ case class WalletRoutes(wallet: AnyDLCHDWalletApi)(implicit
|
|||
}
|
||||
}
|
||||
|
||||
case ServerCommand("adddlcsigsandbroadcastfromfile", arr) =>
|
||||
DLCDataFromFile.fromJsArr(arr) match {
|
||||
case Failure(exception) =>
|
||||
reject(ValidationRejection("failure", Some(exception)))
|
||||
case Success(DLCDataFromFile(path, _)) =>
|
||||
val hex = Files.readAllLines(path).get(0)
|
||||
|
||||
val signMessage = LnMessageFactory(DLCSignTLV).fromHex(hex)
|
||||
complete {
|
||||
for {
|
||||
db <- wallet.addDLCSigs(signMessage.tlv)
|
||||
tx <- wallet.broadcastDLCFundingTx(db.contractIdOpt.get)
|
||||
} yield Server.httpSuccess(tx.txIdBE.hex)
|
||||
}
|
||||
}
|
||||
|
||||
case ServerCommand("getdlcfundingtx", arr) =>
|
||||
GetDLCFundingTx.fromJsArr(arr) match {
|
||||
case Failure(exception) =>
|
||||
|
|
Loading…
Add table
Reference in a new issue