line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
108748
|
use v5.26; |
|
1
|
|
|
|
|
4
|
|
2
|
1
|
|
|
1
|
|
714
|
use Object::Pad; |
|
1
|
|
|
|
|
12735
|
|
|
1
|
|
|
|
|
5
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package Blockchain::Ethereum::Keystore 0.005; |
5
|
|
|
|
|
|
|
class Blockchain::Ethereum::Keystore; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
1; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
__END__ |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=pod |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=encoding UTF-8 |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 NAME |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
Blockchain::Ethereum::Keystore - Ethereum keystorage utilities |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=head1 SYNOPSIS |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
Collection of utilities for keystore management |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
Examples: |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
Generating a new address and writing it to a keyfile: |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
my $key = Blockchain::Ethereum::Keystore::Key->new; |
28
|
|
|
|
|
|
|
# checksummed address |
29
|
|
|
|
|
|
|
print $key->address; |
30
|
|
|
|
|
|
|
my $keyfile = Blockchain::ethereum::Keystore::Keyfile->new; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
$keyfile->import_key($key); |
33
|
|
|
|
|
|
|
$keyfile->write_to_file("..."); |
34
|
|
|
|
|
|
|
... |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
Generating a new seed and derivating new keys (BIP44): |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
my $seed = Blockchain::Ethereum::Keystore::Seed->new; |
39
|
|
|
|
|
|
|
my $key = $seed->derive_key(0); |
40
|
|
|
|
|
|
|
print $key->address; |
41
|
|
|
|
|
|
|
... |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
Importing a keyfile and changing the password: |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
my $keyfile = Blockchain::Ethereum::Keystore::Keyfile->new; |
46
|
|
|
|
|
|
|
my $password = "old_password"; |
47
|
|
|
|
|
|
|
$keyfile->import_file("...", $password); |
48
|
|
|
|
|
|
|
$keyfile->change_password($password, "newpassword"); |
49
|
|
|
|
|
|
|
$keyfile->write_to_file("..."); |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
Signing a transaction: |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
my $transaction = Blockchain::Ethereum::Transaction::EIP1559->new( |
54
|
|
|
|
|
|
|
... |
55
|
|
|
|
|
|
|
); |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
my $keyfile = Blockchain::Ethereum::Keystore::Keyfile->new; |
58
|
|
|
|
|
|
|
$keyfile->import_file("..."); |
59
|
|
|
|
|
|
|
$keyfile->private_key->sign_transaction($transaction); |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
Export private key: |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
my $keyfile = Blockchain::Ethereum::Keystore::Keyfile->new; |
64
|
|
|
|
|
|
|
$keyfile->import_file("..."); |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
# private key bytes |
67
|
|
|
|
|
|
|
print $keyfile->private_key->export; |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head1 AUTHOR |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
Reginaldo Costa, C<< <refeco at cpan.org> >> |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head1 BUGS |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
Please report any bugs or feature requests to L<https://github.com/refeco/perl-ethereum-keystore> |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
This software is Copyright (c) 2023 by REFECO. |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
This is free software, licensed under: |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
The MIT License |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=cut |