Module: Nano::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
- #balance ⇒ Object
- #balances(threshold: nil) ⇒ Object
- #begin_payment ⇒ Object
- #change_password(new_password:) ⇒ Object
- #change_seed(new_seed:) ⇒ Object
- #contains?(account:) ⇒ Boolean
- #create_account(work: true) ⇒ Object
- #create_accounts(count:, work: true) ⇒ Object
- #destroy ⇒ Object
- #enter_password(password:) ⇒ Object
- #export ⇒ Object
- #frontiers ⇒ Object
- #init_payment ⇒ 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) ⇒ 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:, 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
130 131 132 |
# File 'lib/nano_rpc/helpers/wallet_helper.rb', line 130 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? Nano::Accounts.new(account_list.accounts, client: client) 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 |
#balance ⇒ Object
18 19 20 |
# File 'lib/nano_rpc/helpers/wallet_helper.rb', line 18 def balance wallet_balance_total.balance end |
#balances(threshold: nil) ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/nano_rpc/helpers/wallet_helper.rb', line 22 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
30 31 32 |
# File 'lib/nano_rpc/helpers/wallet_helper.rb', line 30 def begin_payment payment_begin.account end |
#change_password(new_password:) ⇒ Object
34 35 36 |
# File 'lib/nano_rpc/helpers/wallet_helper.rb', line 34 def change_password(new_password:) password_change(password: new_password).changed == 1 end |
#change_seed(new_seed:) ⇒ Object
38 39 40 |
# File 'lib/nano_rpc/helpers/wallet_helper.rb', line 38 def change_seed(new_seed:) wallet_change_seed(seed: new_seed).success == '' end |
#contains?(account:) ⇒ Boolean
42 43 44 |
# File 'lib/nano_rpc/helpers/wallet_helper.rb', line 42 def contains?(account:) wallet_contains(account: account).exists == 1 end |
#create_account(work: true) ⇒ Object
46 47 48 49 |
# File 'lib/nano_rpc/helpers/wallet_helper.rb', line 46 def create_account(work: true) address = account_create(work: work).account Nano::Account.new(address, client: client) end |
#create_accounts(count:, work: true) ⇒ Object
51 52 53 54 |
# File 'lib/nano_rpc/helpers/wallet_helper.rb', line 51 def create_accounts(count:, work: true) addresses = accounts_create(count: count, work: work).accounts Nano::Accounts.new(addresses, client: client) end |
#destroy ⇒ Object
56 57 58 |
# File 'lib/nano_rpc/helpers/wallet_helper.rb', line 56 def destroy wallet_destroy end |
#enter_password(password:) ⇒ Object
60 61 62 |
# File 'lib/nano_rpc/helpers/wallet_helper.rb', line 60 def enter_password(password:) password_enter(password: password).valid == 1 end |
#export ⇒ Object
64 65 66 |
# File 'lib/nano_rpc/helpers/wallet_helper.rb', line 64 def export Nano::Response.new(JSON[wallet_export.json]) end |
#frontiers ⇒ Object
68 69 70 |
# File 'lib/nano_rpc/helpers/wallet_helper.rb', line 68 def frontiers wallet_frontiers.frontiers end |
#init_payment ⇒ Object
72 73 74 |
# File 'lib/nano_rpc/helpers/wallet_helper.rb', line 72 def init_payment payment_init.status == 'Ready' end |
#locked? ⇒ Boolean
76 77 78 |
# File 'lib/nano_rpc/helpers/wallet_helper.rb', line 76 def locked? wallet_locked.locked == 1 end |
#move_accounts(to:, accounts:) ⇒ Object
80 81 82 |
# File 'lib/nano_rpc/helpers/wallet_helper.rb', line 80 def move_accounts(to:, accounts:) account_move(wallet: to, source: seed, accounts: accounts).moved == 1 end |
#password_valid?(password:) ⇒ Boolean
84 85 86 |
# File 'lib/nano_rpc/helpers/wallet_helper.rb', line 84 def password_valid?(password:) password_valid(password: password).valid == 1 end |
#pending_balance ⇒ Object Also known as: balance_pending
88 89 90 |
# File 'lib/nano_rpc/helpers/wallet_helper.rb', line 88 def pending_balance wallet_balance_total.pending end |
#pending_balances(threshold: nil) ⇒ Object Also known as: balances_pending
93 94 95 96 97 98 99 |
# File 'lib/nano_rpc/helpers/wallet_helper.rb', line 93 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) ⇒ Object Also known as: blocks_pending
102 103 104 105 106 107 108 |
# File 'lib/nano_rpc/helpers/wallet_helper.rb', line 102 def pending_blocks(count:, threshold: nil, source: nil) wallet_pending( count: count, threshold: threshold, source: source ).blocks end |
#receive_block(account:, block:) ⇒ Object
111 112 113 114 115 116 |
# File 'lib/nano_rpc/helpers/wallet_helper.rb', line 111 def receive_block(account:, block:) receive( account: account, block: block ).block end |
#remove_account(account:) ⇒ Object
118 119 120 |
# File 'lib/nano_rpc/helpers/wallet_helper.rb', line 118 def remove_account(account:) account_remove(account: account).removed == 1 end |
#representative ⇒ Object
122 123 124 |
# File 'lib/nano_rpc/helpers/wallet_helper.rb', line 122 def representative wallet_representative.representative end |
#representative_set(representative:) ⇒ Object Also known as: set_representative
135 136 137 |
# File 'lib/nano_rpc/helpers/wallet_helper.rb', line 135 def representative_set(representative:) wallet_representative_set(representative: representative).set == 1 end |
#republish(count:) ⇒ Object
126 127 128 |
# File 'lib/nano_rpc/helpers/wallet_helper.rb', line 126 def republish(count:) wallet_republish(count: count).blocks end |
#send_nano(from:, to:, amount:, work: nil) ⇒ Object Also known as: send_transaction
140 141 142 143 144 145 146 147 |
# File 'lib/nano_rpc/helpers/wallet_helper.rb', line 140 def send_nano(from:, to:, amount:, work: nil) send_currency( source: from, destination: to, amount: amount, work: work ).block end |
#work ⇒ Object
150 151 152 |
# File 'lib/nano_rpc/helpers/wallet_helper.rb', line 150 def work wallet_work_get.works end |