mirror of
https://github.com/bitcoin-s/bitcoin-s.git
synced 2025-01-19 05:43:51 +01:00
Add AdaptorSigComputation states to states that a DLC can be cancelled in (#4158)
This commit is contained in:
parent
5113cac6c2
commit
0bb0d9acdb
@ -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
|
||||
|
@ -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(
|
||||
|
Loading…
Reference in New Issue
Block a user