105
105
from chia .wallet .wallet_request_types import (
106
106
AddKey ,
107
107
CheckDeleteKey ,
108
+ ClawbackPuzzleDecoratorOverride ,
108
109
CombineCoins ,
109
110
DefaultCAT ,
110
111
DeleteKey ,
136
137
PushTransactions ,
137
138
PushTX ,
138
139
RoyaltyAsset ,
140
+ SendTransaction ,
139
141
SetWalletResyncOnStartup ,
140
142
SplitCoins ,
141
143
VerifySignature ,
@@ -378,24 +380,25 @@ async def test_send_transaction(wallet_rpc_environment: WalletRpcTestEnvironment
378
380
addr = encode_puzzle_hash (await action_scope .get_puzzle_hash (wallet_2 .wallet_state_manager ), "txch" )
379
381
tx_amount = uint64 (15600000 )
380
382
with pytest .raises (ValueError ):
381
- await client .send_transaction (1 , uint64 (100000000000000001 ), addr , DEFAULT_TX_CONFIG )
383
+ await client .send_transaction (
384
+ SendTransaction (wallet_id = uint32 (1 ), amount = uint64 (100000000000000001 ), address = addr , push = True ),
385
+ DEFAULT_TX_CONFIG ,
386
+ )
382
387
383
388
# Tests sending a basic transaction
384
389
extra_conditions = (Remark (Program .to (("test" , None ))),)
385
390
non_existent_coin = Coin (bytes32 .zeros , bytes32 .zeros , uint64 (0 ))
386
391
tx_no_push = (
387
392
await client .send_transaction (
388
- 1 ,
389
- tx_amount ,
390
- addr ,
391
- memos = ["this is a basic tx" ],
393
+ SendTransaction (
394
+ wallet_id = uint32 (1 ), amount = tx_amount , address = addr , memos = ["this is a basic tx" ], push = False
395
+ ),
392
396
tx_config = DEFAULT_TX_CONFIG .override (
393
397
excluded_coin_amounts = [uint64 (250000000000 )],
394
398
excluded_coin_ids = [non_existent_coin .name ()],
395
399
reuse_puzhash = True ,
396
400
),
397
401
extra_conditions = extra_conditions ,
398
- push = False ,
399
402
)
400
403
).transaction
401
404
response = await client .fetch (
@@ -837,12 +840,14 @@ async def test_spend_clawback_coins(wallet_rpc_environment: WalletRpcTestEnviron
837
840
wallet_2_puzhash = await action_scope .get_puzzle_hash (wallet_2 .wallet_state_manager )
838
841
tx = (
839
842
await wallet_1_rpc .send_transaction (
840
- wallet_id = 1 ,
841
- amount = uint64 (500 ),
842
- address = encode_puzzle_hash (wallet_2_puzhash , "txch" ),
843
+ SendTransaction (
844
+ wallet_id = uint32 (1 ),
845
+ amount = uint64 (500 ),
846
+ address = encode_puzzle_hash (wallet_2_puzhash , "txch" ),
847
+ puzzle_decorator = [ClawbackPuzzleDecoratorOverride (decorator = "CLAWBACK" , clawback_timelock = uint64 (5 ))],
848
+ push = True ,
849
+ ),
843
850
tx_config = DEFAULT_TX_CONFIG ,
844
- fee = uint64 (0 ),
845
- puzzle_decorator_override = [{"decorator" : "CLAWBACK" , "clawback_timelock" : 5 }],
846
851
)
847
852
).transaction
848
853
clawback_coin_id_1 = tx .additions [0 ].name ()
@@ -851,12 +856,14 @@ async def test_spend_clawback_coins(wallet_rpc_environment: WalletRpcTestEnviron
851
856
await full_node_api .wait_for_wallet_synced (wallet_node = wallet_2_node , timeout = 20 )
852
857
tx = (
853
858
await wallet_2_rpc .send_transaction (
854
- wallet_id = 1 ,
855
- amount = uint64 (500 ),
856
- address = encode_puzzle_hash (wallet_1_puzhash , "txch" ),
859
+ SendTransaction (
860
+ wallet_id = uint32 (1 ),
861
+ amount = uint64 (500 ),
862
+ address = encode_puzzle_hash (wallet_1_puzhash , "txch" ),
863
+ puzzle_decorator = [ClawbackPuzzleDecoratorOverride (decorator = "CLAWBACK" , clawback_timelock = uint64 (5 ))],
864
+ push = True ,
865
+ ),
857
866
tx_config = DEFAULT_TX_CONFIG ,
858
- fee = uint64 (0 ),
859
- puzzle_decorator_override = [{"decorator" : "CLAWBACK" , "clawback_timelock" : 5 }],
860
867
)
861
868
).transaction
862
869
assert tx .spend_bundle is not None
@@ -1019,7 +1026,8 @@ async def test_get_transactions(wallet_rpc_environment: WalletRpcTestEnvironment
1019
1026
puzhash = await action_scope .get_puzzle_hash (wallet .wallet_state_manager )
1020
1027
await full_node_api .wait_for_wallet_synced (wallet_node = wallet_node , timeout = 20 )
1021
1028
await client .send_transaction (
1022
- 1 , uint64 (1 ), encode_puzzle_hash (puzhash , "txch" ), DEFAULT_TX_CONFIG
1029
+ SendTransaction (wallet_id = uint32 (1 ), amount = uint64 (1 ), address = encode_puzzle_hash (puzhash , "txch" ), push = True ),
1030
+ DEFAULT_TX_CONFIG ,
1023
1031
) # Create a pending tx
1024
1032
1025
1033
with pytest .raises (ValueError , match = "There is no known sort foo" ):
@@ -1045,7 +1053,12 @@ async def test_get_transactions(wallet_rpc_environment: WalletRpcTestEnvironment
1045
1053
async with wallet .wallet_state_manager .new_action_scope (DEFAULT_TX_CONFIG , push = True ) as action_scope :
1046
1054
ph_by_addr = await action_scope .get_puzzle_hash (wallet .wallet_state_manager )
1047
1055
await full_node_api .wait_for_wallet_synced (wallet_node = wallet_node , timeout = 20 )
1048
- await client .send_transaction (1 , uint64 (1 ), encode_puzzle_hash (ph_by_addr , "txch" ), DEFAULT_TX_CONFIG )
1056
+ await client .send_transaction (
1057
+ SendTransaction (
1058
+ wallet_id = uint32 (1 ), amount = uint64 (1 ), address = encode_puzzle_hash (ph_by_addr , "txch" ), push = True
1059
+ ),
1060
+ DEFAULT_TX_CONFIG ,
1061
+ )
1049
1062
await full_node_api .wait_for_wallet_synced (wallet_node = wallet_node , timeout = 20 )
1050
1063
tx_for_address = (
1051
1064
await client .get_transactions (GetTransactions (uint32 (1 ), to_address = encode_puzzle_hash (ph_by_addr , "txch" )))
@@ -1795,7 +1808,12 @@ async def test_get_coin_records_by_names(wallet_rpc_environment: WalletRpcTestEn
1795
1808
await full_node_api .wait_for_wallet_synced (wallet_node = wallet_node , timeout = 20 )
1796
1809
1797
1810
# Spend half of it back to the same wallet get some spent coins in the wallet
1798
- tx = (await client .send_transaction (1 , uint64 (generated_funds / 2 ), address , DEFAULT_TX_CONFIG )).transaction
1811
+ tx = (
1812
+ await client .send_transaction (
1813
+ SendTransaction (wallet_id = uint32 (1 ), amount = uint64 (generated_funds / 2 ), address = address , push = True ),
1814
+ DEFAULT_TX_CONFIG ,
1815
+ )
1816
+ ).transaction
1799
1817
assert tx .spend_bundle is not None
1800
1818
await time_out_assert (20 , tx_in_mempool , True , client , tx .name )
1801
1819
await farm_transaction (full_node_api , wallet_node , tx .spend_bundle )
@@ -2161,7 +2179,11 @@ async def test_key_and_address_endpoints(wallet_rpc_environment: WalletRpcTestEn
2161
2179
addr = encode_puzzle_hash (ph , "txch" )
2162
2180
tx_amount = uint64 (15600000 )
2163
2181
await env .full_node .api .wait_for_wallet_synced (wallet_node = wallet_node , timeout = 20 )
2164
- created_tx = (await client .send_transaction (1 , tx_amount , addr , DEFAULT_TX_CONFIG )).transaction
2182
+ created_tx = (
2183
+ await client .send_transaction (
2184
+ SendTransaction (wallet_id = uint32 (1 ), amount = tx_amount , address = addr , push = True ), DEFAULT_TX_CONFIG
2185
+ )
2186
+ ).transaction
2165
2187
2166
2188
await time_out_assert (20 , tx_in_mempool , True , client , created_tx .name )
2167
2189
assert len (await wallet .wallet_state_manager .tx_store .get_unconfirmed_for_wallet (1 )) == 1
@@ -2224,7 +2246,10 @@ async def test_key_and_address_endpoints(wallet_rpc_environment: WalletRpcTestEn
2224
2246
assert await get_unconfirmed_balance (client , int (wallets [0 ].id )) == 0
2225
2247
2226
2248
with pytest .raises (ValueError ):
2227
- await client .send_transaction (wallets [0 ].id , uint64 (100 ), addr , DEFAULT_TX_CONFIG )
2249
+ await client .send_transaction (
2250
+ SendTransaction (wallet_id = uint32 (wallets [0 ].id ), amount = uint64 (100 ), address = addr , push = True ),
2251
+ DEFAULT_TX_CONFIG ,
2252
+ )
2228
2253
2229
2254
# Delete all keys
2230
2255
await client .delete_all_keys ()
@@ -2250,7 +2275,11 @@ async def test_select_coins_rpc(wallet_rpc_environment: WalletRpcTestEnvironment
2250
2275
for tx_amount in tx_amounts :
2251
2276
funds -= tx_amount
2252
2277
# create coins for tests
2253
- tx = (await client .send_transaction (1 , tx_amount , addr , DEFAULT_TX_CONFIG )).transaction
2278
+ tx = (
2279
+ await client .send_transaction (
2280
+ SendTransaction (wallet_id = uint32 (1 ), amount = tx_amount , address = addr , push = True ), DEFAULT_TX_CONFIG
2281
+ )
2282
+ ).transaction
2254
2283
spend_bundle = tx .spend_bundle
2255
2284
assert spend_bundle is not None
2256
2285
for coin in spend_bundle .additions ():
@@ -2811,12 +2840,14 @@ async def test_set_wallet_resync_on_startup(wallet_rpc_environment: WalletRpcTes
2811
2840
# Test Clawback resync
2812
2841
tx = (
2813
2842
await wc .send_transaction (
2814
- wallet_id = 1 ,
2815
- amount = uint64 (500 ),
2816
- address = address ,
2843
+ SendTransaction (
2844
+ wallet_id = uint32 (1 ),
2845
+ amount = uint64 (500 ),
2846
+ address = address ,
2847
+ puzzle_decorator = [ClawbackPuzzleDecoratorOverride (decorator = "CLAWBACK" , clawback_timelock = uint64 (5 ))],
2848
+ push = True ,
2849
+ ),
2817
2850
tx_config = DEFAULT_TX_CONFIG ,
2818
- fee = uint64 (0 ),
2819
- puzzle_decorator_override = [{"decorator" : "CLAWBACK" , "clawback_timelock" : 5 }],
2820
2851
)
2821
2852
).transaction
2822
2853
clawback_coin_id = tx .additions [0 ].name ()
@@ -2959,7 +2990,11 @@ async def test_cat_spend_run_tail(wallet_rpc_environment: WalletRpcTestEnvironme
2959
2990
)
2960
2991
tx_amount = uint64 (100 )
2961
2992
2962
- tx = (await client .send_transaction (1 , tx_amount , addr , DEFAULT_TX_CONFIG )).transaction
2993
+ tx = (
2994
+ await client .send_transaction (
2995
+ SendTransaction (wallet_id = uint32 (1 ), amount = uint64 (500 ), address = addr , push = True ), DEFAULT_TX_CONFIG
2996
+ )
2997
+ ).transaction
2963
2998
transaction_id = tx .name
2964
2999
spend_bundle = tx .spend_bundle
2965
3000
assert spend_bundle is not None
0 commit comments