143
143
RoyaltyAsset ,
144
144
SendTransaction ,
145
145
SetWalletResyncOnStartup ,
146
+ SpendClawbackCoins ,
146
147
SplitCoins ,
147
148
VerifySignature ,
148
149
VerifySignatureResponse ,
@@ -833,7 +834,6 @@ async def test_spend_clawback_coins(wallet_rpc_environment: WalletRpcTestEnviron
833
834
wallet_1 = wallet_1_node .wallet_state_manager .main_wallet
834
835
wallet_2 = wallet_2_node .wallet_state_manager .main_wallet
835
836
full_node_api : FullNodeSimulator = env .full_node .api
836
- wallet_2_api = WalletRpcApi (wallet_2_node )
837
837
838
838
generated_funds = await generate_funds (full_node_api , env .wallet_1 , 1 )
839
839
await generate_funds (full_node_api , env .wallet_2 , 1 )
@@ -876,41 +876,39 @@ async def test_spend_clawback_coins(wallet_rpc_environment: WalletRpcTestEnviron
876
876
await time_out_assert (20 , get_confirmed_balance , generated_funds - 500 , wallet_1_rpc , 1 )
877
877
await time_out_assert (20 , get_confirmed_balance , generated_funds - 500 , wallet_2_rpc , 1 )
878
878
await asyncio .sleep (10 )
879
- # Test missing coin_ids
880
- has_exception = False
881
- try :
882
- await wallet_2_api .spend_clawback_coins ({})
883
- except ValueError :
884
- has_exception = True
885
- assert has_exception
886
879
# Test coin ID is not a Clawback coin
887
880
invalid_coin_id = tx .removals [0 ].name ()
888
- resp = await wallet_2_rpc .spend_clawback_coins ([invalid_coin_id ], 500 )
889
- assert resp ["success" ]
890
- assert resp ["transaction_ids" ] == []
881
+ resp = await wallet_2_rpc .spend_clawback_coins (
882
+ SpendClawbackCoins (coin_ids = [invalid_coin_id ], fee = uint64 (500 ), push = True ), tx_config = DEFAULT_TX_CONFIG
883
+ )
884
+ assert resp .transaction_ids == []
891
885
# Test unsupported wallet
892
886
coin_record = await wallet_1_node .wallet_state_manager .coin_store .get_coin_record (clawback_coin_id_1 )
893
887
assert coin_record is not None
894
888
await wallet_1_node .wallet_state_manager .coin_store .add_coin_record (
895
889
dataclasses .replace (coin_record , wallet_type = WalletType .CAT )
896
890
)
897
- resp = await wallet_1_rpc .spend_clawback_coins ([clawback_coin_id_1 ], 100 )
898
- assert resp ["success" ]
899
- assert len (resp ["transaction_ids" ]) == 0
891
+ resp = await wallet_1_rpc .spend_clawback_coins (
892
+ SpendClawbackCoins (coin_ids = [clawback_coin_id_1 ], fee = uint64 (100 ), push = True ), tx_config = DEFAULT_TX_CONFIG
893
+ )
894
+ assert len (resp .transaction_ids ) == 0
900
895
# Test missing metadata
901
896
await wallet_1_node .wallet_state_manager .coin_store .add_coin_record (dataclasses .replace (coin_record , metadata = None ))
902
- resp = await wallet_1_rpc .spend_clawback_coins ([clawback_coin_id_1 ], 100 )
903
- assert resp ["success" ]
904
- assert len (resp ["transaction_ids" ]) == 0
897
+ resp = await wallet_1_rpc .spend_clawback_coins (
898
+ SpendClawbackCoins (coin_ids = [clawback_coin_id_1 ], fee = uint64 (100 ), push = True ), tx_config = DEFAULT_TX_CONFIG
899
+ )
900
+ assert len (resp .transaction_ids ) == 0
905
901
# Test missing incoming tx
906
902
coin_record = await wallet_1_node .wallet_state_manager .coin_store .get_coin_record (clawback_coin_id_2 )
907
903
assert coin_record is not None
908
904
fake_coin = Coin (coin_record .coin .parent_coin_info , wallet_2_puzhash , coin_record .coin .amount )
909
905
await wallet_1_node .wallet_state_manager .coin_store .add_coin_record (
910
906
dataclasses .replace (coin_record , coin = fake_coin )
911
907
)
912
- resp = await wallet_1_rpc .spend_clawback_coins ([fake_coin .name ()], 100 )
913
- assert resp ["transaction_ids" ] == []
908
+ resp = await wallet_1_rpc .spend_clawback_coins (
909
+ SpendClawbackCoins (coin_ids = [fake_coin .name ()], fee = uint64 (100 ), push = True ), tx_config = DEFAULT_TX_CONFIG
910
+ )
911
+ assert resp .transaction_ids == []
914
912
# Test coin puzzle hash doesn't match the puzzle
915
913
farmed_tx = (await wallet_1 .wallet_state_manager .tx_store .get_farming_rewards ())[0 ]
916
914
await wallet_1 .wallet_state_manager .tx_store .add_transaction_record (
@@ -919,8 +917,10 @@ async def test_spend_clawback_coins(wallet_rpc_environment: WalletRpcTestEnviron
919
917
await wallet_1_node .wallet_state_manager .coin_store .add_coin_record (
920
918
dataclasses .replace (coin_record , coin = fake_coin )
921
919
)
922
- resp = await wallet_1_rpc .spend_clawback_coins ([fake_coin .name ()], 100 )
923
- assert resp ["transaction_ids" ] == []
920
+ resp = await wallet_1_rpc .spend_clawback_coins (
921
+ SpendClawbackCoins (coin_ids = [fake_coin .name ()], fee = uint64 (100 ), push = True ), tx_config = DEFAULT_TX_CONFIG
922
+ )
923
+ assert resp .transaction_ids == []
924
924
# Test claim spend
925
925
await wallet_2_rpc .set_auto_claim (
926
926
AutoClaimSettings (
@@ -930,21 +930,23 @@ async def test_spend_clawback_coins(wallet_rpc_environment: WalletRpcTestEnviron
930
930
batch_size = uint16 (1 ),
931
931
)
932
932
)
933
- resp = await wallet_2_rpc .spend_clawback_coins ([clawback_coin_id_1 , clawback_coin_id_2 ], 100 )
934
- assert resp ["success" ]
935
- assert len (resp ["transaction_ids" ]) == 2
936
- for _tx in resp ["transactions" ]:
937
- clawback_tx = TransactionRecord .from_json_dict (_tx )
933
+ resp = await wallet_2_rpc .spend_clawback_coins (
934
+ SpendClawbackCoins (coin_ids = [clawback_coin_id_1 , clawback_coin_id_2 ], fee = uint64 (100 ), push = True ),
935
+ tx_config = DEFAULT_TX_CONFIG ,
936
+ )
937
+ assert len (resp .transaction_ids ) == 2
938
+ for clawback_tx in resp .transactions :
938
939
if clawback_tx .spend_bundle is not None :
939
940
await time_out_assert_not_none (
940
941
10 , full_node_api .full_node .mempool_manager .get_spendbundle , clawback_tx .spend_bundle .name ()
941
942
)
942
943
await farm_transaction_block (full_node_api , wallet_2_node )
943
944
await time_out_assert (20 , get_confirmed_balance , generated_funds + 300 , wallet_2_rpc , 1 )
944
945
# Test spent coin
945
- resp = await wallet_2_rpc .spend_clawback_coins ([clawback_coin_id_1 ], 500 )
946
- assert resp ["success" ]
947
- assert resp ["transaction_ids" ] == []
946
+ resp = await wallet_2_rpc .spend_clawback_coins (
947
+ SpendClawbackCoins (coin_ids = [clawback_coin_id_1 ], fee = uint64 (500 ), push = True ), tx_config = DEFAULT_TX_CONFIG
948
+ )
949
+ assert resp .transaction_ids == []
948
950
949
951
950
952
@pytest .mark .anyio
@@ -2861,12 +2863,11 @@ async def test_set_wallet_resync_on_startup(wallet_rpc_environment: WalletRpcTes
2861
2863
await farm_transaction (full_node_api , wallet_node , tx .spend_bundle )
2862
2864
await time_out_assert (20 , check_client_synced , True , wc )
2863
2865
await asyncio .sleep (10 )
2864
- resp = await wc .spend_clawback_coins ([clawback_coin_id ], 0 )
2865
- assert resp ["success" ]
2866
- assert len (resp ["transaction_ids" ]) == 1
2867
- await time_out_assert_not_none (
2868
- 10 , full_node_api .full_node .mempool_manager .get_spendbundle , bytes32 .from_hexstr (resp ["transaction_ids" ][0 ])
2866
+ resp = await wc .spend_clawback_coins (
2867
+ SpendClawbackCoins (coin_ids = [clawback_coin_id ], fee = uint64 (0 ), push = True ), tx_config = DEFAULT_TX_CONFIG
2869
2868
)
2869
+ assert len (resp .transaction_ids ) == 1
2870
+ await time_out_assert_not_none (10 , full_node_api .full_node .mempool_manager .get_spendbundle , resp .transaction_ids [0 ])
2870
2871
await farm_transaction_block (full_node_api , wallet_node )
2871
2872
await time_out_assert (20 , check_client_synced , True , wc )
2872
2873
wallet_node_2 ._close ()
0 commit comments