class Faker::Blockchain::Bitcoin
Constants
- PROTOCOL_VERSIONS
@private
Public Class Methods
address()
click to toggle source
Produces a Bitcoin
wallet address
@return [String]
@example
Faker::Blockchain::Bitcoin.address #=> "147nDP22h3pHrLt2qykTH4txUwQh1ccaXp"
@faker.version 1.9.2
# File lib/faker/blockchain/bitcoin.rb, line 26 def address address_for(:main) end
testnet_address()
click to toggle source
Produces a Bitcoin
testnet address
@return [String]
@example
Faker::Blockchain::Bitcoin.testnet_address #=> "n4YjRyYD6V6zREpk6opqESDqD3KYnMdVEB"
@faker.version 1.9.2
# File lib/faker/blockchain/bitcoin.rb, line 40 def testnet_address address_for(:testnet) end
Protected Class Methods
address_for(network)
click to toggle source
Generates a random Bitcoin
address for the given network
@param network [Symbol] The name of network protocol to generate an address for @return [String] A Bitcoin
address
# File lib/faker/blockchain/bitcoin.rb, line 51 def address_for(network) version = PROTOCOL_VERSIONS.fetch(network) packed = version.chr + Faker::Config.random.bytes(20) checksum = OpenSSL::Digest::SHA256.digest(OpenSSL::Digest::SHA256.digest(packed))[0..3] Faker::Base58.encode(packed + checksum) end