123
123
GetPrivateKey ,
124
124
GetSyncStatusResponse ,
125
125
GetTimestampForHeight ,
126
+ GetTransaction ,
127
+ GetTransactions ,
126
128
GetWalletBalance ,
127
129
GetWalletBalances ,
128
130
GetWallets ,
@@ -345,7 +347,7 @@ async def assert_get_balance(rpc_client: WalletRpcClient, wallet_node: WalletNod
345
347
346
348
347
349
async def tx_in_mempool (client : WalletRpcClient , transaction_id : bytes32 ) -> bool :
348
- tx = await client .get_transaction (transaction_id )
350
+ tx = ( await client .get_transaction (GetTransaction ( transaction_id ))). transaction
349
351
return tx .is_in_mempool ()
350
352
351
353
@@ -433,7 +435,7 @@ async def test_send_transaction(wallet_rpc_environment: WalletRpcTestEnvironment
433
435
await farm_transaction (full_node_api , wallet_node , spend_bundle )
434
436
435
437
# Checks that the memo can be retrieved
436
- tx_confirmed = await client .get_transaction (transaction_id )
438
+ tx_confirmed = ( await client .get_transaction (GetTransaction ( transaction_id ))). transaction . to_transaction_record ( )
437
439
assert tx_confirmed .confirmed
438
440
assert len (tx_confirmed .get_memos ()) == 1
439
441
assert [b"this is a basic tx" ] in tx_confirmed .get_memos ().values ()
@@ -481,7 +483,7 @@ async def test_push_transactions(wallet_rpc_environment: WalletRpcTestEnvironmen
481
483
await farm_transaction (full_node_api , wallet_node , spend_bundle )
482
484
483
485
for tx in resp_client .transactions :
484
- assert (await client .get_transaction (transaction_id = tx .name )).confirmed
486
+ assert (await client .get_transaction (GetTransaction ( transaction_id = tx .name ))). transaction .confirmed
485
487
486
488
# Just testing NOT failure here really (parsing)
487
489
await client .push_tx (PushTX (spend_bundle ))
@@ -975,7 +977,7 @@ async def test_send_transaction_multi(wallet_rpc_environment: WalletRpcTestEnvir
975
977
await time_out_assert (20 , get_confirmed_balance , generated_funds - amount_outputs - amount_fee , client , 1 )
976
978
977
979
# Checks that the memo can be retrieved
978
- tx_confirmed = await client .get_transaction (send_tx_res .name )
980
+ tx_confirmed = ( await client .get_transaction (GetTransaction ( send_tx_res .name ))). transaction
979
981
assert tx_confirmed .confirmed
980
982
memos = tx_confirmed .get_memos ()
981
983
assert len (memos ) == len (outputs )
@@ -998,18 +1000,20 @@ async def test_get_transactions(wallet_rpc_environment: WalletRpcTestEnvironment
998
1000
999
1001
await generate_funds (full_node_api , env .wallet_1 , 5 )
1000
1002
1001
- all_transactions = await client .get_transactions (1 )
1003
+ all_transactions = ( await client .get_transactions (GetTransactions ( uint32 ( 1 )))). transactions
1002
1004
assert len (all_transactions ) >= 10
1003
1005
# Test transaction pagination
1004
- some_transactions = await client .get_transactions (1 , 0 , 5 )
1005
- some_transactions_2 = await client .get_transactions (1 , 5 , 10 )
1006
+ some_transactions = (await client .get_transactions (GetTransactions (uint32 (1 ), uint16 (0 ), uint16 (5 )))).transactions
1007
+ some_transactions_2 = (
1008
+ await client .get_transactions (GetTransactions (uint32 (1 ), uint16 (5 ), uint16 (10 )))
1009
+ ).transactions
1006
1010
assert some_transactions == all_transactions [0 :5 ]
1007
1011
assert some_transactions_2 == all_transactions [5 :10 ]
1008
1012
1009
1013
# Testing sorts
1010
1014
# Test the default sort (CONFIRMED_AT_HEIGHT)
1011
1015
assert all_transactions == sorted (all_transactions , key = attrgetter ("confirmed_at_height" ))
1012
- all_transactions = await client .get_transactions (1 , reverse = True )
1016
+ all_transactions = ( await client .get_transactions (GetTransactions ( uint32 ( 1 ) , reverse = True ))). transactions
1013
1017
assert all_transactions == sorted (all_transactions , key = attrgetter ("confirmed_at_height" ), reverse = True )
1014
1018
1015
1019
# Test RELEVANCE
@@ -1020,13 +1024,17 @@ async def test_get_transactions(wallet_rpc_environment: WalletRpcTestEnvironment
1020
1024
1 , uint64 (1 ), encode_puzzle_hash (puzhash , "txch" ), DEFAULT_TX_CONFIG
1021
1025
) # Create a pending tx
1022
1026
1023
- all_transactions = await client .get_transactions (1 , sort_key = SortKey .RELEVANCE )
1027
+ all_transactions = (
1028
+ await client .get_transactions (GetTransactions (uint32 (1 ), sort_key = SortKey .RELEVANCE .name ))
1029
+ ).transactions
1024
1030
sorted_transactions = sorted (all_transactions , key = attrgetter ("created_at_time" ), reverse = True )
1025
1031
sorted_transactions = sorted (sorted_transactions , key = attrgetter ("confirmed_at_height" ), reverse = True )
1026
1032
sorted_transactions = sorted (sorted_transactions , key = attrgetter ("confirmed" ))
1027
1033
assert all_transactions == sorted_transactions
1028
1034
1029
- all_transactions = await client .get_transactions (1 , sort_key = SortKey .RELEVANCE , reverse = True )
1035
+ all_transactions = (
1036
+ await client .get_transactions (GetTransactions (uint32 (1 ), sort_key = SortKey .RELEVANCE .name , reverse = True ))
1037
+ ).transactions
1030
1038
sorted_transactions = sorted (all_transactions , key = attrgetter ("created_at_time" ))
1031
1039
sorted_transactions = sorted (sorted_transactions , key = attrgetter ("confirmed_at_height" ))
1032
1040
sorted_transactions = sorted (sorted_transactions , key = attrgetter ("confirmed" ), reverse = True )
@@ -1038,31 +1046,43 @@ async def test_get_transactions(wallet_rpc_environment: WalletRpcTestEnvironment
1038
1046
await full_node_api .wait_for_wallet_synced (wallet_node = wallet_node , timeout = 20 )
1039
1047
await client .send_transaction (1 , uint64 (1 ), encode_puzzle_hash (ph_by_addr , "txch" ), DEFAULT_TX_CONFIG )
1040
1048
await full_node_api .wait_for_wallet_synced (wallet_node = wallet_node , timeout = 20 )
1041
- tx_for_address = await client .get_transactions (1 , to_address = encode_puzzle_hash (ph_by_addr , "txch" ))
1049
+ tx_for_address = (
1050
+ await client .get_transactions (GetTransactions (uint32 (1 ), to_address = encode_puzzle_hash (ph_by_addr , "txch" )))
1051
+ ).transactions
1042
1052
assert len (tx_for_address ) == 1
1043
1053
assert tx_for_address [0 ].to_puzzle_hash == ph_by_addr
1044
1054
1045
1055
# Test type filter
1046
- all_transactions = await client .get_transactions (
1047
- 1 , type_filter = TransactionTypeFilter .include ([TransactionType .COINBASE_REWARD ])
1048
- )
1056
+ all_transactions = (
1057
+ await client .get_transactions (
1058
+ GetTransactions (uint32 (1 ), type_filter = TransactionTypeFilter .include ([TransactionType .COINBASE_REWARD ]))
1059
+ )
1060
+ ).transactions
1049
1061
assert len (all_transactions ) == 5
1050
1062
assert all (transaction .type == TransactionType .COINBASE_REWARD .value for transaction in all_transactions )
1051
1063
# Test confirmed filter
1052
- all_transactions = await client .get_transactions (1 , confirmed = True )
1064
+ all_transactions = ( await client .get_transactions (GetTransactions ( uint32 ( 1 ) , confirmed = True ))). transactions
1053
1065
assert len (all_transactions ) == 10
1054
1066
assert all (transaction .confirmed for transaction in all_transactions )
1055
- all_transactions = await client .get_transactions (1 , confirmed = False )
1067
+ all_transactions = ( await client .get_transactions (GetTransactions ( uint32 ( 1 ) , confirmed = False ))). transactions
1056
1068
assert len (all_transactions ) == 2
1057
1069
assert all (not transaction .confirmed for transaction in all_transactions )
1058
1070
1059
1071
# Test bypass broken txs
1060
1072
await wallet .wallet_state_manager .tx_store .add_transaction_record (
1061
- dataclasses .replace (all_transactions [0 ], type = uint32 (TransactionType .INCOMING_CLAWBACK_SEND ))
1062
- )
1063
- all_transactions = await client .get_transactions (
1064
- 1 , type_filter = TransactionTypeFilter .include ([TransactionType .INCOMING_CLAWBACK_SEND ]), confirmed = False
1073
+ dataclasses .replace (
1074
+ all_transactions [0 ].to_transaction_record (), type = uint32 (TransactionType .INCOMING_CLAWBACK_SEND )
1075
+ )
1065
1076
)
1077
+ all_transactions = (
1078
+ await client .get_transactions (
1079
+ GetTransactions (
1080
+ uint32 (1 ),
1081
+ type_filter = TransactionTypeFilter .include ([TransactionType .INCOMING_CLAWBACK_SEND ]),
1082
+ confirmed = False ,
1083
+ )
1084
+ )
1085
+ ).transactions
1066
1086
assert len (all_transactions ) == 1
1067
1087
1068
1088
@@ -1075,7 +1095,7 @@ async def test_get_transaction_count(wallet_rpc_environment: WalletRpcTestEnviro
1075
1095
1076
1096
await generate_funds (full_node_api , env .wallet_1 )
1077
1097
1078
- all_transactions = await client .get_transactions (1 )
1098
+ all_transactions = ( await client .get_transactions (GetTransactions ( uint32 ( 1 )))). transactions
1079
1099
assert len (all_transactions ) > 0
1080
1100
transaction_count = await client .get_transaction_count (1 )
1081
1101
assert transaction_count == len (all_transactions )
0 commit comments