Multiple spending paths
📝 Draft. This chapter has not been reviewed yet — content may be incomplete or change.
Problem. Build a covenant that can be spent in more than one way — e.g. a cooperative path and a cancel/timeout path — and select between them at spend time.
🚧 This recipe is a stub. Outline of what it will cover:
- A Simplicity program with
Either<(), ()>paths (PATH::LEFT/PATH::RIGHT).- Selecting a path with a
simplicityhlwitness:Left(())vsRight(()).- Worked example: the lending
pre_lockcovenant —SetupLendingtakes the left path;CancelOffertakes the right path with a borrower signature.- Using
required_indexon inputs so the covenant's introspection lines up.- Cooperative vs unilateral paths, and how they show up in
lifecycle.
See the pre_lock discussion in the
lending walkthrough in the meantime.