module NanoRpc::WalletHelper

Public Instance Methods

account_work(account:) click to toggle source
# File lib/nano_rpc/helpers/wallet_helper.rb, line 5
def account_work(account:)
  work_get(account: account).work
end
account_work_set(account:, work:) click to toggle source
# File lib/nano_rpc/helpers/wallet_helper.rb, line 144
def account_work_set(account:, work:)
  work_set(account: account, work: work).success == ''
end
Also aliased as: set_account_work
accounts() click to toggle source
# File lib/nano_rpc/helpers/wallet_helper.rb, line 9
def accounts
  return [] unless account_list.accounts.size.positive?
  NanoRpc::Accounts.new(account_list.accounts, node: node)
end
add_key(key:, work: true) click to toggle source
# File lib/nano_rpc/helpers/wallet_helper.rb, line 14
def add_key(key:, work: true)
  wallet_add(key: key, work: work).account
end
add_watch(accounts:) click to toggle source
# File lib/nano_rpc/helpers/wallet_helper.rb, line 18
def add_watch(accounts:)
  wallet_add_watch(accounts: accounts).success == ''
end
balance() click to toggle source
# File lib/nano_rpc/helpers/wallet_helper.rb, line 22
def balance
  wallet_info.balance
end
balance_pending()
Alias for: pending_balance
balances(threshold: nil) click to toggle source
# File lib/nano_rpc/helpers/wallet_helper.rb, line 26
def balances(threshold: nil)
  wallet_balances(threshold: threshold)
    .balances
    .each_with_object({}) do |(k, v), hash|
      hash[k] = v['balance'].to_i
    end
end
balances_pending(threshold: nil)
Alias for: pending_balances
begin_payment() click to toggle source
# File lib/nano_rpc/helpers/wallet_helper.rb, line 34
def begin_payment
  payment_begin.account
end
blocks_pending(count:, threshold: nil, source: nil, include_active: nil)
Alias for: pending_blocks
change_password(new_password:) click to toggle source
# File lib/nano_rpc/helpers/wallet_helper.rb, line 38
def change_password(new_password:)
  password_change(password: new_password).changed == 1
end
change_seed(new_seed:, count: 0) click to toggle source
# File lib/nano_rpc/helpers/wallet_helper.rb, line 42
def change_seed(new_seed:, count: 0)
  wallet_change_seed(seed: new_seed, count: count).success == ''
end
contains?(account:) click to toggle source
# File lib/nano_rpc/helpers/wallet_helper.rb, line 46
def contains?(account:)
  wallet_contains(account: account).exists == 1
end
create_account(work: true) click to toggle source
# File lib/nano_rpc/helpers/wallet_helper.rb, line 50
def create_account(work: true)
  address = account_create(work: work).account
  NanoRpc::Account.new(address, node: node)
end
create_accounts(count:, work: true) click to toggle source
# File lib/nano_rpc/helpers/wallet_helper.rb, line 55
def create_accounts(count:, work: true)
  addresses = accounts_create(count: count, work: work).accounts
  NanoRpc::Accounts.new(addresses, node: node)
end
destroy() click to toggle source
# File lib/nano_rpc/helpers/wallet_helper.rb, line 60
def destroy
  wallet_destroy.destroyed == 1
end
enter_password(password:) click to toggle source
# File lib/nano_rpc/helpers/wallet_helper.rb, line 64
def enter_password(password:)
  password_enter(password: password).valid == 1
end
Also aliased as: unlock
export() click to toggle source
# File lib/nano_rpc/helpers/wallet_helper.rb, line 69
def export
  NanoRpc::Response.new(JSON[wallet_export.json])
end
frontiers() click to toggle source
# File lib/nano_rpc/helpers/wallet_helper.rb, line 73
def frontiers
  wallet_frontiers.frontiers
end
history(modified_since: 0) click to toggle source
# File lib/nano_rpc/helpers/wallet_helper.rb, line 77
def history(modified_since: 0)
  wallet_history(modified_since: modified_since).history
end
init_payment() click to toggle source
# File lib/nano_rpc/helpers/wallet_helper.rb, line 81
def init_payment
  payment_init.status == 'Ready'
end
ledger() click to toggle source
# File lib/nano_rpc/helpers/wallet_helper.rb, line 85
def ledger
  wallet_ledger.accounts
end
locked?() click to toggle source
# File lib/nano_rpc/helpers/wallet_helper.rb, line 89
def locked?
  wallet_locked.locked == 1
end
move_accounts(to:, accounts:) click to toggle source
# File lib/nano_rpc/helpers/wallet_helper.rb, line 93
def move_accounts(to:, accounts:)
  account_move(wallet: to, source: id, accounts: accounts).moved == 1
end
password_valid?(password:) click to toggle source
# File lib/nano_rpc/helpers/wallet_helper.rb, line 97
def password_valid?(password:)
  password_valid(password: password).valid == 1
end
pending_balance() click to toggle source
# File lib/nano_rpc/helpers/wallet_helper.rb, line 101
def pending_balance
  wallet_info.pending
end
Also aliased as: balance_pending
pending_balances(threshold: nil) click to toggle source
# File lib/nano_rpc/helpers/wallet_helper.rb, line 106
def pending_balances(threshold: nil)
  wallet_balances(threshold: threshold)
    .balances
    .each_with_object({}) do |(k, v), hash|
      hash[k] = v['pending'].to_i
    end
end
Also aliased as: balances_pending
pending_blocks(count:, threshold: nil, source: nil, include_active: nil) click to toggle source
# File lib/nano_rpc/helpers/wallet_helper.rb, line 115
def pending_blocks(count:, threshold: nil, source: nil, include_active: nil)
  wallet_pending(
    count: count,
    threshold: threshold,
    source: source,
    include_active: include_active
  ).blocks
end
Also aliased as: blocks_pending
receive_block(account:, block:) click to toggle source
# File lib/nano_rpc/helpers/wallet_helper.rb, line 125
def receive_block(account:, block:)
  receive(
    account: account,
    block: block
  ).block
end
remove_account(account:) click to toggle source
# File lib/nano_rpc/helpers/wallet_helper.rb, line 132
def remove_account(account:)
  account_remove(account: account).removed == 1
end
representative() click to toggle source
# File lib/nano_rpc/helpers/wallet_helper.rb, line 136
def representative
  wallet_representative.representative
end
representative_set(representative:) click to toggle source
# File lib/nano_rpc/helpers/wallet_helper.rb, line 149
def representative_set(representative:)
  wallet_representative_set(representative: representative).set == 1
end
Also aliased as: set_representative
republish(count:) click to toggle source
# File lib/nano_rpc/helpers/wallet_helper.rb, line 140
def republish(count:)
  wallet_republish(count: count).blocks
end
send_nano(from:, to:, amount:, id: nil, work: nil) click to toggle source
# File lib/nano_rpc/helpers/wallet_helper.rb, line 154
def send_nano(from:, to:, amount:, id: nil, work: nil)
  from = from.respond_to?(:address) ? from.address : from
  to = to.respond_to?(:address) ? to.address : to
  send_currency(
    source: from,
    destination: to,
    amount: amount,
    id: id,
    work: work
  ).block
end
Also aliased as: send_transaction
send_transaction(from:, to:, amount:, id: nil, work: nil)
Alias for: send_nano
set_account_work(account:, work:)
Alias for: account_work_set
set_representative(representative:)
Alias for: representative_set
unlock(password:)
Alias for: enter_password
work() click to toggle source
# File lib/nano_rpc/helpers/wallet_helper.rb, line 167
def work
  wallet_work_get.works
end