mirror of
https://github.com/bitcoin-s/bitcoin-s.git
synced 2025-02-23 14:50:42 +01:00
Only unreserve our utxos when canceling a DLC (#3250)
This commit is contained in:
parent
65f096f65a
commit
c2237ab6fe
1 changed files with 7 additions and 6 deletions
|
@ -252,22 +252,23 @@ abstract class DLCWallet
|
||||||
*/
|
*/
|
||||||
override def cancelDLC(dlcId: Sha256Digest): Future[Unit] = {
|
override def cancelDLC(dlcId: Sha256Digest): Future[Unit] = {
|
||||||
for {
|
for {
|
||||||
inputs <- dlcInputsDAO.findByDLCId(dlcId)
|
|
||||||
dbs <- spendingInfoDAO.findByOutPoints(inputs.map(_.outPoint))
|
|
||||||
// allow this to fail in the case they have already been unreserved
|
|
||||||
_ <- unmarkUTXOsAsReserved(dbs).recover { case _: Throwable => () }
|
|
||||||
|
|
||||||
dlcOpt <- dlcDAO.read(dlcId)
|
dlcOpt <- dlcDAO.read(dlcId)
|
||||||
_ = dlcOpt match {
|
dlcDb = dlcOpt match {
|
||||||
case Some(db) =>
|
case Some(db) =>
|
||||||
require(
|
require(
|
||||||
db.state == DLCState.Offered || db.state == DLCState.Accepted || db.state == DLCState.Signed,
|
db.state == DLCState.Offered || db.state == DLCState.Accepted || db.state == DLCState.Signed,
|
||||||
"Cannot cancel a DLC after it has been signed")
|
"Cannot cancel a DLC after it has been signed")
|
||||||
|
db
|
||||||
case None =>
|
case None =>
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
s"No DLC Found with dlc id ${dlcId.hex}")
|
s"No DLC Found with dlc id ${dlcId.hex}")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inputs <- dlcInputsDAO.findByDLCId(dlcId, dlcDb.isInitiator)
|
||||||
|
dbs <- spendingInfoDAO.findByOutPoints(inputs.map(_.outPoint))
|
||||||
|
// allow this to fail in the case they have already been unreserved
|
||||||
|
_ <- unmarkUTXOsAsReserved(dbs).recover { case _: Throwable => () }
|
||||||
|
|
||||||
_ <- dlcSigsDAO.deleteByDLCId(dlcId)
|
_ <- dlcSigsDAO.deleteByDLCId(dlcId)
|
||||||
_ <- dlcRefundSigDAO.deleteByDLCId(dlcId)
|
_ <- dlcRefundSigDAO.deleteByDLCId(dlcId)
|
||||||
_ <- dlcInputsDAO.deleteByDLCId(dlcId)
|
_ <- dlcInputsDAO.deleteByDLCId(dlcId)
|
||||||
|
|
Loading…
Add table
Reference in a new issue