Method: Radiator::Transaction#initialize
- Defined in:
- lib/radiator/transaction.rb
#initialize(options = {}) ⇒ Transaction
Returns a new instance of Transaction.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/radiator/transaction.rb', line 18 def initialize( = {}) = .dup .each do |k, v| k = k.to_sym if VALID_OPTIONS.include?(k.to_sym) .delete(k) send("#{k}=", v) end end @url = [:url] || url @chain ||= 'hive' @chain = @chain.to_sym @chain_id = chain_id [:chain_id] @operations = [:operations] || [] @self_logger = false @logger = if [:logger].nil? @self_logger = true Radiator.logger else [:logger] end unless NETWORK_CHAIN_IDS.include? @chain_id warning "Unknown chain id: #{@chain_id}" end if !!wif && !!private_key raise TransactionError, "Do not pass both wif and private_key. That's confusing." end if !!wif @private_key = Bitcoin::Key.from_base58 wif end @ref_block_num ||= nil @ref_block_prefix ||= nil @expiration ||= nil @immutable_expiration = !!@expiration = .merge( url: @url, chain: @chain, pool_size: 1, persist: false, reuse_ssl_sessions: false ) @api = Api.new() @network_broadcast_api = NetworkBroadcastApi.new() @use_condenser_namespace = if .keys.include? :use_condenser_namespace [:use_condenser_namespace] else true end ObjectSpace.define_finalizer(self, self.class.finalize(@api, @network_broadcast_api, @self_logger, @logger)) end |