|
23 | 23 | from chia.rpc.util import ALL_TRANSLATION_LAYERS, RpcEndpoint, marshal |
24 | 24 | from chia.server.ws_connection import WSChiaConnection |
25 | 25 | from chia.types.blockchain_format.coin import coin_as_list |
26 | | -from chia.types.blockchain_format.program import INFINITE_COST, Program, run_with_cost |
| 26 | +from chia.types.blockchain_format.program import Program |
27 | 27 | from chia.types.coin_record import CoinRecord |
28 | 28 | from chia.types.signing_mode import CHIP_0002_SIGN_MESSAGE_PREFIX, SigningMode |
29 | 29 | from chia.util.bech32m import decode_puzzle_hash, encode_puzzle_hash |
|
39 | 39 | from chia.wallet.cat_wallet.cat_wallet import CATWallet |
40 | 40 | from chia.wallet.conditions import ( |
41 | 41 | AssertCoinAnnouncement, |
| 42 | + AssertConcurrentSpend, |
42 | 43 | AssertPuzzleAnnouncement, |
43 | 44 | Condition, |
44 | 45 | ConditionValidTimes, |
45 | 46 | CreateCoin, |
46 | 47 | CreateCoinAnnouncement, |
47 | 48 | CreatePuzzleAnnouncement, |
48 | 49 | conditions_from_json_dicts, |
49 | | - parse_conditions_non_consensus, |
50 | 50 | parse_timelock_info, |
51 | 51 | ) |
52 | 52 | from chia.wallet.derive_keys import ( |
@@ -1007,50 +1007,21 @@ async def push_transactions( |
1007 | 1007 | ) -> PushTransactionsResponse: |
1008 | 1008 | if not action_scope.config.push: |
1009 | 1009 | raise ValueError("Cannot push transactions if push is False") |
| 1010 | + tx_removals = [c for tx in request.transactions for c in tx.removals] |
1010 | 1011 | async with action_scope.use() as interface: |
1011 | 1012 | interface.side_effects.transactions.extend(request.transactions) |
1012 | | - if request.fee != 0: |
1013 | | - all_conditions_and_origins = [ |
1014 | | - (condition, cs.coin.name()) |
1015 | | - for tx in interface.side_effects.transactions |
1016 | | - if tx.spend_bundle is not None |
1017 | | - for cs in tx.spend_bundle.coin_spends |
1018 | | - for condition in run_with_cost(cs.puzzle_reveal, INFINITE_COST, cs.solution)[1].as_iter() |
1019 | | - ] |
1020 | | - create_coin_announcement = next( |
1021 | | - condition |
1022 | | - for condition in parse_conditions_non_consensus( |
1023 | | - [con for con, coin in all_conditions_and_origins], abstractions=False |
1024 | | - ) |
1025 | | - if isinstance(condition, CreateCoinAnnouncement) |
1026 | | - ) |
1027 | | - announcement_origin = next( |
1028 | | - coin |
1029 | | - for condition, coin in all_conditions_and_origins |
1030 | | - if condition == create_coin_announcement.to_program() |
1031 | | - ) |
1032 | | - async with self.service.wallet_state_manager.new_action_scope( |
1033 | | - dataclasses.replace( |
1034 | | - action_scope.config.tx_config, |
1035 | | - excluded_coin_ids=[ |
1036 | | - *action_scope.config.tx_config.excluded_coin_ids, |
1037 | | - *(c.name() for tx in interface.side_effects.transactions for c in tx.removals), |
1038 | | - ], |
1039 | | - ), |
1040 | | - push=False, |
1041 | | - ) as inner_action_scope: |
1042 | | - await self.service.wallet_state_manager.main_wallet.create_tandem_xch_tx( |
1043 | | - request.fee, |
1044 | | - inner_action_scope, |
1045 | | - extra_conditions=( |
1046 | | - *extra_conditions, |
1047 | | - CreateCoinAnnouncement( |
1048 | | - create_coin_announcement.msg, announcement_origin |
1049 | | - ).corresponding_assertion(), |
1050 | | - ), |
1051 | | - ) |
1052 | | - |
1053 | | - interface.side_effects.transactions.extend(inner_action_scope.side_effects.transactions) |
| 1013 | + interface.side_effects.selected_coins.extend(tx_removals) |
| 1014 | + if request.fee != 0: |
| 1015 | + await self.service.wallet_state_manager.main_wallet.create_tandem_xch_tx( |
| 1016 | + request.fee, |
| 1017 | + action_scope, |
| 1018 | + extra_conditions=( |
| 1019 | + *extra_conditions, |
| 1020 | + AssertConcurrentSpend(tx_removals[0].name()), |
| 1021 | + ), |
| 1022 | + ) |
| 1023 | + elif extra_conditions != tuple(): |
| 1024 | + raise ValueError("Cannot add conditions to a transaction if no new fee spend is being added") |
1054 | 1025 |
|
1055 | 1026 | return PushTransactionsResponse([], []) # tx_endpoint takes care of this |
1056 | 1027 |
|
|
0 commit comments