Module: Bitcoin
- Extended by:
- Util
- Defined in:
- lib/bitcoin.rb,
lib/bitcoin/key.rb,
lib/bitcoin/bech32.rb,
lib/bitcoin/builder.rb,
lib/bitcoin/ext_key.rb,
lib/bitcoin/version.rb,
lib/bitcoin/dogecoin.rb,
lib/bitcoin/protocol.rb,
lib/bitcoin/connection.rb,
lib/bitcoin/ffi/openssl.rb,
lib/bitcoin/protocol/tx.rb,
lib/bitcoin/bloom_filter.rb,
lib/bitcoin/contracthash.rb,
lib/bitcoin/ffi/secp256k1.rb,
lib/bitcoin/protocol/txin.rb,
lib/bitcoin/protocol/block.rb,
lib/bitcoin/protocol/txout.rb,
lib/bitcoin/protocol/parser.rb,
lib/bitcoin/protocol/reject.rb,
lib/bitcoin/trezor/mnemonic.rb,
lib/bitcoin/protocol/address.rb,
lib/bitcoin/protocol/aux_pow.rb,
lib/bitcoin/protocol/handler.rb,
lib/bitcoin/protocol/version.rb,
lib/bitcoin/ffi/bitcoinconsensus.rb,
lib/bitcoin/protocol/script_witness.rb,
lib/bitcoin/protocol/partial_merkle_tree.rb
Defined Under Namespace
Modules: Bech32, BinaryExtensions, BitcoinConsensus, Builder, ConnectionHandler, ContractHash, Dogecoin, OpenSSL_EC, Protocol, Secp256k1, Trezor, Util Classes: BloomFilter, Connection, ExtKey, ExtPubkey, Key, Script
Constant Summary collapse
- Integer =
Determine the integer class to use. In older versions of ruby (< 2.4.0) the integer class is called Fixnum. In newer version (>= 2.4.0) Fixnum was deprecated in favor of a unification of Fixnum and BigInteger named Integer. Since this project strivers for backwards-compatability, we determine the appropriate class to use at initialization.
This avoids annoying deprecation warnings on newer versions for ourselves and library consumers.
if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.4.0') Integer else Fixnum end
- CURVE_ORDER =
Integers modulo the order of the curve(secp256k1)
115792089237316195423570985008687907852837564279074904382605163141518161494337
- VERSION =
"0.0.20"
- P =
Protocol
- MAX_BLOCK_SIZE =
maximum size of a block (in bytes)
1_000_000
- MAX_BLOCK_SIZE_GEN =
soft limit for new blocks
MAX_BLOCK_SIZE/2
- MAX_BLOCK_SIGOPS =
maximum number of signature operations in a block
MAX_BLOCK_SIZE / 50
- MAX_ORPHAN_TRANSACTIONS =
maximum number of orphan transactions to be kept in memory
MAX_BLOCK_SIZE/100
- LOCKTIME_THRESHOLD =
Threshold for lock_time: below this value it is interpreted as block number, otherwise as UNIX timestamp.
500000000
- UINT32_MAX =
maximum integer value
0xffffffff
- INT_MAX =
deprecated name, left here for compatibility with existing users.
0xffffffff
- COINBASE_MATURITY =
number of confirmations required before coinbase tx can be spent
100
- RETARGET_INTERVAL =
interval (in blocks) for difficulty retarget
2016
- RETARGET =
deprecated constant
2016
- REWARD_DROP =
interval (in blocks) for mining reward reduction
210_000
- CENT =
1_000_000
- COIN =
100_000_000
- MIN_FEE_MODE =
[ :block, :relay, :send ]
- NETWORKS =
{ bitcoin: { project: :bitcoin, magic_head: "\xF9\xBE\xB4\xD9", message_magic: "Bitcoin Signed Message:\n", address_version: "00", p2sh_version: "05", privkey_version: "80", extended_privkey_version: "0488ade4", extended_pubkey_version: "0488b21e", bech32_hrp: "bc", default_port: 8333, protocol_version: 70001, coinbase_maturity: 100, reward_base: 50 * COIN, reward_halving: 210_000, retarget_interval: 2016, retarget_time: 1209600, # 2 weeks target_spacing: 600, # block interval max_money: 21_000_000 * COIN, min_tx_fee: 10_000, min_relay_tx_fee: 10_000, free_tx_bytes: 1_000, dust: CENT, per_dust_fee: false, bip34_height: 227931, dns_seeds: [ "seed.bitcoin.sipa.be", "dnsseed.bluematt.me", "dnsseed.bitcoin.dashjr.org", "bitseed.xf2.org", "dnsseed.webbtc.com", ], genesis_hash: "000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f", proof_of_work_limit: 0x1d00ffff, known_nodes: [ 'relay.eligius.st', 'mining.bitcoin.cz', 'blockchain.info', 'blockexplorer.com', 'webbtc.com', ], checkpoints: { 11111 => "0000000069e244f73d78e8fd29ba2fd2ed618bd6fa2ee92559f542fdb26e7c1d", 33333 => "000000002dd5588a74784eaa7ab0507a18ad16a236e7b1ce69f00d7ddfb5d0a6", 74000 => "0000000000573993a3c9e41ce34471c079dcf5f52a0e824a81e7f953b8661a20", 105000 => "00000000000291ce28027faea320c8d2b054b2e0fe44a773f3eefb151d6bdc97", 134444 => "00000000000005b12ffd4cd315cd34ffd4a594f430ac814c91184a0d42d2b0fe", 168000 => "000000000000099e61ea72015e79632f216fe6cb33d7899acb35b75c8303b763", 193000 => "000000000000059f452a5f7340de6682a977387c17010ff6e6c3bd83ca8b1317", 210000 => "000000000000048b95347e83192f69cf0366076336c639f9b7228e9ba171342e", 216116 => "00000000000001b4f4b433e81ee46494af945cf96014816a4e2370f11b23df4e", 225430 => "00000000000001c108384350f74090433e7fcf79a606b8e797f065b130575932", 290000 => "0000000000000000fa0b2badd05db0178623ebf8dd081fe7eb874c26e27d0b3b", 300000 => "000000000000000082ccf8f1557c5d40b21edabb18d2d691cfbf87118bac7254", 305000 => "0000000000000000142bb90561e1a907d500bf534a6727a63a92af5b6abc6160", } } }
Class Method Summary collapse
- .hmac_sha512(key, data) ⇒ Object
- .network ⇒ Object
- .network=(name) ⇒ Object
- .network_name ⇒ Object
- .network_project ⇒ Object
Methods included from Util
address_type, address_version, base58_checksum?, base58_to_int, bitcoin_byte_hash, bitcoin_elliptic_curve, bitcoin_hash, bitcoin_mrkl, bitcoin_signed_message_hash, block_average_hashing_time, block_average_mining_time, block_creation_reward, block_difficulty, block_hash, block_hashes_to_win, block_new_target, block_next_retarget, block_probability, block_scrypt_hash, blockchain_total_btc, checksum, decode_base58, decode_compact_bits, decode_segwit_address, decode_target, encode_address, encode_base58, encode_compact_bits, encode_segwit_address, generate_address, generate_key, hash160, hash160_from_address, hash160_to_address, hash160_to_p2sh_address, hash_mrkl_branch, hash_mrkl_tree, inspect_key, int_to_base58, litecoin_hash, mrkl_branch_root, open_key, p2sh_version, pubkey_to_address, pubkeys_to_p2sh_multisig_address, regenerate_public_key, sha256, sign_data, sign_message, valid_address?, valid_pubkey?, verify_message, verify_signature, version_bytes
Class Method Details
.hmac_sha512(key, data) ⇒ Object
5 6 7 |
# File 'lib/bitcoin/ext_key.rb', line 5 def self.hmac_sha512(key, data) OpenSSL::HMAC.digest(OpenSSL::Digest.new('SHA512'), key, data) end |
.network ⇒ Object
581 582 583 584 |
# File 'lib/bitcoin.rb', line 581 def self.network # Store the copy of network options so we can modify them in tests without breaking the defaults @network_options ||= NETWORKS[@network].dup end |
.network=(name) ⇒ Object
594 595 596 597 598 599 600 601 602 |
# File 'lib/bitcoin.rb', line 594 def self.network=(name) raise "Network descriptor '#{name}' not found." unless NETWORKS[name.to_sym] @network_options = nil # clear cached parameters @network = name.to_sym @network_project = network[:project] rescue nil Dogecoin.load if dogecoin? || dogecoin_testnet? Namecoin.load if namecoin? && defined?(Namecoin) @network end |
.network_name ⇒ Object
586 587 588 |
# File 'lib/bitcoin.rb', line 586 def self.network_name @network ||= nil end |
.network_project ⇒ Object
590 591 592 |
# File 'lib/bitcoin.rb', line 590 def self.network_project @network_project ||= nil end |