Class: Peatio::Electrum::Wallet
- Inherits:
-
Wallet::Abstract
- Object
- Wallet::Abstract
- Peatio::Electrum::Wallet
- Defined in:
- lib/peatio/electrum/wallet.rb
Overview
See the abstract class here: github.com/openware/peatio-core/blob/master/lib/peatio/wallet/abstract.rb
Instance Method Summary collapse
-
#configure(settings = {}) ⇒ Hash
Merges given configuration parameters with defined during initialization and returns the result.
-
#create_address!(options = {}) ⇒ Hash
Performs API call for address creation and returns it.
-
#create_transaction!(transaction, options = {}) ⇒ Peatio::Transaction
Performs API call for creating transaction and returns updated transaction.
-
#initialize(settings = {}) ⇒ Wallet
constructor
A new instance of Wallet.
-
#load_balance! ⇒ BigDecimal
Fetches address balance of specific currency.
-
#prepare_deposit_collection!(deposit_transaction, spread_transactions, deposit_currency) ⇒ Array<Peatio::Transaction>
Performs API call(s) for preparing for deposit collection.
Constructor Details
#initialize(settings = {}) ⇒ Wallet
Returns a new instance of Wallet.
10 11 12 |
# File 'lib/peatio/electrum/wallet.rb', line 10 def initialize(settings = {}) @settings = settings end |
Instance Method Details
#configure(settings = {}) ⇒ Hash
Be careful with your wallet state after configure. Clean everything what could be related to other wallet configuration. E.g. client state.
Merges given configuration parameters with defined during initialization and returns the result.
With :address required key other settings could be customized using Wallet#settings.
30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/peatio/electrum/wallet.rb', line 30 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, :secret) @currency = @settings.fetch(:currency) do raise Peatio::Wallet::MissingSettingError, :currency end.slice(:id, :base_factor, :options) end |
#create_address!(options = {}) ⇒ Hash
Performs API call for address creation and returns it.
58 59 60 |
# File 'lib/peatio/electrum/wallet.rb', line 58 def create_address!( = {}) method_not_implemented end |
#create_transaction!(transaction, options = {}) ⇒ Peatio::Transaction
Performs API call for creating transaction and returns updated transaction.
to_address, amount & currency_id.
82 83 84 |
# File 'lib/peatio/electrum/wallet.rb', line 82 def create_transaction!(transaction, = {}) method_not_implemented end |
#load_balance! ⇒ BigDecimal
Optional. Don’t override this method if your blockchain
Fetches address balance of specific currency.
doesn’t provide functionality to get balance by address.
if error was raised on wallet API call ClientError is raised. if wallet API call was successful but we can’t detect balance for address Error is raised.
97 98 99 |
# File 'lib/peatio/electrum/wallet.rb', line 97 def load_balance! raise Peatio::Wallet::UnavailableAddressBalanceError end |
#prepare_deposit_collection!(deposit_transaction, spread_transactions, deposit_currency) ⇒ Array<Peatio::Transaction>
Optional. Override this method only if you need additional step
Performs API call(s) for preparing for deposit collection. E.g deposits ETH for collecting ERC20 tokens in case of Ethereum blockchain.
before deposit collection.
describes received deposit.
spread between wallets.
deposit collection preparing. By default return empty [Array]
116 117 118 119 120 |
# File 'lib/peatio/electrum/wallet.rb', line 116 def prepare_deposit_collection!(deposit_transaction, spread_transactions, deposit_currency) # This method is mostly used for coins which needs additional fees # to be deposited before deposit collection. [] end |