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