Rallias

Untitled

Oct 27th, 2013
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.12 KB | None | 0 0
  1. #!/usr/bin/perl
  2.  
  3. use JSON::RPC::Client;
  4. use Data::Dumper;
  5.  
  6. ## ###### ###### ###### ###### ###### ###### ## ##
  7. ## ## ## ## ## ## ## ## ### ##
  8. ## ## ## #### ## ## ## ## ######
  9. ## ## ## ## ## ## ## ## ## ###
  10. ###### ###### ## ###### ###### ###### ###### ## ##
  11.  
  12. sub payByLitecoinGenerateAddress {
  13. my $sRpcCredentials = shift;
  14. my $sAccountId = shift;
  15.  
  16. my $sProtocol = ${$sRpcCredentials}[0];
  17. my $sEndpoint = ${$sRpcCredentials}[1];
  18. my $sUsername = ${$sRpcCredentials}[2];
  19. my $sPassword = ${$sRpcCredentials}[3];
  20.  
  21. my $sConnect = new JSON::RPC::Client;
  22.  
  23. $sConnect->ua->credentials(
  24. $sEndpoint,
  25. 'jsonrpc',
  26. $sUsername => $sPassword
  27. );
  28.  
  29. my $sUrl = $sProtocol.'://'.$sEndpoint;
  30.  
  31. my $sObject = {
  32. method => 'getnewaddress',
  33. params => [ $sAccountId ],
  34. };
  35.  
  36. my $sResponse = $sConnect->call( $sUrl, $sObject );
  37.  
  38. my $sLitecoinAddress;
  39. if ($sResponse){
  40. if ($sResponse->is_error) { print "Error : ", $sResponse->error_message; }
  41. else { $sLitecoinAddress = $sResponse->result; }
  42. } else {
  43. print $sConnect->status_line;
  44. }
  45.  
  46. return $sLitecoinAddress;
  47. }
  48.  
  49. sub payByLitecoinVerifyPayment {
  50. my $sRpcCredentials = shift;
  51. my $sAccountId = shift;
  52. my $sPaymentAmount = shift;
  53.  
  54. my $sProtocol = ${$sRpcCredentials}[0];
  55. my $sEndpoint = ${$sRpcCredentials}[1];
  56. my $sUsername = ${$sRpcCredentials}[2];
  57. my $sPassword = ${$sRpcCredentials}[3];
  58.  
  59. my $sConnect = new JSON::RPC::Client;
  60.  
  61. $sConnect->ua->credentials(
  62. $sEndpoint,
  63. 'jsonrpc',
  64. $sUsername => $sPassword
  65. );
  66.  
  67. my $sUrl = $sProtocol.'://'.$sEndpoint;
  68.  
  69. my $sObject = {
  70. method => 'getbalance',
  71. params => [ $sAccountId ],
  72. };
  73.  
  74. my $sResponse = $sConnect->call( $sUrl, $sObject );
  75.  
  76. my $sLitecoinAddress;
  77. if ($sResponse){
  78. if ($sResponse->is_error) { print "Error : ", $sResponse->error_message; }
  79. else { print Dumper($sResponse->result); }
  80. } else {
  81. print $sConnect->status_line;
  82. }
  83.  
  84. return $sLitecoinAddress;
  85. }
  86.  
  87. ###### ###### ###### ## ## ###### ###### ###### ## ##
  88. ## ## ## ## ## ## ## ## ## ####
  89. ###### #### ## ## ## ###### ## ## ##
  90. ## ## ## ## ## ## ## ## ## ##
  91. ###### ###### ###### ###### ## ## ###### ## ##
  92.  
  93. sub passwordHash {
  94. my $sPassword = shift;
  95. my $sRounds = shift;
  96.  
  97. my @sChars = ("A".."Z", "a".."z", 0..9);
  98. my @sRoundsChars = ("0".."9");
  99. my $sSalt;
  100. $sSalt .= $sChars[rand @sChars] for 1..16;
  101. if (!$sRounds) {
  102. while ($sRounds < 100000) {
  103. $sRounds = "";
  104. $sRounds .= int (rand 10) for 1..6;
  105. }
  106. }
  107.  
  108. my $sHash = crypt($sPassword, "\$6\$rounds=$sRounds\$$sSalt\$");
  109.  
  110. return $sHash;
  111. }
  112.  
  113. ###### ###### ###### ###### ###### ## ## ######
  114. ## ## ## ## ## ### ## ##
  115. ## #### ###### ## ## ###### ## ##
  116. ## ## ## ## ## ## ### ## ##
  117. ## ###### ###### ## ###### ## ## ######
  118.  
  119. print(payByLitecoinVerifyPayment(['http', 'localhost:9332', 'rallias', 'penis'], "penis"),"\n");
Advertisement
Add Comment
Please, Sign In to add comment