class Peatio::Goldcash::Wallet
Public Class Methods
new(settings = {})
click to toggle source
# File lib/peatio/goldcash/wallet.rb, line 7 def initialize(settings = {}) @settings = settings end
Public Instance Methods
configure(settings = {})
click to toggle source
# File lib/peatio/goldcash/wallet.rb, line 11 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
create_address!(_options = {})
click to toggle source
# File lib/peatio/goldcash/wallet.rb, line 26 def create_address!(_options = {}) { address: client.json_rpc(:getnewaddress) } rescue Goldcash::Client::Error => e raise Peatio::Wallet::ClientError, e end
create_transaction!(transaction, options = {})
click to toggle source
# File lib/peatio/goldcash/wallet.rb, line 32 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 Goldcash::Client::Error => e raise Peatio::Wallet::ClientError, e end
load_balance!()
click to toggle source
# File lib/peatio/goldcash/wallet.rb, line 47 def load_balance! client.json_rpc(:getbalance).to_d rescue Goldcash::Client::Error => e raise Peatio::Wallet::ClientError, e end
Private Instance Methods
client()
click to toggle source
# File lib/peatio/goldcash/wallet.rb, line 56 def client uri = @wallet.fetch(:uri) { raise Peatio::Wallet::MissingSettingError, :uri } @client ||= Client.new(uri, idle_timeout: 1) end