@@ -8,20 +8,35 @@ defmodule RPC.API do
88
99 defmodule Wallet do
1010 def transfer ( seed64 , receiver , amount_float , symbol \\ "AMA" ) do
11- tx_packed = API.Wallet . transfer ( seed64 , receiver , amount_float , symbol , false )
12- RPC.API . get ( "/api/tx/submit/#{ Base58 . encode ( tx_packed ) } " )
11+ if ! BlsEx . validate_public_key ( receiver ) and receiver != @ burn_address do
12+ IO . inspect { "sending #{ amount_float } AMA to invalid public key" , receiver }
13+ % { error: :invalid_public_key , pk: receiver }
14+ else
15+ tx_packed = API.Wallet . transfer ( seed64 , receiver , amount_float , symbol , false )
16+ RPC.API . get ( "/api/tx/submit/#{ Base58 . encode ( tx_packed ) } " )
17+ end
1318 end
1419
1520 def transfer_bulk ( seed64 , receiver_amount_list ) do
1621 Enum . map ( receiver_amount_list , fn
1722 { receiver , amount_float } ->
18- IO . inspect { "sending #{ amount_float } AMA to " , receiver }
19- tx_packed = API.Wallet . transfer ( seed64 , receiver , amount_float , "AMA" , false )
20- RPC.API . get ( "/api/tx/submit/#{ Base58 . encode ( tx_packed ) } " )
23+ if ! BlsEx . validate_public_key ( receiver ) and receiver != @ burn_address do
24+ IO . inspect { "sending #{ amount_float } AMA to invalid public key" , receiver }
25+ % { error: :invalid_public_key , pk: receiver }
26+ else
27+ IO . inspect { "sending #{ amount_float } AMA to " , receiver }
28+ tx_packed = API.Wallet . transfer ( seed64 , receiver , amount_float , "AMA" , false )
29+ RPC.API . get ( "/api/tx/submit/#{ Base58 . encode ( tx_packed ) } " )
30+ end
2131 { receiver , amount_float , symbol } ->
22- IO . inspect { "sending #{ amount_float } #{ symbol } to " , receiver }
23- tx_packed = API.Wallet . transfer ( seed64 , receiver , amount_float , symbol , false )
24- RPC.API . get ( "/api/tx/submit/#{ Base58 . encode ( tx_packed ) } " )
32+ if ! BlsEx . validate_public_key ( receiver ) and receiver != @ burn_address do
33+ IO . inspect { "sending #{ amount_float } AMA to invalid public key" , receiver }
34+ % { error: :invalid_public_key , pk: receiver }
35+ else
36+ IO . inspect { "sending #{ amount_float } #{ symbol } to " , receiver }
37+ tx_packed = API.Wallet . transfer ( seed64 , receiver , amount_float , symbol , false )
38+ RPC.API . get ( "/api/tx/submit/#{ Base58 . encode ( tx_packed ) } " )
39+ end
2540 end )
2641 end
2742
0 commit comments