Class: Peatio::Dogecoin::Wallet
- Inherits:
-
Wallet::Abstract
- Object
- Wallet::Abstract
- Peatio::Dogecoin::Wallet
- Defined in:
- lib/peatio/dogecoin/wallet.rb
Constant Summary collapse
- DEFAULT_FEATURES =
{ skip_deposit_collection: false }.freeze
Instance Method Summary collapse
- #configure(settings = {}) ⇒ Object
- #create_address!(_options = {}) ⇒ Object
- #create_transaction!(transaction, options = {}) ⇒ Object
-
#initialize(custom_features = {}) ⇒ Wallet
constructor
A new instance of Wallet.
- #load_balance! ⇒ Object
Constructor Details
#initialize(custom_features = {}) ⇒ Wallet
Returns a new instance of Wallet.
7 8 9 10 |
# File 'lib/peatio/dogecoin/wallet.rb', line 7 def initialize(custom_features = {}) @features = DEFAULT_FEATURES.merge(custom_features).slice(*SUPPORTED_FEATURES) @settings = {} end |
Instance Method Details
#configure(settings = {}) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/peatio/dogecoin/wallet.rb', line 12 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 = {}) ⇒ Object
27 28 29 30 31 |
# File 'lib/peatio/dogecoin/wallet.rb', line 27 def create_address!( = {}) { address: client.json_rpc(:getnewaddress) } rescue Dogecoin::Client::Error => e raise Peatio::Wallet::ClientError, e end |
#create_transaction!(transaction, options = {}) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/peatio/dogecoin/wallet.rb', line 33 def create_transaction!(transaction, = {}) txid = client.json_rpc(:sendtoaddress, [ transaction.to_address, transaction.amount, '', '', [:subtract_fee].to_s == 'true' # subtract fee from transaction amount. ]) transaction.hash = txid transaction rescue Dogecoin::Client::Error => e raise Peatio::Wallet::ClientError, e end |
#load_balance! ⇒ Object
48 49 50 51 52 53 |
# File 'lib/peatio/dogecoin/wallet.rb', line 48 def load_balance! client.json_rpc(:getbalance).to_d rescue Dogecoin::Client::Error => e raise Peatio::Wallet::ClientError, e end |