mirror of
https://github.com/Chia-Network/chia-blockchain.git
synced 2026-09-27 17:46:28 -04:00
Fix pubkey is not synthetic issue
This commit is contained in:
@@ -12,7 +12,9 @@ from chia.wallet.nft_wallet.nft_info import NFTCoinInfo, NFTInfo
|
||||
from chia.wallet.nft_wallet.uncurry_nft import UncurriedNFT
|
||||
from chia.wallet.puzzles.cat_loader import CAT_MOD
|
||||
from chia.wallet.puzzles.load_clvm import load_clvm
|
||||
from chia.wallet.puzzles.p2_delegated_puzzle_or_hidden_puzzle import solution_for_conditions
|
||||
from chia.wallet.puzzles.p2_delegated_puzzle_or_hidden_puzzle import solution_for_conditions, \
|
||||
puzzle_for_public_key_and_hidden_puzzle_hash, puzzle_for_pk, calculate_synthetic_public_key, \
|
||||
DEFAULT_HIDDEN_PUZZLE_HASH
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
SINGLETON_TOP_LAYER_MOD = load_clvm("singleton_top_layer_v1_1.clvm")
|
||||
@@ -227,7 +229,8 @@ def create_ownership_layer_transfer_solution(
|
||||
str(trade_prices_list),
|
||||
new_pubkey,
|
||||
)
|
||||
puzhash = STANDARD_PUZZLE_MOD.curry(new_pubkey).get_tree_hash()
|
||||
synthetic_pk: bytes = bytes(calculate_synthetic_public_key(new_pubkey, DEFAULT_HIDDEN_PUZZLE_HASH))
|
||||
puzhash = STANDARD_PUZZLE_MOD.curry(synthetic_pk).get_tree_hash()
|
||||
condition_list = [
|
||||
[
|
||||
51,
|
||||
@@ -235,7 +238,7 @@ def create_ownership_layer_transfer_solution(
|
||||
1,
|
||||
[puzhash],
|
||||
],
|
||||
[-10, new_did, trade_prices_list, new_pubkey, [new_did_inner_hash]],
|
||||
[-10, new_did, trade_prices_list, synthetic_pk, [new_did_inner_hash]],
|
||||
]
|
||||
log.debug("Condition list raw: %r", condition_list)
|
||||
solution = Program.to(
|
||||
|
||||
@@ -215,7 +215,8 @@ class NFTWallet:
|
||||
derivation_record: Optional[
|
||||
DerivationRecord
|
||||
] = await self.wallet_state_manager.puzzle_store.get_derivation_record_for_puzzle_hash(p2_puzzle_hash)
|
||||
if derivation_record:
|
||||
|
||||
if derivation_record and not uncurried_nft.supports_did:
|
||||
p2_puzzle = puzzle_for_pk(derivation_record.pubkey)
|
||||
else:
|
||||
# we don't have this puzhash in puzzle store
|
||||
@@ -251,7 +252,8 @@ class NFTWallet:
|
||||
if new_coin.puzzle_hash == child_puzzle.get_tree_hash():
|
||||
child_coin = new_coin
|
||||
break
|
||||
|
||||
else:
|
||||
raise ValueError("Not a valid NFT")
|
||||
launcher_coin_states: List[CoinState] = await self.wallet_state_manager.wallet_node.get_coin_state(
|
||||
[singleton_id]
|
||||
)
|
||||
@@ -422,13 +424,11 @@ class NFTWallet:
|
||||
|
||||
bundles_to_agg = [tx_record.spend_bundle, launcher_sb]
|
||||
|
||||
if not target_puzzle_hash:
|
||||
target_puzzle_hash = p2_inner_puzzle.get_tree_hash()
|
||||
record: Optional[DerivationRecord] = None
|
||||
# Create inner solution for eve spend
|
||||
if did_id is not None:
|
||||
record = await self.wallet_state_manager.puzzle_store.get_derivation_record_for_puzzle_hash(
|
||||
p2_inner_puzzle.get_tree_hash()
|
||||
target_puzzle_hash
|
||||
)
|
||||
self.log.debug("Got back a pubkey record: %s", record)
|
||||
if not record:
|
||||
@@ -477,7 +477,6 @@ class NFTWallet:
|
||||
name=bytes32(token_bytes()),
|
||||
memos=list(compute_memos(full_spend).items()),
|
||||
)
|
||||
self.log.info("Minting NFT with hint:%s", nft_record.memos)
|
||||
await self.standard_wallet.push_transaction(nft_record)
|
||||
return nft_record.spend_bundle
|
||||
|
||||
@@ -723,6 +722,7 @@ class NFTWallet:
|
||||
return await cls.create_new_nft_wallet(
|
||||
wallet_state_manager,
|
||||
wallet,
|
||||
None,
|
||||
name,
|
||||
in_transaction,
|
||||
)
|
||||
|
||||
@@ -716,19 +716,18 @@ class WalletStateManager:
|
||||
"""
|
||||
wallet_id = None
|
||||
wallet_type = None
|
||||
self.log.debug("Handling NFT: %s", coin_spend)
|
||||
did_id = uncurried_nft.owner_did
|
||||
for wallet_info in await self.get_all_wallet_info_entries():
|
||||
if wallet_info.type == WalletType.NFT:
|
||||
nft_wallet_info: NFTWalletInfo = NFTWalletInfo.from_json_dict(json.loads(wallet_info.data))
|
||||
if nft_wallet_info.did_id == did_id:
|
||||
self.log.debug(
|
||||
"Checking NFT wallet %r and inner puzzle %s",
|
||||
wallet_info.name,
|
||||
uncurried_nft.inner_puzzle.get_tree_hash(),
|
||||
)
|
||||
wallet_id = wallet_info.id
|
||||
wallet_type = WalletType.NFT
|
||||
self.log.debug("Handling NFT: %s, DID: %s", coin_spend, did_id)
|
||||
for wallet_info in await self.get_all_wallet_info_entries(wallet_type=WalletType.NFT):
|
||||
nft_wallet_info: NFTWalletInfo = NFTWalletInfo.from_json_dict(json.loads(wallet_info.data))
|
||||
if nft_wallet_info.did_id == did_id:
|
||||
self.log.debug(
|
||||
"Checking NFT wallet %r and inner puzzle %s",
|
||||
wallet_info.name,
|
||||
uncurried_nft.inner_puzzle.get_tree_hash(),
|
||||
)
|
||||
wallet_id = wallet_info.id
|
||||
wallet_type = WalletType.NFT
|
||||
|
||||
if wallet_id is None:
|
||||
self.log.info(
|
||||
@@ -748,7 +747,6 @@ class WalletStateManager:
|
||||
self, coin_states: List[CoinState], peer: WSChiaConnection, fork_height: Optional[uint32]
|
||||
) -> None:
|
||||
# TODO: add comment about what this method does
|
||||
|
||||
# Input states should already be sorted by cs_height, with reorgs at the beginning
|
||||
curr_h = -1
|
||||
for c_state in coin_states:
|
||||
|
||||
@@ -608,9 +608,15 @@ async def test_nft_with_did_wallet_creation(two_wallet_nodes: Any, trusted: Any)
|
||||
)
|
||||
assert resp.get("success")
|
||||
sb = resp["spend_bundle"]
|
||||
|
||||
memos = compute_memos(sb)
|
||||
assert memos
|
||||
puzhashes = []
|
||||
[puzhashes.extend(list(x)) for x in memos.values()]
|
||||
assert len(puzhashes) > 0
|
||||
for puzhash in puzhashes:
|
||||
assert wallet_0.wallet_state_manager.puzzle_store.get_derivation_record_for_puzzle_hash(puzhash)
|
||||
# ensure hints are generated
|
||||
assert compute_memos(sb)
|
||||
|
||||
await time_out_assert_not_none(5, full_node_api.full_node.mempool_manager.get_spendbundle, sb.name())
|
||||
|
||||
for i in range(1, num_blocks):
|
||||
|
||||
Reference in New Issue
Block a user