|
18 | 18 | from chia.data_layer.data_layer_util import DLProof, VerifyProofResponse, dl_verify_proof |
19 | 19 | from chia.data_layer.data_layer_wallet import DataLayerWallet, Mirror |
20 | 20 | from chia.pools.pool_wallet import PoolWallet |
21 | | -from chia.pools.pool_wallet_info import FARMING_TO_POOL, PoolState, PoolWalletInfo, create_pool_state |
| 21 | +from chia.pools.pool_wallet_info import ( |
| 22 | + FARMING_TO_POOL, |
| 23 | + PoolState, |
| 24 | + PoolWalletInfo, |
| 25 | + create_pool_state, |
| 26 | + initial_pool_state_from_dict, |
| 27 | +) |
22 | 28 | from chia.protocols.outbound_message import NodeType |
23 | 29 | from chia.rpc.rpc_server import Endpoint, EndpointResult, default_get_connections |
24 | 30 | from chia.rpc.util import ALL_TRANSLATION_LAYERS, RpcEndpoint, marshal |
|
47 | 53 | parse_timelock_info, |
48 | 54 | ) |
49 | 55 | from chia.wallet.derive_keys import ( |
50 | | - MAX_POOL_WALLETS, |
51 | 56 | master_sk_to_farmer_sk, |
52 | 57 | master_sk_to_pool_sk, |
53 | 58 | match_address_to_sk, |
@@ -1245,32 +1250,12 @@ async def create_new_wallet( # type: ignore[return] |
1245 | 1250 | ) |
1246 | 1251 | elif request.wallet_type == CreateNewWalletType.POOL_WALLET: |
1247 | 1252 | if request.mode == WalletCreationMode.NEW: |
1248 | | - owner_puzzle_hash: bytes32 = await action_scope.get_puzzle_hash(self.service.wallet_state_manager) |
1249 | | - |
1250 | | - from chia.pools.pool_wallet_info import initial_pool_state_from_dict |
1251 | | - |
1252 | 1253 | async with self.service.wallet_state_manager.lock: |
1253 | | - # We assign a pseudo unique id to each pool wallet, so that each one gets its own deterministic |
1254 | | - # owner and auth keys. The public keys will go on the blockchain, and the private keys can be found |
1255 | | - # using the root SK and trying each index from zero. The indexes are not fully unique though, |
1256 | | - # because the PoolWallet is not created until the tx gets confirmed on chain. Therefore if we |
1257 | | - # make multiple pool wallets at the same time, they will have the same ID. |
1258 | | - max_pwi = 1 |
1259 | | - for _, wallet in self.service.wallet_state_manager.wallets.items(): |
1260 | | - if wallet.type() == WalletType.POOLING_WALLET: |
1261 | | - max_pwi += 1 |
1262 | | - |
1263 | | - if max_pwi + 1 >= (MAX_POOL_WALLETS - 1): |
1264 | | - raise ValueError(f"Too many pool wallets ({max_pwi}), cannot create any more on this key.") |
1265 | | - |
1266 | | - owner_pk: G1Element = self.service.wallet_state_manager.main_wallet.hardened_pubkey_for_path( |
1267 | | - # copied from chia.wallet.derive_keys. Could maybe be an exported constant in the future. |
1268 | | - [12381, 8444, 5, max_pwi] |
1269 | | - ) |
1270 | | - |
1271 | 1254 | assert request.initial_target_state is not None # mypy doesn't know about our __post_init__ |
1272 | 1255 | initial_target_state = initial_pool_state_from_dict( |
1273 | | - request.initial_target_state, owner_pk, owner_puzzle_hash |
| 1256 | + request.initial_target_state, |
| 1257 | + self.service.wallet_state_manager.new_pool_wallet_pubkey(), |
| 1258 | + await action_scope.get_puzzle_hash(self.service.wallet_state_manager), |
1274 | 1259 | ) |
1275 | 1260 | assert initial_target_state is not None |
1276 | 1261 |
|
|
0 commit comments