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