Add AdaptorSigComputation states to states that a DLC can be cancelled in (#4158)

This commit is contained in:
Chris Stewart 2022-03-03 20:52:19 -06:00 committed by GitHub
parent 5113cac6c2
commit 0bb0d9acdb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 2 deletions

View File

@ -101,6 +101,15 @@ object DLCState extends StringFactory[DLCState] {
RemoteClaimed,
Refunded)
/** The states where you can cancel a DLC in your wallet */
val cancellableState = Vector(
Offered,
AcceptComputingAdaptorSigs,
Accepted,
SignComputingAdaptorSigs,
Signed
)
override def fromString(str: String): DLCState = {
all.find(state => str.toLowerCase() == state.toString.toLowerCase) match {
case Some(state) => state

View File

@ -246,8 +246,8 @@ abstract class DLCWallet
dlcDb = dlcOpt match {
case Some(db) =>
require(
db.state == DLCState.Offered || db.state == DLCState.Accepted || db.state == DLCState.Signed,
"Cannot cancel a DLC after it has been signed")
DLCState.cancellableState.exists(_ == db.state),
s"Cannot cancel a DLC after it has been signed, state=${db.state}")
db
case None =>
throw new IllegalArgumentException(