Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CHIA-2224] Add some extra safety into create_message_spend #19153

Merged
merged 2 commits into from
Jan 27, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions chia/wallet/did_wallet/did_wallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -765,20 +765,28 @@ async def create_message_spend(
assert self.did_info.origin_coin is not None
coin = await self.get_coin()
innerpuz: Program = self.did_info.current_inner
assert (
create_singleton_puzzle(
innerpuz,
self.did_info.origin_coin.name(),
).get_tree_hash()
== coin.puzzle_hash
)
uncurried = did_wallet_puzzles.uncurry_innerpuz(innerpuz)
assert uncurried is not None
p2_puzzle, id_list, num_of_backup_ids_needed, _, metadata = uncurried
Rigidity marked this conversation as resolved.
Show resolved Hide resolved
# Quote message puzzle & solution
if action_scope.config.tx_config.reuse_puzhash:
new_innerpuzzle_hash = innerpuz.get_tree_hash()
uncurried = did_wallet_puzzles.uncurry_innerpuz(innerpuz)
assert uncurried is not None
p2_ph = uncurried[0].get_tree_hash()
p2_ph = p2_puzzle.get_tree_hash()
else:
p2_ph = await self.standard_wallet.get_puzzle_hash(new=True)
new_innerpuzzle_hash = did_wallet_puzzles.get_inner_puzhash_by_p2(
p2_puzhash=p2_ph,
recovery_list=self.did_info.backup_ids,
num_of_backup_ids_needed=self.did_info.num_of_backup_ids_needed,
recovery_list=[bytes32(id.as_atom()) for id in id_list.as_iter()],
Rigidity marked this conversation as resolved.
Show resolved Hide resolved
num_of_backup_ids_needed=uint64(num_of_backup_ids_needed.as_int()),
launcher_id=self.did_info.origin_coin.name(),
metadata=did_wallet_puzzles.metadata_to_program(json.loads(self.did_info.metadata)),
metadata=metadata,
)
p2_solution = self.standard_wallet.make_solution(
primaries=[Payment(puzzle_hash=new_innerpuzzle_hash, amount=uint64(coin.amount), memos=[p2_ph])],
Expand Down
Loading