class Secp256k1::Ethereum::Enode
- Secp256k1::Ethereum::Enode
- Reference
- Object
Overview
Implements an Ethereum
devp2p enode containing a Keypair
and an IP address.
Properties:
#key_pair
(Keypair
): theKeypair
containing the secret key.#address
(Socket::IPAddress
): the public (or local) IP address with port.
p2p = Secp256k1::Ethereum::Enode.new
p2p.get_secret
# => "53d77137b39427a35d8c4b187f532d3912e1e7135985e730633e1e3c1b87ce97"
p2p.to_s
# => "enode://e097fc69f0b92f711620511c07fefdd648e469df46b1e4385a00a1786f6bc55b7d9011bb589e883d8a7947cfb37dc6b3c8beae9c614cab4a83009bd9d8732a9f@84.160.86.205:30303"
Defined in:
ethereum.crConstructors
-
.new(key_pair : Secp256k1::Keypair, host, port)
Generates an
Ethereum::Enode
from a providedKeypair
and a custom IP address with port. -
.new(key_pair : Secp256k1::Keypair, port)
Generates an
Ethereum::Enode
from a providedKeypair
and a custom port. -
.new(key_pair : Secp256k1::Keypair)
Generates an
Ethereum::Enode
from a providedKeypair
. -
.new
Generates a new
Ethereum::Enode
from a fresh randomKeypair
.
Instance Method Summary
-
#address : Socket::IPAddress
The public (or local) IP address with port.
-
#address=(address : Socket::IPAddress)
The public (or local) IP address with port.
-
#get_my_ip
Tries to find out the public IP address for the node.
-
#get_secret
Gets the private key as hexadecimal formatted string literal.
-
#key_pair : Keypair
The
Keypair
containing the secret key. -
#key_pair=(key_pair : Keypair)
The
Keypair
containing the secret key. -
#to_s
Gets the
Enode
formatted as devp2p enode address.
Constructor Detail
Generates an Ethereum::Enode
from a provided Keypair
and a custom IP address with port.
key = Secp256k1::Keypair.new BigInt.new("53d77137b39427a35d8c4b187f532d3912e1e7135985e730633e1e3c1b87ce97", 16)
p2p = Secp256k1::Ethereum::Enode.new key, "192.168.13.37", 31337
# => #<Secp256k1::Ethereum::Enode:0x7f81ef21ab80>
Generates an Ethereum::Enode
from a provided Keypair
and a custom port.
key = Secp256k1::Keypair.new BigInt.new("53d77137b39427a35d8c4b187f532d3912e1e7135985e730633e1e3c1b87ce97", 16)
p2p = Secp256k1::Ethereum::Enode.new key, 50000
# => #<Secp256k1::Ethereum::Enode:0x7f81ef21ab80>
Note, this tries to find out the public IP address and silently falls back to "127.0.0.1" if it fails.
Generates an Ethereum::Enode
from a provided Keypair
.
key = Secp256k1::Keypair.new BigInt.new("53d77137b39427a35d8c4b187f532d3912e1e7135985e730633e1e3c1b87ce97", 16)
p2p = Secp256k1::Ethereum::Enode.new key
# => #<Secp256k1::Ethereum::Enode:0x7f81ef21ab80>
Note, this tries to find out the public IP address and silently falls back to "127.0.0.1" if it fails.
Generates a new Ethereum::Enode
from a fresh random Keypair
.
p2p = Secp256k1::Ethereum::Enode.new
# => #<Secp256k1::Ethereum::Enode:0x7f81ef21ab80>
Note, this tries to find out the public IP address and silently falls back to "127.0.0.1" if it fails.
Instance Method Detail
Tries to find out the public IP address for the node.
It queries ident.me for a potential public IP and silently falls back to "127.0.0.1" if it fails without raising. Should be used with caution.
p2p.get_my_ip
# => "84.160.86.205"
Gets the private key as hexadecimal formatted string literal.
p2p.get_secret
# => "53d77137b39427a35d8c4b187f532d3912e1e7135985e730633e1e3c1b87ce97"