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.- Declaring inputs in the order the covenant's introspection expects.
- Cooperative vs unilateral paths, and how each is enforced by the covenant.
See the pre_lock discussion in
Accepting or cancelling the offer (and the
lending covenant in Settling the loan)
in the meantime.