Module: Bitcoin

Extended by:
Util
Defined in:
lib/bitcoin/contracthash.rb,
lib/bitcoin.rb,
lib/bitcoin/key.rb,
lib/bitcoin/logger.rb,
lib/bitcoin/builder.rb,
lib/bitcoin/version.rb,
lib/bitcoin/protocol.rb,
lib/bitcoin/connection.rb,
lib/bitcoin/ffi/openssl.rb,
lib/bitcoin/protocol/tx.rb,
lib/bitcoin/protocol/txin.rb,
lib/bitcoin/ffi/secp256k1.rb,
lib/bitcoin/protocol/alert.rb,
lib/bitcoin/protocol/block.rb,
lib/bitcoin/protocol/txout.rb,
lib/bitcoin/trezor/mnemonic.rb,
lib/bitcoin/protocol/parser.rb,
lib/bitcoin/protocol/reject.rb,
lib/bitcoin/protocol/aux_pow.rb,
lib/bitcoin/protocol/address.rb,
lib/bitcoin/protocol/handler.rb,
lib/bitcoin/protocol/version.rb,
lib/bitcoin/ffi/bitcoinconsensus.rb

Overview

binding for src/.libs/bitcoinconsensus.so (github.com/bitcoin/bitcoin) tag: v0.11.0 commit: d26f951802c762de04fb68e1a112d611929920ba

Defined Under Namespace

Modules: BinaryExtensions, BitcoinConsensus, Builder, ConnectionHandler, ContractHash, Dogecoin, Logger, OpenSSL_EC, Protocol, Secp256k1, Trezor, Util Classes: Connection, Key, Script

Constant Summary

VERSION =
"0.0.8"
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",
    address_version: "00",
    p2sh_version: "05",
    privkey_version: "80",
    extended_privkey_version: "0488ade4",
    extended_pubkey_version: "0488b21e",
    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,
    alert_pubkeys: ["04fc9702847840aaf195de8442ebecedf5b095cdbb9bc716bda9110971b28a49e0ead8564ff0db22209e0374782c093bb899692d524e9d6a6956e7c5ecbcd68284"],
    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

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_target, encode_address, encode_base58, encode_compact_bits, 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

Class Method Details

.networkObject



484
485
486
487
# File 'lib/bitcoin.rb', line 484

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



497
498
499
500
501
502
503
504
505
# File 'lib/bitcoin.rb', line 497

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_nameObject



489
490
491
# File 'lib/bitcoin.rb', line 489

def self.network_name
  @network
end

.network_projectObject



493
494
495
# File 'lib/bitcoin.rb', line 493

def self.network_project
  @network_project
end