| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Solana::SPLAddress; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
104396
|
use 5.034000; |
|
|
1
|
|
|
|
|
6
|
|
|
4
|
1
|
|
|
1
|
|
8
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
78
|
|
|
5
|
1
|
|
|
1
|
|
7
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
112
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.06'; |
|
8
|
1
|
|
|
1
|
|
7
|
use Carp qw(croak); |
|
|
1
|
|
|
|
|
11
|
|
|
|
1
|
|
|
|
|
80
|
|
|
9
|
1
|
|
|
1
|
|
10
|
use constant PDA_MAKER => "ProgramDerivedAddress"; |
|
|
1
|
|
|
|
|
68
|
|
|
|
1
|
|
|
|
|
130
|
|
|
10
|
1
|
|
|
1
|
|
724
|
use Digest::SHA; |
|
|
1
|
|
|
|
|
4546
|
|
|
|
1
|
|
|
|
|
484
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
require XSLoader; |
|
13
|
|
|
|
|
|
|
XSLoader::load('Solana::SPLAddress', $VERSION); |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub find_address { |
|
16
|
1
|
|
|
1
|
1
|
194346
|
my ($seeds, $program_id) = @_; |
|
17
|
|
|
|
|
|
|
|
|
18
|
1
|
|
|
|
|
4
|
for my $bump ( reverse(0..255) ) { |
|
19
|
1
|
|
|
|
|
4
|
my $address = create_address($seeds, $bump, $program_id); |
|
20
|
1
|
50
|
|
|
|
3
|
if (defined $address) { |
|
21
|
1
|
|
|
|
|
3
|
return ($address, $bump); |
|
22
|
|
|
|
|
|
|
} |
|
23
|
|
|
|
|
|
|
} |
|
24
|
0
|
|
|
|
|
0
|
croak "Failed to generate SPL address"; |
|
25
|
|
|
|
|
|
|
} |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub create_address { |
|
28
|
1
|
|
|
1
|
1
|
2
|
my ($seeds, $bump, $program_id) = @_; |
|
29
|
1
|
|
|
|
|
9
|
my $sha = Digest::SHA->new(256); |
|
30
|
1
|
|
|
|
|
15
|
for my $seed (@$seeds) { |
|
31
|
3
|
|
|
|
|
11
|
$sha->add($seed); |
|
32
|
|
|
|
|
|
|
} |
|
33
|
1
|
|
|
|
|
5
|
$sha->add(pack("C", $bump)); |
|
34
|
1
|
|
|
|
|
4
|
$sha->add($program_id); |
|
35
|
1
|
|
|
|
|
3
|
$sha->add(PDA_MAKER); |
|
36
|
|
|
|
|
|
|
|
|
37
|
1
|
|
|
|
|
5
|
my $hash = $sha->digest; |
|
38
|
1
|
50
|
|
|
|
20
|
if (!check_pub_address_is_ok($hash)) { |
|
39
|
1
|
|
|
|
|
6
|
return unpack('H*', $hash); |
|
40
|
|
|
|
|
|
|
} |
|
41
|
0
|
|
|
|
|
|
return undef; |
|
42
|
|
|
|
|
|
|
} |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
1; |
|
45
|
|
|
|
|
|
|
__END__ |