Class: Peatio::Dash::Wallet
- Inherits:
-
Wallet::Abstract
- Object
- Wallet::Abstract
- Peatio::Dash::Wallet
- Defined in:
- lib/peatio/dash/wallet.rb
Instance Method Summary collapse
- #configure(settings = {}) ⇒ Object
- #create_address!(_options = {}) ⇒ Object
- #create_transaction!(transaction, options = {}) ⇒ Object
-
#initialize(settings = {}) ⇒ Wallet
constructor
A new instance of Wallet.
- #load_balance! ⇒ Object
Constructor Details
#initialize(settings = {}) ⇒ Wallet
Returns a new instance of Wallet.
6 7 8 |
# File 'lib/peatio/dash/wallet.rb', line 6 def initialize(settings={}) @settings = settings end |
Instance Method Details
#configure(settings = {}) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/peatio/dash/wallet.rb', line 10 def configure(settings={}) # Clean client state during configure. @client = nil @settings.merge!(settings.slice(*SUPPORTED_SETTINGS)) @wallet = @settings.fetch(:wallet) { raise Peatio::Wallet::MissingSettingError, :wallet }.slice(:uri, :address) @currency = @settings.fetch(:currency) { raise Peatio::Wallet::MissingSettingError, :currency }.slice(:id, :base_factor, :options) end |
#create_address!(_options = {}) ⇒ Object
25 26 27 28 29 |
# File 'lib/peatio/dash/wallet.rb', line 25 def create_address!(={}) {address: client.json_rpc(:getnewaddress)} rescue Dash::Client::Error => e raise Peatio::Wallet::ClientError, e end |
#create_transaction!(transaction, options = {}) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/peatio/dash/wallet.rb', line 31 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 Dash::Client::Error => e raise Peatio::Wallet::ClientError, e end |