Sha256: 9a94a28e6e1f364e30f1991c423d6b6f0585adb8e0de9b566d784f495d3720a2
Contents?: true
Size: 1.73 KB
Versions: 2
Compression:
Stored size: 1.73 KB
Contents
module Peatio module Axe class Wallet < Peatio::Wallet::Abstract def initialize(settings = {}) @settings = settings end def configure(settings = {}) # Clean client state during configure. @client = nil @settings.merge!(settings.slice(*SUPPORTED_SETTINGS)) @wallet = @settings.fetch(:wallet) do raise Peatio::Wallet::MissingSettingError, :wallet end.slice(:uri, :address) @currency = @settings.fetch(:currency) do raise Peatio::Wallet::MissingSettingError, :currency end.slice(:id, :base_factor, :options) end def create_address!(_options = {}) { address: client.json_rpc(:getnewaddress) } rescue Axe::Client::Error => e raise Peatio::Wallet::ClientError, e end def create_transaction!(transaction, options = {}) txid = client.json_rpc(:sendtoaddress, [ transaction.to_address, transaction.amount, '', '', options[:subtract_fee].to_s == 'true' # subtract fee from transaction amount. ]) transaction.hash = txid transaction rescue Axe::Client::Error => e raise Peatio::Wallet::ClientError, e end def load_balance! client.json_rpc(:getbalance).to_d rescue Axe::Client::Error => e raise Peatio::Wallet::ClientError, e end private def client uri = @wallet.fetch(:uri) { raise Peatio::Wallet::MissingSettingError, :uri } @client ||= Client.new(uri) end end end end
Version data entries
2 entries across 2 versions & 2 rubygems
Version | Path |
---|---|
peatio-axe-0.2.3 | lib/peatio/axe/wallet.rb |
ultex-axe-0.2.1 | lib/peatio/axe/wallet.rb |