Module: NanoRpc::WalletHelper
Instance Method Summary collapse
- #account_work(account:) ⇒ Object
 - #account_work_set(account:, work:) ⇒ Object (also: #set_account_work)
 - #accounts ⇒ Object
 - #add_key(key:, work: true) ⇒ Object
 - #add_watch(accounts:) ⇒ Object
 - #balance ⇒ Object
 - #balances(threshold: nil) ⇒ Object
 - #begin_payment ⇒ Object
 - #change_password(new_password:) ⇒ Object
 - #change_seed(new_seed:, count: 0) ⇒ Object
 - #contains?(account:) ⇒ Boolean
 - #create_account(work: true) ⇒ Object
 - #create_accounts(count:, work: true) ⇒ Object
 - #destroy ⇒ Object
 - #enter_password(password:) ⇒ Object (also: #unlock)
 - #export ⇒ Object
 - #frontiers ⇒ Object
 - #history(modified_since: 0) ⇒ Object
 - #init_payment ⇒ Object
 - #ledger ⇒ Object
 - #locked? ⇒ Boolean
 - #move_accounts(to:, accounts:) ⇒ Object
 - #password_valid?(password:) ⇒ Boolean
 - #pending_balance ⇒ Object (also: #balance_pending)
 - #pending_balances(threshold: nil) ⇒ Object (also: #balances_pending)
 - #pending_blocks(count:, threshold: nil, source: nil, include_active: nil) ⇒ Object (also: #blocks_pending)
 - #receive_block(account:, block:) ⇒ Object
 - #remove_account(account:) ⇒ Object
 - #representative ⇒ Object
 - #representative_set(representative:) ⇒ Object (also: #set_representative)
 - #republish(count:) ⇒ Object
 - #send_nano(from:, to:, amount:, id: nil, work: nil) ⇒ Object (also: #send_transaction)
 - #work ⇒ Object
 
Instance Method Details
#account_work(account:) ⇒ Object
      5 6 7  | 
    
      # 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:) ⇒ Object Also known as: set_account_work
      144 145 146  | 
    
      # File 'lib/nano_rpc/helpers/wallet_helper.rb', line 144 def account_work_set(account:, work:) work_set(account: account, work: work).success == '' end  | 
  
#accounts ⇒ Object
      9 10 11 12  | 
    
      # 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) ⇒ Object
      14 15 16  | 
    
      # 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:) ⇒ Object
      18 19 20  | 
    
      # File 'lib/nano_rpc/helpers/wallet_helper.rb', line 18 def add_watch(accounts:) wallet_add_watch(accounts: accounts).success == '' end  | 
  
#balance ⇒ Object
      22 23 24  | 
    
      # File 'lib/nano_rpc/helpers/wallet_helper.rb', line 22 def balance wallet_info.balance end  | 
  
#balances(threshold: nil) ⇒ Object
      26 27 28 29 30 31 32  | 
    
      # 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  | 
  
#begin_payment ⇒ Object
      34 35 36  | 
    
      # File 'lib/nano_rpc/helpers/wallet_helper.rb', line 34 def begin_payment payment_begin.account end  | 
  
#change_password(new_password:) ⇒ Object
      38 39 40  | 
    
      # 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) ⇒ Object
      42 43 44  | 
    
      # 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:) ⇒ Boolean
      46 47 48  | 
    
      # File 'lib/nano_rpc/helpers/wallet_helper.rb', line 46 def contains?(account:) wallet_contains(account: account).exists == 1 end  | 
  
#create_account(work: true) ⇒ Object
      50 51 52 53  | 
    
      # 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) ⇒ Object
      55 56 57 58  | 
    
      # 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 ⇒ Object
      60 61 62  | 
    
      # File 'lib/nano_rpc/helpers/wallet_helper.rb', line 60 def destroy wallet_destroy.destroyed == 1 end  | 
  
#enter_password(password:) ⇒ Object Also known as: unlock
      64 65 66  | 
    
      # File 'lib/nano_rpc/helpers/wallet_helper.rb', line 64 def enter_password(password:) password_enter(password: password).valid == 1 end  | 
  
#export ⇒ Object
      69 70 71  | 
    
      # File 'lib/nano_rpc/helpers/wallet_helper.rb', line 69 def export NanoRpc::Response.new(JSON[wallet_export.json]) end  | 
  
#frontiers ⇒ Object
      73 74 75  | 
    
      # File 'lib/nano_rpc/helpers/wallet_helper.rb', line 73 def frontiers wallet_frontiers.frontiers end  | 
  
#history(modified_since: 0) ⇒ Object
      77 78 79  | 
    
      # 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 ⇒ Object
      81 82 83  | 
    
      # File 'lib/nano_rpc/helpers/wallet_helper.rb', line 81 def init_payment payment_init.status == 'Ready' end  | 
  
#ledger ⇒ Object
      85 86 87  | 
    
      # File 'lib/nano_rpc/helpers/wallet_helper.rb', line 85 def ledger wallet_ledger.accounts end  | 
  
#locked? ⇒ Boolean
      89 90 91  | 
    
      # File 'lib/nano_rpc/helpers/wallet_helper.rb', line 89 def locked? wallet_locked.locked == 1 end  | 
  
#move_accounts(to:, accounts:) ⇒ Object
      93 94 95  | 
    
      # 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:) ⇒ Boolean
      97 98 99  | 
    
      # File 'lib/nano_rpc/helpers/wallet_helper.rb', line 97 def password_valid?(password:) password_valid(password: password).valid == 1 end  | 
  
#pending_balance ⇒ Object Also known as: balance_pending
      101 102 103  | 
    
      # File 'lib/nano_rpc/helpers/wallet_helper.rb', line 101 def pending_balance wallet_info.pending end  | 
  
#pending_balances(threshold: nil) ⇒ Object Also known as: balances_pending
      106 107 108 109 110 111 112  | 
    
      # 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  | 
  
#pending_blocks(count:, threshold: nil, source: nil, include_active: nil) ⇒ Object Also known as: blocks_pending
      115 116 117 118 119 120 121 122  | 
    
      # 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  | 
  
#receive_block(account:, block:) ⇒ Object
      125 126 127 128 129 130  | 
    
      # 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:) ⇒ Object
      132 133 134  | 
    
      # File 'lib/nano_rpc/helpers/wallet_helper.rb', line 132 def remove_account(account:) account_remove(account: account).removed == 1 end  | 
  
#representative ⇒ Object
      136 137 138  | 
    
      # File 'lib/nano_rpc/helpers/wallet_helper.rb', line 136 def representative wallet_representative.representative end  | 
  
#representative_set(representative:) ⇒ Object Also known as: set_representative
      149 150 151  | 
    
      # File 'lib/nano_rpc/helpers/wallet_helper.rb', line 149 def representative_set(representative:) wallet_representative_set(representative: representative).set == 1 end  | 
  
#republish(count:) ⇒ Object
      140 141 142  | 
    
      # 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) ⇒ Object Also known as: send_transaction
      154 155 156 157 158 159 160 161 162 163 164  | 
    
      # 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  | 
  
#work ⇒ Object
      167 168 169  | 
    
      # File 'lib/nano_rpc/helpers/wallet_helper.rb', line 167 def work wallet_work_get.works end  |