module Tapyrus
Porting part of the code from bitcoin-ruby. see the license. github.com/lian/bitcoin-ruby/blob/master/COPYING
Porting part of the code from bitcoin-ruby. see the license. github.com/lian/bitcoin-ruby/blob/master/COPYING
Porting part of the code from bitcoin-ruby. see the license. github.com/lian/bitcoin-ruby/blob/master/COPYING
Porting part of the code from bitcoin-ruby. see the license. github.com/lian/bitcoin-ruby/blob/master/COPYING
Porting part of the code from bitcoin-ruby. see the license. github.com/lian/bitcoin-ruby/blob/master/COPYING
Porting part of the code from bitcoin-ruby. see the license. github.com/lian/bitcoin-ruby/blob/master/COPYING
Porting part of the code from bitcoin-ruby. see the license. github.com/lian/bitcoin-ruby/blob/master/COPYING
Constants
- BIP32_EXTKEY_WITH_VERSION_SIZE
- COIN
- COINBASE_MATURITY
Coinbase transaction outputs can only be spent after this number of new blocks (network rule)
- COINBASE_WTXID
- CURVE_ORDER
Integers modulo the order of the curve(secp256k1)
- DEFAULT_MAX_NUM_SIZE
Maximum number length in bytes
- DUST_RELAY_TX_FEE
Min feerate for defining dust.
- ERRCODES_MAP
- HARDENED_THRESHOLD
- LOCKTIME_MEDIAN_TIME_PAST
- LOCKTIME_THRESHOLD
Threshold for nLockTime: below this value it is interpreted as block number, otherwise as UNIX timestamp.
- LOCKTIME_VERIFY_SEQUENCE
Flags for nSequence and nLockTime locks
- MANDATORY_SCRIPT_VERIFY_FLAGS
- MAX_BLOCK_SERIALIZED_SIZE
The maximum allowed size for a serialized block, in bytes (only for buffer size limits)
- MAX_BLOCK_SIGOPS_COST
The maximum allowed number of signature check operations in a block (network rule)
- MAX_BLOCK_WEIGHT
The maximum allowed weight for a block, see BIP 141 (network rule)
- MAX_FUTURE_BLOCK_TIME
Maximum amount of time that a block timestamp is allowed to exceed the current network-adjusted time before the block will be accepted.
- MAX_MONEY
- MAX_OPS_PER_SCRIPT
Maximum number of non-push operations per script
- MAX_OP_RETURN_RELAY
80 bytes of data, +1 for OP_RETURN, +2 for the pushdata opcodes.
- MAX_PUBKEYS_PER_MULTISIG
Maximum number of public keys per multisig
- MAX_SCRIPT_ELEMENT_SIZE
Maximum number of bytes pushable to the stack
- MAX_SCRIPT_SIZE
Maximum script length in bytes
- MAX_STACK_SIZE
Maximum number of size in the stack
- MEDIAN_TIME_SPAN
Size of set to pick median time from.
- MESSAGE_HEADER_SIZE
for message
- MIN_SERIALIZABLE_TRANSACTION_WEIGHT
10 is the lower bound for the size of a serialized
Tx
- MIN_TRANSACTION_WEIGHT
60 is the lower bound for the size of a valid serialized
Tx
- NAME_MAP
- PARALLEL_THREAD
for peer
- SCRIPT_ERR_BAD_OPCODE
Logical/Format/Canonical errors
- SCRIPT_ERR_CHECKDATASIGVERIFY
- SCRIPT_ERR_CHECKMULTISIGVERIFY
- SCRIPT_ERR_CHECKSIGVERIFY
- SCRIPT_ERR_CLEANSTACK
- SCRIPT_ERR_DISABLED_OPCODE
- SCRIPT_ERR_DISCOURAGE_UPGRADABLE_NOPS
softfork safeness
- SCRIPT_ERR_EQUALVERIFY
- SCRIPT_ERR_ERROR_COUNT
- SCRIPT_ERR_EVAL_FALSE
- SCRIPT_ERR_INVALID_ALTSTACK_OPERATION
- SCRIPT_ERR_INVALID_STACK_OPERATION
- SCRIPT_ERR_MINIMALDATA
- SCRIPT_ERR_MINIMALIF
- SCRIPT_ERR_MIXED_SCHEME_MULTISIG
- SCRIPT_ERR_NEGATIVE_LOCKTIME
CHECKLOCKTIMEVERIFY and CHECKSEQUENCEVERIFY
- SCRIPT_ERR_NUMEQUALVERIFY
- SCRIPT_ERR_OK
for script error
- SCRIPT_ERR_OP_CODESEPARATOR
Constant scriptCode
- SCRIPT_ERR_OP_COLOR_ID_INVALID
- SCRIPT_ERR_OP_COLOR_IN_BRANCH
- SCRIPT_ERR_OP_COLOR_MULTIPLE
- SCRIPT_ERR_OP_COLOR_UNEXPECTED
- SCRIPT_ERR_OP_COUNT
- SCRIPT_ERR_OP_RETURN
- SCRIPT_ERR_PUBKEYTYPE
- SCRIPT_ERR_PUBKEY_COUNT
- SCRIPT_ERR_PUSH_SIZE
- SCRIPT_ERR_SCRIPT_SIZE
Max sizes
- SCRIPT_ERR_SIG_COUNT
- SCRIPT_ERR_SIG_DER
- SCRIPT_ERR_SIG_FINDANDDELETE
- SCRIPT_ERR_SIG_HASHTYPE
Malleability
- SCRIPT_ERR_SIG_HIGH_S
- SCRIPT_ERR_SIG_NULLDUMMY
- SCRIPT_ERR_SIG_NULLFAIL
- SCRIPT_ERR_SIG_PUSHONLY
- SCRIPT_ERR_STACK_SIZE
- SCRIPT_ERR_UNBALANCED_CONDITIONAL
- SCRIPT_ERR_UNKNOWN_ERROR
- SCRIPT_ERR_UNSATISFIED_LOCKTIME
- SCRIPT_ERR_VERIFY
Failed verify operations
- SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY
- SCRIPT_VERIFY_CHECKSEQUENCEVERIFY
- SCRIPT_VERIFY_CLEANSTACK
- SCRIPT_VERIFY_CONST_SCRIPTCODE
- SCRIPT_VERIFY_DERSIG
- SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS
- SCRIPT_VERIFY_LOW_S
- SCRIPT_VERIFY_MINIMALDATA
- SCRIPT_VERIFY_MINIMALIF
- SCRIPT_VERIFY_NONE
script verify flags
- SCRIPT_VERIFY_NULLDUMMY
- SCRIPT_VERIFY_NULLFAIL
- SCRIPT_VERIFY_P2SH
- SCRIPT_VERIFY_SIGPUSHONLY
- SCRIPT_VERIFY_STRICTENC
- SIGHASH_TYPE
Signature hash types/flags
- SIG_VERSION
- STANDARD_SCRIPT_VERIFY_FLAGS
Standard script verification flags that standard transactions will comply with.
- VERSION
- WITNESS_SCALE_FACTOR
Public Class Methods
base dir path that store blockchain data and wallet data
# File lib/tapyrus.rb, line 81 def self.base_dir "#{Dir.home}/.tapyrusrb/#{@chain_param}" end
current tapyrus network chain params.
# File lib/tapyrus.rb, line 69 def self.chain_params return @current_chain if @current_chain case @chain_param when :prod @current_chain = Tapyrus::ChainParams.prod when :dev @current_chain = Tapyrus::ChainParams.dev end @current_chain end
set tapyrus network chain params
# File lib/tapyrus.rb, line 62 def self.chain_params=(name) raise "chain params for #{name} is not defined." unless %i[prod dev].include?(name.to_sym) @current_chain = nil @chain_param = name.to_sym end
# File lib/tapyrus.rb, line 95 def self.hmac_sha256(key, data) OpenSSL::HMAC.digest(OpenSSL::Digest.new('SHA256'), key, data) end
# File lib/tapyrus.rb, line 91 def self.hmac_sha512(key, data) OpenSSL::HMAC.digest(OpenSSL::Digest.new('SHA512'), key, data) end
get secp implementation module
# File lib/tapyrus.rb, line 86 def self.secp_impl path = ENV['SECP256K1_LIB_PATH'] (path && File.exist?(path)) ? Tapyrus::Secp256k1::Native : Tapyrus::Secp256k1::Ruby end