bad ports

This commit is contained in:
Matt
2026-08-07 09:32:49 +12:00
parent b3a863981b
commit bbf665fe65
3 changed files with 22 additions and 3 deletions
@@ -28,6 +28,7 @@ from chia.util.timing import adjusted_timeout
from chia.wallet import wallet_state_manager as wsm_mod
from chia.wallet.derivation_record import DerivationRecord
from chia.wallet.derive_keys import master_sk_to_wallet_sk, master_sk_to_wallet_sk_unhardened
from chia.wallet.nft_wallet import nft_wallet as nft_wallet_mod
from chia.wallet.nft_wallet.nft_wallet import NFTWallet
from chia.wallet.nft_wallet.uncurry_nft import NFTCoinData, UncurriedNFT
from chia.wallet.remote_wallet.remote_wallet import RemoteWallet
@@ -971,8 +972,8 @@ async def test_handle_nft_auto_add_limit(
def fake_get_new_owner_did(_unft: UncurriedNFT, _solution: Program) -> bytes32:
return foreign_did_id
monkeypatch.setattr(wsm_mod, "get_metadata_and_phs", fake_get_metadata_and_phs)
monkeypatch.setattr(wsm_mod, "get_new_owner_did", fake_get_new_owner_did)
monkeypatch.setattr(nft_wallet_mod, "get_metadata_and_phs", fake_get_metadata_and_phs)
monkeypatch.setattr(nft_wallet_mod, "get_new_owner_did", fake_get_new_owner_did)
nft_data = _build_fake_nft_data(
old_p2_puzhash=old_p2_puzhash,
+18
View File
@@ -356,6 +356,24 @@ class NFTWallet:
if wallet_identifier is None and new_derivation_record is not None:
# Cannot find an existed NFT wallet for the new NFT
# Bound the number of auto-created DID-scoped NFT wallets. `new_did_id`
# is parsed from attacker-controllable NFT transfer data; without a cap a
# peer that spams inbound NFTs with unique foreign DIDs can force
# unbounded wallet creation. Mirrors `did_auto_add_limit`.
# Counter excludes the canonical did_id=None wallet so attacker-driven
# fanout cannot displace a user's legitimate no-DID NFT receives.
nft_wallet_count = sum(
1
for w in wallet_state_manager.wallets.values()
if isinstance(w, NFTWallet) and w.nft_wallet_info.did_id is not None
)
nft_limit = wallet_state_manager.config.get("nft_auto_add_limit", 100)
if new_did_id is not None and nft_wallet_count >= nft_limit:
wallet_state_manager.log.warning(
f"You are at the max configured limit of {nft_limit} NFT wallets. "
f"Ignoring received NFT {uncurried_nft.singleton_launcher_id.hex()} with DID {new_did_id.hex()}"
)
return None
wallet_state_manager.log.info(
"Cannot find a NFT wallet for NFT_ID: %s DID_ID: %s, creating a new one.",
uncurried_nft.singleton_launcher_id,
+1 -1
View File
@@ -449,7 +449,7 @@ class PlotNFT2Wallet:
else:
matched_plotnft_wallet_id = None
if matched_plotnft_wallet_id is None and coin_spend.coin.parent_coin_info == next_plot_nft.launcher_id:
matched_plotnft_wallet_id = uint32(len(wallet_state_manager.wallets) + 1)
matched_plotnft_wallet_id = uint32(max(wallet_state_manager.wallets.keys()) + 1)
wallet_state_manager.wallets[matched_plotnft_wallet_id] = await PlotNFT2Wallet.create(
wallet_state_manager=wallet_state_manager,
xch_wallet=wallet_state_manager.main_wallet,