Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl
- use JSON::RPC::Client;
- use Data::Dumper;
- ## ###### ###### ###### ###### ###### ###### ## ##
- ## ## ## ## ## ## ## ## ### ##
- ## ## ## #### ## ## ## ## ######
- ## ## ## ## ## ## ## ## ## ###
- ###### ###### ## ###### ###### ###### ###### ## ##
- sub payByLitecoinGenerateAddress {
- my $sRpcCredentials = shift;
- my $sAccountId = shift;
- my $sProtocol = ${$sRpcCredentials}[0];
- my $sEndpoint = ${$sRpcCredentials}[1];
- my $sUsername = ${$sRpcCredentials}[2];
- my $sPassword = ${$sRpcCredentials}[3];
- my $sConnect = new JSON::RPC::Client;
- $sConnect->ua->credentials(
- $sEndpoint,
- 'jsonrpc',
- $sUsername => $sPassword
- );
- my $sUrl = $sProtocol.'://'.$sEndpoint;
- my $sObject = {
- method => 'getnewaddress',
- params => [ $sAccountId ],
- };
- my $sResponse = $sConnect->call( $sUrl, $sObject );
- my $sLitecoinAddress;
- if ($sResponse){
- if ($sResponse->is_error) { print "Error : ", $sResponse->error_message; }
- else { $sLitecoinAddress = $sResponse->result; }
- } else {
- print $sConnect->status_line;
- }
- return $sLitecoinAddress;
- }
- sub payByLitecoinVerifyPayment {
- my $sRpcCredentials = shift;
- my $sAccountId = shift;
- my $sPaymentAmount = shift;
- my $sProtocol = ${$sRpcCredentials}[0];
- my $sEndpoint = ${$sRpcCredentials}[1];
- my $sUsername = ${$sRpcCredentials}[2];
- my $sPassword = ${$sRpcCredentials}[3];
- my $sConnect = new JSON::RPC::Client;
- $sConnect->ua->credentials(
- $sEndpoint,
- 'jsonrpc',
- $sUsername => $sPassword
- );
- my $sUrl = $sProtocol.'://'.$sEndpoint;
- my $sObject = {
- method => 'getbalance',
- params => [ $sAccountId ],
- };
- my $sResponse = $sConnect->call( $sUrl, $sObject );
- my $sLitecoinAddress;
- if ($sResponse){
- if ($sResponse->is_error) { print "Error : ", $sResponse->error_message; }
- else { print Dumper($sResponse->result); }
- } else {
- print $sConnect->status_line;
- }
- return $sLitecoinAddress;
- }
- ###### ###### ###### ## ## ###### ###### ###### ## ##
- ## ## ## ## ## ## ## ## ## ####
- ###### #### ## ## ## ###### ## ## ##
- ## ## ## ## ## ## ## ## ## ##
- ###### ###### ###### ###### ## ## ###### ## ##
- sub passwordHash {
- my $sPassword = shift;
- my $sRounds = shift;
- my @sChars = ("A".."Z", "a".."z", 0..9);
- my @sRoundsChars = ("0".."9");
- my $sSalt;
- $sSalt .= $sChars[rand @sChars] for 1..16;
- if (!$sRounds) {
- while ($sRounds < 100000) {
- $sRounds = "";
- $sRounds .= int (rand 10) for 1..6;
- }
- }
- my $sHash = crypt($sPassword, "\$6\$rounds=$sRounds\$$sSalt\$");
- return $sHash;
- }
- ###### ###### ###### ###### ###### ## ## ######
- ## ## ## ## ## ### ## ##
- ## #### ###### ## ## ###### ## ##
- ## ## ## ## ## ## ### ## ##
- ## ###### ###### ## ###### ## ## ######
- print(payByLitecoinVerifyPayment(['http', 'localhost:9332', 'rallias', 'penis'], "penis"),"\n");
Advertisement
Add Comment
Please, Sign In to add comment