Class: Peatio::Thought::Wallet
- Inherits:
-
Wallet::Abstract
- Object
- Wallet::Abstract
- Peatio::Thought::Wallet
- Defined in:
- lib/peatio/thought/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.
8 9 10 11 |
# File 'lib/peatio/thought/wallet.rb', line 8 def initialize(custom_features = {}) @features = DEFAULT_FEATURES.merge(custom_features).slice(*SUPPORTED_FEATURES) @settings = {} end |
Instance Method Details
#configure(settings = {}) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/peatio/thought/wallet.rb', line 13 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
28 29 30 31 32 |
# File 'lib/peatio/thought/wallet.rb', line 28 def create_address!(={}) {address: client.json_rpc(:getnewaddress)} rescue Thought::Client::Error => e raise Peatio::Wallet::ClientError, e end |
#create_transaction!(transaction, options = {}) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/peatio/thought/wallet.rb', line 34 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 Thought::Client::Error => e raise Peatio::Wallet::ClientError, e end |