Class: Middlecoin::Core::BitcoinAddress
- Inherits:
-
Object
- Object
- Middlecoin::Core::BitcoinAddress
- Defined in:
- lib/middlecoin/core/bitcoinaddress.rb
Overview
Bitcoin Address
Class Method Summary collapse
-
.validate(address) ⇒ Object
Does some simple validation of a BTC address to make sure its sane.
Class Method Details
.validate(address) ⇒ Object
Does some simple validation of a BTC address to make sure its sane
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/middlecoin/core/bitcoinaddress.rb', line 29 def self.validate address if address[0] != "1" && address[0] != "3" raise Middlecoin::InvalidBitcoinAddressError, "Bitcoin addresses must start with 1 or 3" end if !(27..34).include?(address.length) raise Middlecoin::InvalidBitcoinAddressError, "Bitcoin addresses must be between 27 and 34 in length" end if address =~ /\A\p{Alnum}+\z/ return true else raise Middlecoin::InvalidBitcoinAddressError, "Bitcoin addresses must only contain Alphanumerical characters" end end |