-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This adds a restriction to be used with `ValidatorStackRestriction` that enforces a timelock condition with a specific value be in the delegated puzzle output.
- Loading branch information
Showing
6 changed files
with
115 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
chia/wallet/puzzles/custody/restriction_puzzles/restrictions.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
from __future__ import annotations | ||
|
||
from dataclasses import dataclass | ||
|
||
from chia.types.blockchain_format.program import Program | ||
from chia.types.blockchain_format.sized_bytes import bytes32 | ||
from chia.util.ints import uint64 | ||
from chia.wallet.puzzles.load_clvm import load_clvm_maybe_recompile | ||
|
||
TIMELOCK_WRAPPER = load_clvm_maybe_recompile( | ||
"timelock.clsp", package_or_requirement="chia.wallet.puzzles.custody.restriction_puzzles.wrappers" | ||
) | ||
|
||
|
||
@dataclass(frozen=True) | ||
class Timelock: | ||
timelock: uint64 | ||
|
||
@property | ||
def member_not_dpuz(self) -> bool: | ||
return False | ||
|
||
def memo(self, nonce: int) -> Program: | ||
return Program.to(None) | ||
|
||
def puzzle(self, nonce: int) -> Program: | ||
return TIMELOCK_WRAPPER.curry(self.timelock) | ||
|
||
def puzzle_hash(self, nonce: int) -> bytes32: | ||
return self.puzzle(nonce).get_tree_hash() |
Empty file.
18 changes: 18 additions & 0 deletions
18
chia/wallet/puzzles/custody/restriction_puzzles/wrappers/timelock.clsp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
(mod | ||
( | ||
TIMELOCK | ||
Conditions | ||
) | ||
|
||
(include condition_codes.clib) | ||
(include utility_macros.clib) | ||
|
||
(defun check_conditions (TIMELOCK conditions) | ||
(if (and (= (f (f conditions)) ASSERT_SECONDS_RELATIVE) (= (f (r (f conditions))) TIMELOCK)) | ||
conditions | ||
(check_conditions TIMELOCK (r conditions)) | ||
) | ||
) | ||
|
||
(check_conditions TIMELOCK Conditions) | ||
) |
1 change: 1 addition & 0 deletions
1
chia/wallet/puzzles/custody/restriction_puzzles/wrappers/timelock.clsp.hex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
ff02ffff01ff02ff06ffff04ff02ffff04ff05ffff04ff0bff8080808080ffff04ffff01ff50ff02ffff03ffff02ffff03ffff09ff23ff0480ffff01ff02ffff03ffff09ff53ff0580ffff01ff0101ff8080ff0180ff8080ff0180ffff010bffff01ff02ff06ffff04ff02ffff04ff05ffff04ff1bff808080808080ff0180ff018080 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters