diff --git a/go.mod b/go.mod index ece87be08..2e4fb70c3 100644 --- a/go.mod +++ b/go.mod @@ -28,7 +28,6 @@ require ( github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542 // indirect github.com/holiman/uint256 v1.2.3 // indirect github.com/iancoleman/orderedmap v0.3.0 // indirect - github.com/iotaledger/hive.go/codegen v0.0.0-20231005142627-86973b2edb3b // indirect github.com/kr/text v0.2.0 // indirect github.com/mr-tron/base58 v1.2.0 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect diff --git a/go.sum b/go.sum index 37ff8d311..e06d4a86a 100644 --- a/go.sum +++ b/go.sum @@ -23,8 +23,6 @@ github.com/holiman/uint256 v1.2.3 h1:K8UWO1HUJpRMXBxbmaY1Y8IAMZC/RsKB+ArEnnK4l5o github.com/holiman/uint256 v1.2.3/go.mod h1:SC8Ryt4n+UBbPbIBKaG9zbbDlp4jOru9xFZmPzLUTxw= github.com/iancoleman/orderedmap v0.3.0 h1:5cbR2grmZR/DiVt+VJopEhtVs9YGInGIxAoMJn+Ichc= github.com/iancoleman/orderedmap v0.3.0/go.mod h1:XuLcCUkdL5owUCQeF2Ue9uuw1EptkJDkXXS7VoV7XGE= -github.com/iotaledger/hive.go/codegen v0.0.0-20231005142627-86973b2edb3b h1:RpCqfmmxrkTdxPm56UzF1QuHppTo3VtyzhfaUUfzVA0= -github.com/iotaledger/hive.go/codegen v0.0.0-20231005142627-86973b2edb3b/go.mod h1:zBiQaY4DL7xx/gNgb1MWqMaV62x2o937nBCEaW++ztI= github.com/iotaledger/hive.go/constraints v0.0.0-20231005142627-86973b2edb3b h1:8FdKoB755PjCL1aHTi+2rPt9lCUS4B2wg2fNKykw5dc= github.com/iotaledger/hive.go/constraints v0.0.0-20231005142627-86973b2edb3b/go.mod h1:dOBOM2s4se3HcWefPe8sQLUalGXJ8yVXw58oK8jke3s= github.com/iotaledger/hive.go/core v1.0.0-rc.3.0.20231005142627-86973b2edb3b h1:gQ+Wqg8h/LRpgX3CsmaOZYdMIBVL4fAPIrZbmA6Wn3Q= diff --git a/nodeclient/blockissuer_client.go b/nodeclient/blockissuer_client.go index 3cebf1be2..9545f1f2f 100644 --- a/nodeclient/blockissuer_client.go +++ b/nodeclient/blockissuer_client.go @@ -25,7 +25,6 @@ var ( ) type ( - // BlockIssuerClient is a client which queries the optional blockissuer functionality of a node. BlockIssuerClient interface { // Info returns the info of the block issuer. diff --git a/unlock_cond.go b/unlock_cond.go index 7d202eca6..4cfc617a0 100644 --- a/unlock_cond.go +++ b/unlock_cond.go @@ -199,6 +199,25 @@ func (f UnlockConditionSet) HasExpirationCondition() bool { return f.Expiration() != nil } +// CheckExpirationCondition returns the expiration return ident in case an expiration condition was set and +// the future bound slot is greater than the expiration slot. +// In case the past bound slot is smaller than the expiration slot, "nil" is returned to indicate that the original owner can unlock the output. +// The range in between is not unlockable by anyone and an "ErrExpirationConditionUnlockFailed" error will be returned. +func (f UnlockConditionSet) CheckExpirationCondition(futureBoundedSlotIndex, pastBoundedSlotIndex SlotIndex) (Address, error) { + if f.HasExpirationCondition() { + if ok, returnIdent := f.ReturnIdentCanUnlock(futureBoundedSlotIndex); ok { + return returnIdent, nil + } + + if !f.OwnerIdentCanUnlock(pastBoundedSlotIndex) { + return nil, ErrExpirationConditionUnlockFailed + } + } + + //nolint:nilnil // nil, nil is ok in this context, even if it is not go idiomatic + return nil, nil +} + // HasTimelockCondition tells whether this set has a TimelockUnlockCondition. func (f UnlockConditionSet) HasTimelockCondition() bool { return f.Timelock() != nil