Skip to content

Commit

Permalink
Merge pull request #236 from Chia-Network/offer-v2
Browse files Browse the repository at this point in the history
Update offer puzzle to v2
  • Loading branch information
mando222 authored Sep 26, 2023
2 parents 1942c7e + 44b4050 commit d2b607e
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions docs/primitives/offers.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ You can use a wallet to generate an offer file for a given trade, then distribut

## Settlement Payments Code {#code}

This is the source code of the settlement payments puzzle, which can also be found in the chia-blockchain repository in the puzzle [`settlement_payments.clvm`](https://github.com/Chia-Network/chia-blockchain/blob/164fd158c8626893bc45ba00b87ae69d2ab5f8b7/chia/wallet/puzzles/settlement_payments.clvm).
This is the source code of the settlement payments puzzle, which can also be found in the chia-blockchain repository in the puzzle [`settlement_payments.clvm`](https://github.com/Chia-Network/chia-blockchain/blob/8224d2fd657780b224a1fc40d3081ce734d70016/chia/wallet/puzzles/settlement_payments.clsp).

<details>
<summary>Expand Settlement Payments Puzzle</summary>
Expand All @@ -31,25 +31,29 @@ This is the source code of the settlement payments puzzle, which can also be fou
;; The idea is the other side of this trade requires observing the announcement from a
;; `settlement_payments` puzzle hash as a condition of one or more coin spends.
(include condition_codes.clvm)
(include condition_codes.clib)
(include utility_macros.clib)
(defun sha256tree (TREE)
(if (l TREE)
(sha256 2 (sha256tree (f TREE)) (sha256tree (r TREE)))
(sha256 1 TREE)
)
(if (l TREE)
(sha256 2 (sha256tree (f TREE)) (sha256tree (r TREE)))
(sha256 1 TREE)
)
)
(defun create_coins_for_payment (payment_params so_far)
(if payment_params
(c (c CREATE_COIN (f payment_params)) (create_coins_for_payment (r payment_params) so_far))
(assert (> (f (r (f payment_params))) 0) ; assert the amount is positive
; then
(c (c CREATE_COIN (f payment_params)) (create_coins_for_payment (r payment_params) so_far))
)
so_far
)
)
(defun-inline create_announcement_for_payment (notarized_payment)
(list CREATE_PUZZLE_ANNOUNCEMENT
(sha256tree notarized_payment))
(list CREATE_PUZZLE_ANNOUNCEMENT
(sha256tree notarized_payment))
)
(defun-inline augment_condition_list (notarized_payment so_far)
Expand Down

0 comments on commit d2b607e

Please sign in to comment.