nanook 0.7.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -1
- data/CHANGELOG.md +26 -0
- data/Gemfile.lock +2 -2
- data/README.md +18 -7
- data/Rakefile +18 -0
- data/docs/0.7.0/apple-touch-icon.png +0 -0
- data/docs/0.7.0/classes/Nanook.html +572 -0
- data/docs/0.7.0/classes/Nanook/Account.html +909 -0
- data/docs/0.7.0/classes/Nanook/Block.html +717 -0
- data/docs/0.7.0/classes/Nanook/Error.html +84 -0
- data/docs/0.7.0/classes/Nanook/Key.html +253 -0
- data/docs/0.7.0/classes/Nanook/Node.html +657 -0
- data/docs/0.7.0/classes/Nanook/Rpc.html +247 -0
- data/docs/0.7.0/classes/Nanook/Util.html +197 -0
- data/docs/0.7.0/classes/Nanook/Wallet.html +986 -0
- data/docs/0.7.0/classes/Nanook/WalletAccount.html +446 -0
- data/docs/0.7.0/classes/Nanook/WorkPeer.html +294 -0
- data/docs/0.7.0/created.rid +14 -0
- data/docs/0.7.0/css/github.css +123 -0
- data/docs/0.7.0/css/main.css +374 -0
- data/docs/0.7.0/css/panel.css +360 -0
- data/docs/0.7.0/css/reset.css +48 -0
- data/docs/0.7.0/favicon.ico +0 -0
- data/docs/0.7.0/files/README_md.html +418 -0
- data/docs/0.7.0/files/lib/nanook/account_rb.html +89 -0
- data/docs/0.7.0/files/lib/nanook/block_rb.html +89 -0
- data/docs/0.7.0/files/lib/nanook/error_rb.html +89 -0
- data/docs/0.7.0/files/lib/nanook/key_rb.html +89 -0
- data/docs/0.7.0/files/lib/nanook/node_rb.html +89 -0
- data/docs/0.7.0/files/lib/nanook/rpc_rb.html +99 -0
- data/docs/0.7.0/files/lib/nanook/util_rb.html +89 -0
- data/docs/0.7.0/files/lib/nanook/version_rb.html +84 -0
- data/docs/0.7.0/files/lib/nanook/wallet_account_rb.html +89 -0
- data/docs/0.7.0/files/lib/nanook/wallet_rb.html +89 -0
- data/docs/0.7.0/files/lib/nanook/work_peer_rb.html +89 -0
- data/docs/0.7.0/files/lib/nanook_rb.html +94 -0
- data/docs/0.7.0/i/arrow-down.svg +8 -0
- data/docs/0.7.0/i/arrow-right.svg +8 -0
- data/docs/0.7.0/i/search.svg +12 -0
- data/docs/0.7.0/i/tree_bg.svg +8 -0
- data/docs/0.7.0/index.html +11 -0
- data/docs/0.7.0/js/highlight.pack.js +1 -0
- data/docs/0.7.0/js/jquery-1.3.2.min.js +19 -0
- data/docs/0.7.0/js/main.js +25 -0
- data/docs/0.7.0/js/navigation.js +142 -0
- data/docs/0.7.0/js/search_index.js +1 -0
- data/docs/0.7.0/js/searchdoc.js +465 -0
- data/docs/0.7.0/js/searcher.js +229 -0
- data/docs/0.7.0/panel/index.html +47 -0
- data/docs/0.7.0/panel/links.html +32 -0
- data/docs/0.7.0/panel/tree.js +1 -0
- data/docs/0.8.0/apple-touch-icon.png +0 -0
- data/docs/0.8.0/classes/Nanook.html +621 -0
- data/docs/0.8.0/classes/Nanook/Account.html +971 -0
- data/docs/0.8.0/classes/Nanook/Block.html +759 -0
- data/docs/0.8.0/classes/Nanook/Error.html +84 -0
- data/docs/0.8.0/classes/Nanook/Key.html +295 -0
- data/docs/0.8.0/classes/Nanook/Node.html +657 -0
- data/docs/0.8.0/classes/Nanook/Rpc.html +247 -0
- data/docs/0.8.0/classes/Nanook/Util.html +264 -0
- data/docs/0.8.0/classes/Nanook/Wallet.html +1056 -0
- data/docs/0.8.0/classes/Nanook/WalletAccount.html +582 -0
- data/docs/0.8.0/classes/Nanook/WorkPeer.html +294 -0
- data/docs/0.8.0/created.rid +14 -0
- data/docs/0.8.0/css/github.css +123 -0
- data/docs/0.8.0/css/main.css +374 -0
- data/docs/0.8.0/css/panel.css +360 -0
- data/docs/0.8.0/css/reset.css +48 -0
- data/docs/0.8.0/favicon.ico +0 -0
- data/docs/0.8.0/files/README_md.html +423 -0
- data/docs/0.8.0/files/lib/nanook/account_rb.html +89 -0
- data/docs/0.8.0/files/lib/nanook/block_rb.html +89 -0
- data/docs/0.8.0/files/lib/nanook/error_rb.html +89 -0
- data/docs/0.8.0/files/lib/nanook/key_rb.html +89 -0
- data/docs/0.8.0/files/lib/nanook/node_rb.html +89 -0
- data/docs/0.8.0/files/lib/nanook/rpc_rb.html +99 -0
- data/docs/0.8.0/files/lib/nanook/util_rb.html +97 -0
- data/docs/0.8.0/files/lib/nanook/version_rb.html +84 -0
- data/docs/0.8.0/files/lib/nanook/wallet_account_rb.html +89 -0
- data/docs/0.8.0/files/lib/nanook/wallet_rb.html +89 -0
- data/docs/0.8.0/files/lib/nanook/work_peer_rb.html +89 -0
- data/docs/0.8.0/files/lib/nanook_rb.html +94 -0
- data/docs/0.8.0/i/arrow-down.svg +8 -0
- data/docs/0.8.0/i/arrow-right.svg +8 -0
- data/docs/0.8.0/i/search.svg +12 -0
- data/docs/0.8.0/i/tree_bg.svg +8 -0
- data/docs/0.8.0/index.html +11 -0
- data/docs/0.8.0/js/highlight.pack.js +1 -0
- data/docs/0.8.0/js/jquery-1.3.2.min.js +19 -0
- data/docs/0.8.0/js/main.js +25 -0
- data/docs/0.8.0/js/navigation.js +142 -0
- data/docs/0.8.0/js/search_index.js +1 -0
- data/docs/0.8.0/js/searchdoc.js +465 -0
- data/docs/0.8.0/js/searcher.js +229 -0
- data/docs/0.8.0/panel/index.html +47 -0
- data/docs/0.8.0/panel/links.html +32 -0
- data/docs/0.8.0/panel/tree.js +1 -0
- data/docs/1.0.0/apple-touch-icon.png +0 -0
- data/docs/1.0.0/classes/Nanook.html +621 -0
- data/docs/1.0.0/classes/Nanook/Account.html +971 -0
- data/docs/1.0.0/classes/Nanook/Block.html +759 -0
- data/docs/1.0.0/classes/Nanook/Error.html +84 -0
- data/docs/1.0.0/classes/Nanook/Key.html +295 -0
- data/docs/1.0.0/classes/Nanook/Node.html +657 -0
- data/docs/1.0.0/classes/Nanook/Rpc.html +247 -0
- data/docs/1.0.0/classes/Nanook/Util.html +264 -0
- data/docs/1.0.0/classes/Nanook/Wallet.html +1056 -0
- data/docs/1.0.0/classes/Nanook/WalletAccount.html +582 -0
- data/docs/1.0.0/classes/Nanook/WorkPeer.html +294 -0
- data/docs/1.0.0/created.rid +14 -0
- data/docs/1.0.0/css/github.css +123 -0
- data/docs/1.0.0/css/main.css +374 -0
- data/docs/1.0.0/css/panel.css +360 -0
- data/docs/1.0.0/css/reset.css +48 -0
- data/docs/1.0.0/favicon.ico +0 -0
- data/docs/1.0.0/files/README_md.html +423 -0
- data/docs/1.0.0/files/lib/nanook/account_rb.html +89 -0
- data/docs/1.0.0/files/lib/nanook/block_rb.html +89 -0
- data/docs/1.0.0/files/lib/nanook/error_rb.html +89 -0
- data/docs/1.0.0/files/lib/nanook/key_rb.html +89 -0
- data/docs/1.0.0/files/lib/nanook/node_rb.html +89 -0
- data/docs/1.0.0/files/lib/nanook/rpc_rb.html +99 -0
- data/docs/1.0.0/files/lib/nanook/util_rb.html +97 -0
- data/docs/1.0.0/files/lib/nanook/version_rb.html +84 -0
- data/docs/1.0.0/files/lib/nanook/wallet_account_rb.html +89 -0
- data/docs/1.0.0/files/lib/nanook/wallet_rb.html +89 -0
- data/docs/1.0.0/files/lib/nanook/work_peer_rb.html +89 -0
- data/docs/1.0.0/files/lib/nanook_rb.html +94 -0
- data/docs/1.0.0/i/arrow-down.svg +8 -0
- data/docs/1.0.0/i/arrow-right.svg +8 -0
- data/docs/1.0.0/i/search.svg +12 -0
- data/docs/1.0.0/i/tree_bg.svg +8 -0
- data/docs/1.0.0/index.html +11 -0
- data/docs/1.0.0/js/highlight.pack.js +1 -0
- data/docs/1.0.0/js/jquery-1.3.2.min.js +19 -0
- data/docs/1.0.0/js/main.js +25 -0
- data/docs/1.0.0/js/navigation.js +142 -0
- data/docs/1.0.0/js/search_index.js +1 -0
- data/docs/1.0.0/js/searchdoc.js +465 -0
- data/docs/1.0.0/js/searcher.js +229 -0
- data/docs/1.0.0/panel/index.html +47 -0
- data/docs/1.0.0/panel/links.html +32 -0
- data/docs/1.0.0/panel/tree.js +1 -0
- data/docs/apple-touch-icon.png +0 -0
- data/docs/classes/Nanook.html +572 -0
- data/docs/classes/Nanook/Account.html +907 -0
- data/docs/classes/Nanook/Block.html +717 -0
- data/docs/classes/Nanook/Error.html +84 -0
- data/docs/classes/Nanook/Key.html +253 -0
- data/docs/classes/Nanook/Node.html +657 -0
- data/docs/classes/Nanook/Rpc.html +247 -0
- data/docs/classes/Nanook/Util.html +197 -0
- data/docs/classes/Nanook/Wallet.html +778 -0
- data/docs/classes/Nanook/WalletAccount.html +447 -0
- data/docs/classes/Nanook/WorkPeer.html +294 -0
- data/docs/created.rid +14 -0
- data/docs/css/github.css +123 -0
- data/docs/css/main.css +374 -0
- data/docs/css/panel.css +360 -0
- data/docs/css/reset.css +48 -0
- data/docs/favicon.ico +0 -0
- data/docs/files/README_md.html +408 -0
- data/docs/files/lib/nanook/account_rb.html +89 -0
- data/docs/files/lib/nanook/block_rb.html +89 -0
- data/docs/files/lib/nanook/error_rb.html +89 -0
- data/docs/files/lib/nanook/key_rb.html +89 -0
- data/docs/files/lib/nanook/node_rb.html +89 -0
- data/docs/files/lib/nanook/rpc_rb.html +99 -0
- data/docs/files/lib/nanook/util_rb.html +89 -0
- data/docs/files/lib/nanook/version_rb.html +84 -0
- data/docs/files/lib/nanook/wallet_account_rb.html +89 -0
- data/docs/files/lib/nanook/wallet_rb.html +89 -0
- data/docs/files/lib/nanook/work_peer_rb.html +89 -0
- data/docs/files/lib/nanook_rb.html +94 -0
- data/docs/i/arrow-down.svg +8 -0
- data/docs/i/arrow-right.svg +8 -0
- data/docs/i/search.svg +12 -0
- data/docs/i/tree_bg.svg +8 -0
- data/docs/index.html +11 -0
- data/docs/js/highlight.pack.js +1 -0
- data/docs/js/jquery-1.3.2.min.js +19 -0
- data/docs/js/main.js +25 -0
- data/docs/js/navigation.js +142 -0
- data/docs/js/search_index.js +1 -0
- data/docs/js/searchdoc.js +465 -0
- data/docs/js/searcher.js +229 -0
- data/docs/panel/index.html +47 -0
- data/docs/panel/links.html +32 -0
- data/docs/panel/tree.js +1 -0
- data/lib/nanook.rb +40 -4
- data/lib/nanook/account.rb +250 -8
- data/lib/nanook/block.rb +25 -2
- data/lib/nanook/key.rb +10 -2
- data/lib/nanook/node.rb +4 -0
- data/lib/nanook/rpc.rb +5 -1
- data/lib/nanook/util.rb +9 -1
- data/lib/nanook/version.rb +1 -1
- data/lib/nanook/wallet.rb +275 -14
- data/lib/nanook/wallet_account.rb +63 -11
- data/lib/nanook/work_peer.rb +4 -0
- metadata +188 -3
@@ -0,0 +1,247 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html lang="en">
|
3
|
+
<head>
|
4
|
+
<title>Nanook::Rpc</title>
|
5
|
+
<meta charset="UTF-8" />
|
6
|
+
<link rel="stylesheet" href="../../css/reset.css" type="text/css" media="screen" />
|
7
|
+
<link rel="stylesheet" href="../../css/main.css" type="text/css" media="screen" />
|
8
|
+
<link rel="stylesheet" href="../../css/github.css" type="text/css" media="screen" />
|
9
|
+
<script src="../../js/jquery-1.3.2.min.js" type="text/javascript" charset="utf-8"></script>
|
10
|
+
<script src="../../js/main.js" type="text/javascript" charset="utf-8"></script>
|
11
|
+
<script src="../../js/highlight.pack.js" type="text/javascript" charset="utf-8"></script>
|
12
|
+
|
13
|
+
|
14
|
+
<meta property="og:title" value="Nanook::Rpc">
|
15
|
+
|
16
|
+
|
17
|
+
|
18
|
+
<meta name="keywords" content="Nanook::Rpc class">
|
19
|
+
|
20
|
+
<meta name="keywords" content="new, call">
|
21
|
+
|
22
|
+
</head>
|
23
|
+
|
24
|
+
<body>
|
25
|
+
<div class="banner">
|
26
|
+
|
27
|
+
<h1>
|
28
|
+
<span class="type">Class</span>
|
29
|
+
Nanook::Rpc
|
30
|
+
|
31
|
+
<span class="parent"><
|
32
|
+
|
33
|
+
Object
|
34
|
+
|
35
|
+
</span>
|
36
|
+
|
37
|
+
</h1>
|
38
|
+
<ul class="files">
|
39
|
+
|
40
|
+
<li><a href="../../files/lib/nanook/rpc_rb.html">lib/nanook/rpc.rb</a></li>
|
41
|
+
|
42
|
+
</ul>
|
43
|
+
</div>
|
44
|
+
<div id="bodyContent">
|
45
|
+
<div id="content">
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
|
60
|
+
<!-- Method ref -->
|
61
|
+
<div class="sectiontitle">Methods</div>
|
62
|
+
<dl class="methods">
|
63
|
+
|
64
|
+
<dt>C</dt>
|
65
|
+
<dd>
|
66
|
+
<ul>
|
67
|
+
|
68
|
+
|
69
|
+
<li>
|
70
|
+
<a href="#method-i-call">call</a>
|
71
|
+
</li>
|
72
|
+
|
73
|
+
</ul>
|
74
|
+
</dd>
|
75
|
+
|
76
|
+
<dt>N</dt>
|
77
|
+
<dd>
|
78
|
+
<ul>
|
79
|
+
|
80
|
+
|
81
|
+
<li>
|
82
|
+
<a href="#method-c-new">new</a>
|
83
|
+
</li>
|
84
|
+
|
85
|
+
</ul>
|
86
|
+
</dd>
|
87
|
+
|
88
|
+
</dl>
|
89
|
+
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
|
102
|
+
<!-- Section constants -->
|
103
|
+
<div class="sectiontitle">Constants</div>
|
104
|
+
<table border='0' cellpadding='5'>
|
105
|
+
|
106
|
+
<tr valign='top'>
|
107
|
+
<td class="attr-name">DEFAULT_TIMEOUT</td>
|
108
|
+
<td>=</td>
|
109
|
+
<td class="attr-value">500</td>
|
110
|
+
</tr>
|
111
|
+
|
112
|
+
<tr valign='top'>
|
113
|
+
<td> </td>
|
114
|
+
<td colspan="2" class="attr-desc"></td>
|
115
|
+
</tr>
|
116
|
+
|
117
|
+
|
118
|
+
<tr valign='top'>
|
119
|
+
<td class="attr-name">DEFAULT_URI</td>
|
120
|
+
<td>=</td>
|
121
|
+
<td class="attr-value">"http://localhost:7076"</td>
|
122
|
+
</tr>
|
123
|
+
|
124
|
+
<tr valign='top'>
|
125
|
+
<td> </td>
|
126
|
+
<td colspan="2" class="attr-desc"></td>
|
127
|
+
</tr>
|
128
|
+
|
129
|
+
|
130
|
+
</table>
|
131
|
+
|
132
|
+
|
133
|
+
|
134
|
+
|
135
|
+
|
136
|
+
|
137
|
+
<!-- Methods -->
|
138
|
+
|
139
|
+
<div class="sectiontitle">Class Public methods</div>
|
140
|
+
|
141
|
+
<div class="method">
|
142
|
+
<div class="title method-title" id="method-c-new">
|
143
|
+
|
144
|
+
<b>new</b>(uri=DEFAULT_URI, timeout:DEFAULT_TIMEOUT)
|
145
|
+
|
146
|
+
<a href="../../classes/Nanook/Rpc.html#method-c-new" name="method-c-new" class="permalink">Link</a>
|
147
|
+
</div>
|
148
|
+
|
149
|
+
|
150
|
+
<div class="description">
|
151
|
+
|
152
|
+
</div>
|
153
|
+
|
154
|
+
|
155
|
+
|
156
|
+
|
157
|
+
|
158
|
+
|
159
|
+
|
160
|
+
|
161
|
+
<div class="sourcecode">
|
162
|
+
|
163
|
+
<p class="source-link">
|
164
|
+
Source:
|
165
|
+
<a href="javascript:toggleSource('method-c-new_source')" id="l_method-c-new_source">show</a>
|
166
|
+
|
167
|
+
</p>
|
168
|
+
<div id="method-c-new_source" class="dyn-source">
|
169
|
+
<pre><span class="ruby-comment"># File lib/nanook/rpc.rb, line 10</span>
|
170
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">initialize</span>(<span class="ruby-identifier">uri</span>=<span class="ruby-constant">DEFAULT_URI</span>, <span class="ruby-value">timeout:</span><span class="ruby-constant">DEFAULT_TIMEOUT</span>)
|
171
|
+
<span class="ruby-identifier">rpc_server</span> = <span class="ruby-constant">URI</span>(<span class="ruby-identifier">uri</span>)
|
172
|
+
|
173
|
+
<span class="ruby-keyword">unless</span> [<span class="ruby-string">'http'</span>, <span class="ruby-string">'https'</span>].<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">rpc_server</span>.<span class="ruby-identifier">scheme</span>)
|
174
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>.<span class="ruby-identifier">new</span>(<span class="ruby-node">"URI must have http or https in it. Was given: #{uri}"</span>)
|
175
|
+
<span class="ruby-keyword">end</span>
|
176
|
+
|
177
|
+
<span class="ruby-ivar">@http</span> = <span class="ruby-constant">Net</span><span class="ruby-operator">::</span><span class="ruby-constant">HTTP</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">rpc_server</span>.<span class="ruby-identifier">host</span>, <span class="ruby-identifier">rpc_server</span>.<span class="ruby-identifier">port</span>)
|
178
|
+
<span class="ruby-ivar">@http</span>.<span class="ruby-identifier">read_timeout</span> = <span class="ruby-identifier">timeout</span>
|
179
|
+
<span class="ruby-ivar">@request</span> = <span class="ruby-constant">Net</span><span class="ruby-operator">::</span><span class="ruby-constant">HTTP</span><span class="ruby-operator">::</span><span class="ruby-constant">Post</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">rpc_server</span>.<span class="ruby-identifier">request_uri</span>, {<span class="ruby-string">"user-agent"</span> <span class="ruby-operator">=></span> <span class="ruby-string">"Ruby nanook gem"</span>})
|
180
|
+
<span class="ruby-ivar">@request</span>.<span class="ruby-identifier">content_type</span> = <span class="ruby-string">"application/json"</span>
|
181
|
+
<span class="ruby-keyword">end</span></pre>
|
182
|
+
</div>
|
183
|
+
</div>
|
184
|
+
|
185
|
+
</div>
|
186
|
+
|
187
|
+
|
188
|
+
|
189
|
+
<div class="sectiontitle">Instance Public methods</div>
|
190
|
+
|
191
|
+
<div class="method">
|
192
|
+
<div class="title method-title" id="method-i-call">
|
193
|
+
|
194
|
+
<b>call</b>(action, params={})
|
195
|
+
|
196
|
+
<a href="../../classes/Nanook/Rpc.html#method-i-call" name="method-i-call" class="permalink">Link</a>
|
197
|
+
</div>
|
198
|
+
|
199
|
+
|
200
|
+
<div class="description">
|
201
|
+
|
202
|
+
</div>
|
203
|
+
|
204
|
+
|
205
|
+
|
206
|
+
|
207
|
+
|
208
|
+
|
209
|
+
|
210
|
+
|
211
|
+
<div class="sourcecode">
|
212
|
+
|
213
|
+
<p class="source-link">
|
214
|
+
Source:
|
215
|
+
<a href="javascript:toggleSource('method-i-call_source')" id="l_method-i-call_source">show</a>
|
216
|
+
|
217
|
+
</p>
|
218
|
+
<div id="method-i-call_source" class="dyn-source">
|
219
|
+
<pre><span class="ruby-comment"># File lib/nanook/rpc.rb, line 23</span>
|
220
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">call</span>(<span class="ruby-identifier">action</span>, <span class="ruby-identifier">params</span>={})
|
221
|
+
<span class="ruby-comment"># Stringify param values</span>
|
222
|
+
<span class="ruby-identifier">params</span> = <span class="ruby-constant">Hash</span>[<span class="ruby-identifier">params</span>.<span class="ruby-identifier">map</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">k</span>, <span class="ruby-identifier">v</span><span class="ruby-operator">|</span> [<span class="ruby-identifier">k</span>, <span class="ruby-identifier">v</span>.<span class="ruby-identifier">to_s</span>] }]
|
223
|
+
|
224
|
+
<span class="ruby-ivar">@request</span>.<span class="ruby-identifier">body</span> = { <span class="ruby-value">action:</span> <span class="ruby-identifier">action</span> }.<span class="ruby-identifier">merge</span>(<span class="ruby-identifier">params</span>).<span class="ruby-identifier">to_json</span>
|
225
|
+
|
226
|
+
<span class="ruby-identifier">response</span> = <span class="ruby-ivar">@http</span>.<span class="ruby-identifier">request</span>(<span class="ruby-ivar">@request</span>)
|
227
|
+
|
228
|
+
<span class="ruby-keyword">if</span> <span class="ruby-identifier">response</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Net</span><span class="ruby-operator">::</span><span class="ruby-constant">HTTPSuccess</span>)
|
229
|
+
<span class="ruby-identifier">hash</span> = <span class="ruby-constant">JSON</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-identifier">response</span>.<span class="ruby-identifier">body</span>)
|
230
|
+
<span class="ruby-identifier">process_hash</span>(<span class="ruby-identifier">hash</span>)
|
231
|
+
<span class="ruby-keyword">else</span>
|
232
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-constant">Nanook</span><span class="ruby-operator">::</span><span class="ruby-constant">Error</span>.<span class="ruby-identifier">new</span>(<span class="ruby-node">"Encountered net/http error #{response.code}: #{response.class.name}"</span>)
|
233
|
+
<span class="ruby-keyword">end</span>
|
234
|
+
<span class="ruby-keyword">end</span></pre>
|
235
|
+
</div>
|
236
|
+
</div>
|
237
|
+
|
238
|
+
</div>
|
239
|
+
|
240
|
+
|
241
|
+
|
242
|
+
|
243
|
+
</div>
|
244
|
+
|
245
|
+
</div>
|
246
|
+
</body>
|
247
|
+
</html>
|
@@ -0,0 +1,197 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html lang="en">
|
3
|
+
<head>
|
4
|
+
<title>Nanook::Util</title>
|
5
|
+
<meta charset="UTF-8" />
|
6
|
+
<link rel="stylesheet" href="../../css/reset.css" type="text/css" media="screen" />
|
7
|
+
<link rel="stylesheet" href="../../css/main.css" type="text/css" media="screen" />
|
8
|
+
<link rel="stylesheet" href="../../css/github.css" type="text/css" media="screen" />
|
9
|
+
<script src="../../js/jquery-1.3.2.min.js" type="text/javascript" charset="utf-8"></script>
|
10
|
+
<script src="../../js/main.js" type="text/javascript" charset="utf-8"></script>
|
11
|
+
<script src="../../js/highlight.pack.js" type="text/javascript" charset="utf-8"></script>
|
12
|
+
|
13
|
+
|
14
|
+
<meta property="og:title" value="Nanook::Util">
|
15
|
+
|
16
|
+
|
17
|
+
|
18
|
+
<meta name="keywords" content="Nanook::Util class">
|
19
|
+
|
20
|
+
<meta name="keywords" content="NANO_to_raw, coerce_empty_string_to_type">
|
21
|
+
|
22
|
+
</head>
|
23
|
+
|
24
|
+
<body>
|
25
|
+
<div class="banner">
|
26
|
+
|
27
|
+
<h1>
|
28
|
+
<span class="type">Class</span>
|
29
|
+
Nanook::Util
|
30
|
+
|
31
|
+
<span class="parent"><
|
32
|
+
|
33
|
+
Object
|
34
|
+
|
35
|
+
</span>
|
36
|
+
|
37
|
+
</h1>
|
38
|
+
<ul class="files">
|
39
|
+
|
40
|
+
<li><a href="../../files/lib/nanook/util_rb.html">lib/nanook/util.rb</a></li>
|
41
|
+
|
42
|
+
</ul>
|
43
|
+
</div>
|
44
|
+
<div id="bodyContent">
|
45
|
+
<div id="content">
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
|
60
|
+
<!-- Method ref -->
|
61
|
+
<div class="sectiontitle">Methods</div>
|
62
|
+
<dl class="methods">
|
63
|
+
|
64
|
+
<dt>N</dt>
|
65
|
+
<dd>
|
66
|
+
<ul>
|
67
|
+
|
68
|
+
|
69
|
+
<li>
|
70
|
+
<a href="#method-c-NANO_to_raw">NANO_to_raw</a>
|
71
|
+
</li>
|
72
|
+
|
73
|
+
</ul>
|
74
|
+
</dd>
|
75
|
+
|
76
|
+
<dt>C</dt>
|
77
|
+
<dd>
|
78
|
+
<ul>
|
79
|
+
|
80
|
+
|
81
|
+
<li>
|
82
|
+
<a href="#method-c-coerce_empty_string_to_type">coerce_empty_string_to_type</a>
|
83
|
+
</li>
|
84
|
+
|
85
|
+
</ul>
|
86
|
+
</dd>
|
87
|
+
|
88
|
+
</dl>
|
89
|
+
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
<!-- Methods -->
|
108
|
+
|
109
|
+
<div class="sectiontitle">Class Public methods</div>
|
110
|
+
|
111
|
+
<div class="method">
|
112
|
+
<div class="title method-title" id="method-c-NANO_to_raw">
|
113
|
+
|
114
|
+
<b>NANO_to_raw</b>(nano)
|
115
|
+
|
116
|
+
<a href="../../classes/Nanook/Util.html#method-c-NANO_to_raw" name="method-c-NANO_to_raw" class="permalink">Link</a>
|
117
|
+
</div>
|
118
|
+
|
119
|
+
|
120
|
+
<div class="description">
|
121
|
+
|
122
|
+
</div>
|
123
|
+
|
124
|
+
|
125
|
+
|
126
|
+
|
127
|
+
|
128
|
+
|
129
|
+
|
130
|
+
|
131
|
+
<div class="sourcecode">
|
132
|
+
|
133
|
+
<p class="source-link">
|
134
|
+
Source:
|
135
|
+
<a href="javascript:toggleSource('method-c-NANO_to_raw_source')" id="l_method-c-NANO_to_raw_source">show</a>
|
136
|
+
|
137
|
+
</p>
|
138
|
+
<div id="method-c-NANO_to_raw_source" class="dyn-source">
|
139
|
+
<pre><span class="ruby-comment"># File lib/nanook/util.rb, line 4</span>
|
140
|
+
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-constant">NANO_to_raw</span>(<span class="ruby-identifier ruby-title">nano</span>)
|
141
|
+
<span class="ruby-identifier">nano</span> <span class="ruby-operator">*</span> (<span class="ruby-value">10</span><span class="ruby-operator">**</span><span class="ruby-value">30</span>)
|
142
|
+
<span class="ruby-keyword">end</span></pre>
|
143
|
+
</div>
|
144
|
+
</div>
|
145
|
+
|
146
|
+
</div>
|
147
|
+
|
148
|
+
<div class="method">
|
149
|
+
<div class="title method-title" id="method-c-coerce_empty_string_to_type">
|
150
|
+
|
151
|
+
<b>coerce_empty_string_to_type</b>(response, type)
|
152
|
+
|
153
|
+
<a href="../../classes/Nanook/Util.html#method-c-coerce_empty_string_to_type" name="method-c-coerce_empty_string_to_type" class="permalink">Link</a>
|
154
|
+
</div>
|
155
|
+
|
156
|
+
|
157
|
+
<div class="description">
|
158
|
+
|
159
|
+
</div>
|
160
|
+
|
161
|
+
|
162
|
+
|
163
|
+
|
164
|
+
|
165
|
+
|
166
|
+
|
167
|
+
|
168
|
+
<div class="sourcecode">
|
169
|
+
|
170
|
+
<p class="source-link">
|
171
|
+
Source:
|
172
|
+
<a href="javascript:toggleSource('method-c-coerce_empty_string_to_type_source')" id="l_method-c-coerce_empty_string_to_type_source">show</a>
|
173
|
+
|
174
|
+
</p>
|
175
|
+
<div id="method-c-coerce_empty_string_to_type_source" class="dyn-source">
|
176
|
+
<pre><span class="ruby-comment"># File lib/nanook/util.rb, line 8</span>
|
177
|
+
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">coerce_empty_string_to_type</span>(<span class="ruby-identifier">response</span>, <span class="ruby-identifier">type</span>)
|
178
|
+
<span class="ruby-keyword">if</span> <span class="ruby-identifier">response</span> <span class="ruby-operator">==</span> <span class="ruby-string">""</span>
|
179
|
+
<span class="ruby-keyword">return</span> <span class="ruby-identifier">type</span>.<span class="ruby-identifier">new</span>
|
180
|
+
<span class="ruby-keyword">end</span>
|
181
|
+
|
182
|
+
<span class="ruby-identifier">response</span>
|
183
|
+
<span class="ruby-keyword">end</span></pre>
|
184
|
+
</div>
|
185
|
+
</div>
|
186
|
+
|
187
|
+
</div>
|
188
|
+
|
189
|
+
|
190
|
+
|
191
|
+
|
192
|
+
|
193
|
+
</div>
|
194
|
+
|
195
|
+
</div>
|
196
|
+
</body>
|
197
|
+
</html>
|
@@ -0,0 +1,986 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html lang="en">
|
3
|
+
<head>
|
4
|
+
<title>Nanook::Wallet</title>
|
5
|
+
<meta charset="UTF-8" />
|
6
|
+
<link rel="stylesheet" href="../../css/reset.css" type="text/css" media="screen" />
|
7
|
+
<link rel="stylesheet" href="../../css/main.css" type="text/css" media="screen" />
|
8
|
+
<link rel="stylesheet" href="../../css/github.css" type="text/css" media="screen" />
|
9
|
+
<script src="../../js/jquery-1.3.2.min.js" type="text/javascript" charset="utf-8"></script>
|
10
|
+
<script src="../../js/main.js" type="text/javascript" charset="utf-8"></script>
|
11
|
+
<script src="../../js/highlight.pack.js" type="text/javascript" charset="utf-8"></script>
|
12
|
+
|
13
|
+
|
14
|
+
<meta property="og:title" value="Nanook::Wallet">
|
15
|
+
|
16
|
+
|
17
|
+
|
18
|
+
<meta name="description" content="The Nanook::Wallet class lets you manage your nano wallets, as well as some account-specific things like making and receiving payments.">
|
19
|
+
<meta property="og:description" content="The Nanook::Wallet class lets you manage your nano wallets, as well as some account-specific things like making and receiving payments.">
|
20
|
+
|
21
|
+
|
22
|
+
<meta name="keywords" content="Nanook::Wallet class">
|
23
|
+
|
24
|
+
<meta name="keywords" content="new, account, accounts, balance, create, destroy, export, contains?, pay, receive, locked?, unlock, change_password">
|
25
|
+
|
26
|
+
</head>
|
27
|
+
|
28
|
+
<body>
|
29
|
+
<div class="banner">
|
30
|
+
|
31
|
+
<h1>
|
32
|
+
<span class="type">Class</span>
|
33
|
+
Nanook::Wallet
|
34
|
+
|
35
|
+
<span class="parent"><
|
36
|
+
|
37
|
+
Object
|
38
|
+
|
39
|
+
</span>
|
40
|
+
|
41
|
+
</h1>
|
42
|
+
<ul class="files">
|
43
|
+
|
44
|
+
<li><a href="../../files/lib/nanook/wallet_rb.html">lib/nanook/wallet.rb</a></li>
|
45
|
+
|
46
|
+
</ul>
|
47
|
+
</div>
|
48
|
+
<div id="bodyContent">
|
49
|
+
<div id="content">
|
50
|
+
|
51
|
+
<div class="description">
|
52
|
+
|
53
|
+
<p>The <code>Nanook::Wallet</code> class lets you manage your nano wallets, as
|
54
|
+
well as some account-specific things like making and receiving payments.</p>
|
55
|
+
|
56
|
+
<p>Your wallets each have a seed, which is a 32-byte uppercase hex string that
|
57
|
+
looks like this:</p>
|
58
|
+
|
59
|
+
<pre><code>000D1BAEC8EC208142C99059B393051BAC8380F9B5A2E6B2489A277D81789F3F
|
60
|
+
</code></pre>
|
61
|
+
|
62
|
+
<p>You can think of this string as your API key to the nano network. The
|
63
|
+
person who knows it can do all read and write actions against the wallet
|
64
|
+
and all accounts inside the wallet from anywhere on the nano network, not
|
65
|
+
just on the node you created the wallet on. <strong>Make sure this key is
|
66
|
+
always secret and safe</strong>. Do not commit your seed into source
|
67
|
+
control.</p>
|
68
|
+
|
69
|
+
<h3 id="class-Nanook::Wallet-label-Initializing">Initializing</h3>
|
70
|
+
|
71
|
+
<p>Initialize this class through the convenient <a
|
72
|
+
href="../Nanook.html#method-i-wallet">Nanook#wallet</a> method:</p>
|
73
|
+
|
74
|
+
<pre><code>nanook = Nanook.new
|
75
|
+
wallet = nanook.wallet(wallet_seed)
|
76
|
+
</code></pre>
|
77
|
+
|
78
|
+
<p>Or compose the longhand way like this:</p>
|
79
|
+
|
80
|
+
<pre><code>rpc_conn = Nanook::Rpc.new
|
81
|
+
wallet = Nanook::Wallet.new(rpc_conn, wallet_seed)
|
82
|
+
</code></pre>
|
83
|
+
|
84
|
+
</div>
|
85
|
+
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
<!-- Method ref -->
|
100
|
+
<div class="sectiontitle">Methods</div>
|
101
|
+
<dl class="methods">
|
102
|
+
|
103
|
+
<dt>A</dt>
|
104
|
+
<dd>
|
105
|
+
<ul>
|
106
|
+
|
107
|
+
|
108
|
+
<li>
|
109
|
+
<a href="#method-i-account">account</a>,
|
110
|
+
</li>
|
111
|
+
|
112
|
+
|
113
|
+
<li>
|
114
|
+
<a href="#method-i-accounts">accounts</a>
|
115
|
+
</li>
|
116
|
+
|
117
|
+
</ul>
|
118
|
+
</dd>
|
119
|
+
|
120
|
+
<dt>B</dt>
|
121
|
+
<dd>
|
122
|
+
<ul>
|
123
|
+
|
124
|
+
|
125
|
+
<li>
|
126
|
+
<a href="#method-i-balance">balance</a>
|
127
|
+
</li>
|
128
|
+
|
129
|
+
</ul>
|
130
|
+
</dd>
|
131
|
+
|
132
|
+
<dt>C</dt>
|
133
|
+
<dd>
|
134
|
+
<ul>
|
135
|
+
|
136
|
+
|
137
|
+
<li>
|
138
|
+
<a href="#method-i-change_password">change_password</a>,
|
139
|
+
</li>
|
140
|
+
|
141
|
+
|
142
|
+
<li>
|
143
|
+
<a href="#method-i-contains-3F">contains?</a>,
|
144
|
+
</li>
|
145
|
+
|
146
|
+
|
147
|
+
<li>
|
148
|
+
<a href="#method-i-create">create</a>
|
149
|
+
</li>
|
150
|
+
|
151
|
+
</ul>
|
152
|
+
</dd>
|
153
|
+
|
154
|
+
<dt>D</dt>
|
155
|
+
<dd>
|
156
|
+
<ul>
|
157
|
+
|
158
|
+
|
159
|
+
<li>
|
160
|
+
<a href="#method-i-destroy">destroy</a>
|
161
|
+
</li>
|
162
|
+
|
163
|
+
</ul>
|
164
|
+
</dd>
|
165
|
+
|
166
|
+
<dt>E</dt>
|
167
|
+
<dd>
|
168
|
+
<ul>
|
169
|
+
|
170
|
+
|
171
|
+
<li>
|
172
|
+
<a href="#method-i-export">export</a>
|
173
|
+
</li>
|
174
|
+
|
175
|
+
</ul>
|
176
|
+
</dd>
|
177
|
+
|
178
|
+
<dt>L</dt>
|
179
|
+
<dd>
|
180
|
+
<ul>
|
181
|
+
|
182
|
+
|
183
|
+
<li>
|
184
|
+
<a href="#method-i-locked-3F">locked?</a>
|
185
|
+
</li>
|
186
|
+
|
187
|
+
</ul>
|
188
|
+
</dd>
|
189
|
+
|
190
|
+
<dt>N</dt>
|
191
|
+
<dd>
|
192
|
+
<ul>
|
193
|
+
|
194
|
+
|
195
|
+
<li>
|
196
|
+
<a href="#method-c-new">new</a>
|
197
|
+
</li>
|
198
|
+
|
199
|
+
</ul>
|
200
|
+
</dd>
|
201
|
+
|
202
|
+
<dt>P</dt>
|
203
|
+
<dd>
|
204
|
+
<ul>
|
205
|
+
|
206
|
+
|
207
|
+
<li>
|
208
|
+
<a href="#method-i-pay">pay</a>
|
209
|
+
</li>
|
210
|
+
|
211
|
+
</ul>
|
212
|
+
</dd>
|
213
|
+
|
214
|
+
<dt>R</dt>
|
215
|
+
<dd>
|
216
|
+
<ul>
|
217
|
+
|
218
|
+
|
219
|
+
<li>
|
220
|
+
<a href="#method-i-receive">receive</a>
|
221
|
+
</li>
|
222
|
+
|
223
|
+
</ul>
|
224
|
+
</dd>
|
225
|
+
|
226
|
+
<dt>U</dt>
|
227
|
+
<dd>
|
228
|
+
<ul>
|
229
|
+
|
230
|
+
|
231
|
+
<li>
|
232
|
+
<a href="#method-i-unlock">unlock</a>
|
233
|
+
</li>
|
234
|
+
|
235
|
+
</ul>
|
236
|
+
</dd>
|
237
|
+
|
238
|
+
</dl>
|
239
|
+
|
240
|
+
|
241
|
+
|
242
|
+
|
243
|
+
|
244
|
+
|
245
|
+
|
246
|
+
|
247
|
+
|
248
|
+
|
249
|
+
|
250
|
+
|
251
|
+
|
252
|
+
|
253
|
+
|
254
|
+
|
255
|
+
|
256
|
+
|
257
|
+
<!-- Methods -->
|
258
|
+
|
259
|
+
<div class="sectiontitle">Class Public methods</div>
|
260
|
+
|
261
|
+
<div class="method">
|
262
|
+
<div class="title method-title" id="method-c-new">
|
263
|
+
|
264
|
+
<b>new</b>(rpc, wallet)
|
265
|
+
|
266
|
+
<a href="../../classes/Nanook/Wallet.html#method-c-new" name="method-c-new" class="permalink">Link</a>
|
267
|
+
</div>
|
268
|
+
|
269
|
+
|
270
|
+
<div class="description">
|
271
|
+
|
272
|
+
</div>
|
273
|
+
|
274
|
+
|
275
|
+
|
276
|
+
|
277
|
+
|
278
|
+
|
279
|
+
|
280
|
+
|
281
|
+
<div class="sourcecode">
|
282
|
+
|
283
|
+
<p class="source-link">
|
284
|
+
Source:
|
285
|
+
<a href="javascript:toggleSource('method-c-new_source')" id="l_method-c-new_source">show</a>
|
286
|
+
|
287
|
+
</p>
|
288
|
+
<div id="method-c-new_source" class="dyn-source">
|
289
|
+
<pre><span class="ruby-comment"># File lib/nanook/wallet.rb, line 31</span>
|
290
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">initialize</span>(<span class="ruby-identifier">rpc</span>, <span class="ruby-identifier">wallet</span>)
|
291
|
+
<span class="ruby-ivar">@rpc</span> = <span class="ruby-identifier">rpc</span>
|
292
|
+
<span class="ruby-ivar">@wallet</span> = <span class="ruby-identifier">wallet</span>
|
293
|
+
<span class="ruby-keyword">end</span></pre>
|
294
|
+
</div>
|
295
|
+
</div>
|
296
|
+
|
297
|
+
</div>
|
298
|
+
|
299
|
+
|
300
|
+
|
301
|
+
<div class="sectiontitle">Instance Public methods</div>
|
302
|
+
|
303
|
+
<div class="method">
|
304
|
+
<div class="title method-title" id="method-i-account">
|
305
|
+
|
306
|
+
<b>account</b>(account=nil)
|
307
|
+
|
308
|
+
<a href="../../classes/Nanook/Wallet.html#method-i-account" name="method-i-account" class="permalink">Link</a>
|
309
|
+
</div>
|
310
|
+
|
311
|
+
|
312
|
+
<div class="description">
|
313
|
+
<p>A convenient method that returns an account in your wallet, allowing you to
|
314
|
+
perform all the actions in <a
|
315
|
+
href="WalletAccount.html">Nanook::WalletAccount</a> on it.</p>
|
316
|
+
|
317
|
+
<pre><code>wallet.account("xrb_...") #=> Nanook::WalletAccount instance
|
318
|
+
</code></pre>
|
319
|
+
|
320
|
+
<p>See <a href="WalletAccount.html">Nanook::WalletAccount</a>.</p>
|
321
|
+
|
322
|
+
<h4 id="method-i-account-label-Arguments">Arguments</h4>
|
323
|
+
<table class="rdoc-list label-list"><tbody><tr><td class='label'><code>account</code></td><td>
|
324
|
+
<p>Optional String of an account (starting with
|
325
|
+
<code>"xrb..."</code>) to start working with. Must be an account
|
326
|
+
within the wallet. When no account is given, the instance returned only
|
327
|
+
allows you to call <code>create</code> on it, to create a new account.
|
328
|
+
Otherwise, you must pass an account string for all other methods.</p>
|
329
|
+
</td></tr></tbody></table>
|
330
|
+
|
331
|
+
<h4 id="method-i-account-label-Examples">Examples</h4>
|
332
|
+
|
333
|
+
<pre><code>wallet.account.create # Creates an account in the wallet and returns a Nanook::WalletAccount
|
334
|
+
wallet.account(account_id) # Returns a Nanook::WalletAccount for the account
|
335
|
+
</code></pre>
|
336
|
+
</div>
|
337
|
+
|
338
|
+
|
339
|
+
|
340
|
+
|
341
|
+
|
342
|
+
|
343
|
+
|
344
|
+
|
345
|
+
<div class="sourcecode">
|
346
|
+
|
347
|
+
<p class="source-link">
|
348
|
+
Source:
|
349
|
+
<a href="javascript:toggleSource('method-i-account_source')" id="l_method-i-account_source">show</a>
|
350
|
+
|
351
|
+
</p>
|
352
|
+
<div id="method-i-account_source" class="dyn-source">
|
353
|
+
<pre><span class="ruby-comment"># File lib/nanook/wallet.rb, line 55</span>
|
354
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">account</span>(<span class="ruby-identifier">account</span>=<span class="ruby-keyword">nil</span>)
|
355
|
+
<span class="ruby-constant">Nanook</span><span class="ruby-operator">::</span><span class="ruby-constant">WalletAccount</span>.<span class="ruby-identifier">new</span>(<span class="ruby-ivar">@rpc</span>, <span class="ruby-ivar">@wallet</span>, <span class="ruby-identifier">account</span>)
|
356
|
+
<span class="ruby-keyword">end</span></pre>
|
357
|
+
</div>
|
358
|
+
</div>
|
359
|
+
|
360
|
+
</div>
|
361
|
+
|
362
|
+
<div class="method">
|
363
|
+
<div class="title method-title" id="method-i-accounts">
|
364
|
+
|
365
|
+
<b>accounts</b>()
|
366
|
+
|
367
|
+
<a href="../../classes/Nanook/Wallet.html#method-i-accounts" name="method-i-accounts" class="permalink">Link</a>
|
368
|
+
</div>
|
369
|
+
|
370
|
+
|
371
|
+
<div class="description">
|
372
|
+
<p>Returns an Array with Strings of all account ids in the wallet.</p>
|
373
|
+
|
374
|
+
<h4 id="method-i-accounts-label-Example+response">Example response</h4>
|
375
|
+
|
376
|
+
<pre><code>[
|
377
|
+
"xrb_3e3j5tkog48pnny9dmfzj1r16pg8t1e76dz5tmac6iq689wyjfpi00000000",
|
378
|
+
"xrb_1e5aqegc1jb7qe964u4adzmcezyo6o146zb8hm6dft8tkp79za3sxwjym5rx"
|
379
|
+
]
|
380
|
+
</code></pre>
|
381
|
+
</div>
|
382
|
+
|
383
|
+
|
384
|
+
|
385
|
+
|
386
|
+
|
387
|
+
|
388
|
+
|
389
|
+
|
390
|
+
<div class="sourcecode">
|
391
|
+
|
392
|
+
<p class="source-link">
|
393
|
+
Source:
|
394
|
+
<a href="javascript:toggleSource('method-i-accounts_source')" id="l_method-i-accounts_source">show</a>
|
395
|
+
|
396
|
+
</p>
|
397
|
+
<div id="method-i-accounts_source" class="dyn-source">
|
398
|
+
<pre><span class="ruby-comment"># File lib/nanook/wallet.rb, line 67</span>
|
399
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">accounts</span>
|
400
|
+
<span class="ruby-identifier">wallet_required!</span>
|
401
|
+
<span class="ruby-identifier">response</span> = <span class="ruby-identifier">rpc</span>(<span class="ruby-value">:account_list</span>)[<span class="ruby-value">:accounts</span>]
|
402
|
+
<span class="ruby-constant">Nanook</span><span class="ruby-operator">::</span><span class="ruby-constant">Util</span>.<span class="ruby-identifier">coerce_empty_string_to_type</span>(<span class="ruby-identifier">response</span>, <span class="ruby-constant">Array</span>)
|
403
|
+
<span class="ruby-keyword">end</span></pre>
|
404
|
+
</div>
|
405
|
+
</div>
|
406
|
+
|
407
|
+
</div>
|
408
|
+
|
409
|
+
<div class="method">
|
410
|
+
<div class="title method-title" id="method-i-balance">
|
411
|
+
|
412
|
+
<b>balance</b>(account_break_down: false)
|
413
|
+
|
414
|
+
<a href="../../classes/Nanook/Wallet.html#method-i-balance" name="method-i-balance" class="permalink">Link</a>
|
415
|
+
</div>
|
416
|
+
|
417
|
+
|
418
|
+
<div class="description">
|
419
|
+
<p>Returns a Hash containing the balance of all accounts in the wallet,
|
420
|
+
optionally breaking the balances down by account.</p>
|
421
|
+
|
422
|
+
<h4 id="method-i-balance-label-Arguments">Arguments</h4>
|
423
|
+
<table class="rdoc-list label-list"><tbody><tr><td class='label'><code>account_break_down:</code></td><td>
|
424
|
+
<p>Boolean (default is false). When <code>true</code> the response will
|
425
|
+
contain balances per account.</p>
|
426
|
+
</td></tr></tbody></table>
|
427
|
+
|
428
|
+
<h4 id="method-i-balance-label-Examples">Examples</h4>
|
429
|
+
|
430
|
+
<p>Simple use:</p>
|
431
|
+
|
432
|
+
<pre><code>wallet.balance
|
433
|
+
</code></pre>
|
434
|
+
|
435
|
+
<p>Example response:</p>
|
436
|
+
|
437
|
+
<pre><code>{
|
438
|
+
"balance"=>5000000000000000,
|
439
|
+
"pending"=>10000000000000
|
440
|
+
}
|
441
|
+
</code></pre>
|
442
|
+
|
443
|
+
<p>Asking for totals to be broken down by account:</p>
|
444
|
+
|
445
|
+
<pre><code>wallet.balance(account_break_down: true)
|
446
|
+
</code></pre>
|
447
|
+
|
448
|
+
<p>Example response:</p>
|
449
|
+
|
450
|
+
<pre><code>{
|
451
|
+
"xrb_3e3j5tkog48pnny9dmfzj1r16pg8t1e76dz5tmac6iq689wyjfpi00000000"=>{
|
452
|
+
"balance"=>2500000000000000,
|
453
|
+
"pending"=>10000000000000
|
454
|
+
},
|
455
|
+
"xrb_1e5aqegc1jb7qe964u4adzmcezyo6o146zb8hm6dft8tkp79za3sxwjym5rx"=>{
|
456
|
+
"balance"=>2500000000000000,
|
457
|
+
"pending"=>0
|
458
|
+
},
|
459
|
+
}
|
460
|
+
</code></pre>
|
461
|
+
</div>
|
462
|
+
|
463
|
+
|
464
|
+
|
465
|
+
|
466
|
+
|
467
|
+
|
468
|
+
|
469
|
+
|
470
|
+
<div class="sourcecode">
|
471
|
+
|
472
|
+
<p class="source-link">
|
473
|
+
Source:
|
474
|
+
<a href="javascript:toggleSource('method-i-balance_source')" id="l_method-i-balance_source">show</a>
|
475
|
+
|
476
|
+
</p>
|
477
|
+
<div id="method-i-balance_source" class="dyn-source">
|
478
|
+
<pre><span class="ruby-comment"># File lib/nanook/wallet.rb, line 110</span>
|
479
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">balance</span>(<span class="ruby-value">account_break_down:</span> <span class="ruby-keyword">false</span>)
|
480
|
+
<span class="ruby-identifier">wallet_required!</span>
|
481
|
+
<span class="ruby-keyword">if</span> <span class="ruby-identifier">account_break_down</span>
|
482
|
+
<span class="ruby-constant">Nanook</span><span class="ruby-operator">::</span><span class="ruby-constant">Util</span>.<span class="ruby-identifier">coerce_empty_string_to_type</span>(<span class="ruby-identifier">rpc</span>(<span class="ruby-value">:wallet_balances</span>)[<span class="ruby-value">:balances</span>], <span class="ruby-constant">Hash</span>)
|
483
|
+
<span class="ruby-keyword">else</span>
|
484
|
+
<span class="ruby-identifier">rpc</span>(<span class="ruby-value">:wallet_balance_total</span>)
|
485
|
+
<span class="ruby-keyword">end</span>
|
486
|
+
<span class="ruby-keyword">end</span></pre>
|
487
|
+
</div>
|
488
|
+
</div>
|
489
|
+
|
490
|
+
</div>
|
491
|
+
|
492
|
+
<div class="method">
|
493
|
+
<div class="title method-title" id="method-i-change_password">
|
494
|
+
|
495
|
+
<b>change_password</b>(password)
|
496
|
+
|
497
|
+
<a href="../../classes/Nanook/Wallet.html#method-i-change_password" name="method-i-change_password" class="permalink">Link</a>
|
498
|
+
</div>
|
499
|
+
|
500
|
+
|
501
|
+
<div class="description">
|
502
|
+
<p>Changes the password for a wallet. Returns a boolean to indicate if the
|
503
|
+
action was successful.</p>
|
504
|
+
|
505
|
+
<h4 id="method-i-change_password-label-Example+response">Example response</h4>
|
506
|
+
|
507
|
+
<pre><code>true
|
508
|
+
</code></pre>
|
509
|
+
</div>
|
510
|
+
|
511
|
+
|
512
|
+
|
513
|
+
|
514
|
+
|
515
|
+
|
516
|
+
|
517
|
+
|
518
|
+
<div class="sourcecode">
|
519
|
+
|
520
|
+
<p class="source-link">
|
521
|
+
Source:
|
522
|
+
<a href="javascript:toggleSource('method-i-change_password_source')" id="l_method-i-change_password_source">show</a>
|
523
|
+
|
524
|
+
</p>
|
525
|
+
<div id="method-i-change_password_source" class="dyn-source">
|
526
|
+
<pre><span class="ruby-comment"># File lib/nanook/wallet.rb, line 284</span>
|
527
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">change_password</span>(<span class="ruby-identifier">password</span>)
|
528
|
+
<span class="ruby-identifier">wallet_required!</span>
|
529
|
+
<span class="ruby-identifier">rpc</span>(<span class="ruby-value">:password_change</span>, <span class="ruby-value">password:</span> <span class="ruby-identifier">password</span>)[<span class="ruby-value">:changed</span>] <span class="ruby-operator">==</span> <span class="ruby-value">1</span>
|
530
|
+
<span class="ruby-keyword">end</span></pre>
|
531
|
+
</div>
|
532
|
+
</div>
|
533
|
+
|
534
|
+
</div>
|
535
|
+
|
536
|
+
<div class="method">
|
537
|
+
<div class="title method-title" id="method-i-contains-3F">
|
538
|
+
|
539
|
+
<b>contains?</b>(account)
|
540
|
+
|
541
|
+
<a href="../../classes/Nanook/Wallet.html#method-i-contains-3F" name="method-i-contains-3F" class="permalink">Link</a>
|
542
|
+
</div>
|
543
|
+
|
544
|
+
|
545
|
+
<div class="description">
|
546
|
+
<p>Returns boolean indicating if the wallet contains an account.</p>
|
547
|
+
|
548
|
+
<h4 id="method-i-contains-3F-label-Arguments">Arguments</h4>
|
549
|
+
<table class="rdoc-list label-list"><tbody><tr><td class='label'><code>account</code></td><td>
|
550
|
+
<p>String account id (will start with <code>"xrb_..."</code>)</p>
|
551
|
+
</td></tr></tbody></table>
|
552
|
+
|
553
|
+
<h4 id="method-i-contains-3F-label-Example+response">Example response</h4>
|
554
|
+
|
555
|
+
<pre><code>true
|
556
|
+
</code></pre>
|
557
|
+
</div>
|
558
|
+
|
559
|
+
|
560
|
+
|
561
|
+
|
562
|
+
|
563
|
+
|
564
|
+
|
565
|
+
|
566
|
+
<div class="sourcecode">
|
567
|
+
|
568
|
+
<p class="source-link">
|
569
|
+
Source:
|
570
|
+
<a href="javascript:toggleSource('method-i-contains-3F_source')" id="l_method-i-contains-3F_source">show</a>
|
571
|
+
|
572
|
+
</p>
|
573
|
+
<div id="method-i-contains-3F_source" class="dyn-source">
|
574
|
+
<pre><span class="ruby-comment"># File lib/nanook/wallet.rb, line 178</span>
|
575
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">contains?</span>(<span class="ruby-identifier">account</span>)
|
576
|
+
<span class="ruby-identifier">wallet_required!</span>
|
577
|
+
<span class="ruby-identifier">response</span> = <span class="ruby-identifier">rpc</span>(<span class="ruby-value">:wallet_contains</span>, <span class="ruby-value">account:</span> <span class="ruby-identifier">account</span>)
|
578
|
+
<span class="ruby-operator">!</span><span class="ruby-identifier">response</span>.<span class="ruby-identifier">empty?</span> <span class="ruby-operator">&&</span> <span class="ruby-identifier">response</span>[<span class="ruby-value">:exists</span>] <span class="ruby-operator">==</span> <span class="ruby-value">1</span>
|
579
|
+
<span class="ruby-keyword">end</span></pre>
|
580
|
+
</div>
|
581
|
+
</div>
|
582
|
+
|
583
|
+
</div>
|
584
|
+
|
585
|
+
<div class="method">
|
586
|
+
<div class="title method-title" id="method-i-create">
|
587
|
+
|
588
|
+
<b>create</b>()
|
589
|
+
|
590
|
+
<a href="../../classes/Nanook/Wallet.html#method-i-create" name="method-i-create" class="permalink">Link</a>
|
591
|
+
</div>
|
592
|
+
|
593
|
+
|
594
|
+
<div class="description">
|
595
|
+
<p>Creates a new wallet. This is the only method in <a
|
596
|
+
href="Wallet.html">Nanook::Wallet</a> that doesn't expect a wallet seed
|
597
|
+
to be passed in as an argument.</p>
|
598
|
+
|
599
|
+
<p>To create a new wallet:</p>
|
600
|
+
|
601
|
+
<pre><code>Nanook.new.wallet.create
|
602
|
+
</code></pre>
|
603
|
+
|
604
|
+
<h4 id="method-i-create-label-Very+important">Very important</h4>
|
605
|
+
|
606
|
+
<p><strong>Please read this.</strong> The response of this method is a wallet
|
607
|
+
seed. A seed is a 32-byte uppercase hex string. You can think of this
|
608
|
+
string as your API key to the nano network. The person who knows it can do
|
609
|
+
all read and write actions against the wallet and all accounts inside the
|
610
|
+
wallet from anywhere on the nano network, not just on the node you created
|
611
|
+
the wallet on.</p>
|
612
|
+
|
613
|
+
<p>If you intend for your wallet to contain funds, then make sure that you
|
614
|
+
consider the seed that is returned as the key to your funds and store it
|
615
|
+
somewhere secret and safe. Do not transmit the seed over insecure (non-SSH
|
616
|
+
or SSL) networks or store it where it is able to be easily comprised by a
|
617
|
+
hacker, which includes your personal computer.</p>
|
618
|
+
|
619
|
+
<h4 id="method-i-create-label-Example+response-3A">Example response:</h4>
|
620
|
+
|
621
|
+
<pre><code>"CC2C9846A44DB6F0363F647D12B957794AD937F59498D4E35C172C81E2888650"
|
622
|
+
</code></pre>
|
623
|
+
</div>
|
624
|
+
|
625
|
+
|
626
|
+
|
627
|
+
|
628
|
+
|
629
|
+
|
630
|
+
|
631
|
+
|
632
|
+
<div class="sourcecode">
|
633
|
+
|
634
|
+
<p class="source-link">
|
635
|
+
Source:
|
636
|
+
<a href="javascript:toggleSource('method-i-create_source')" id="l_method-i-create_source">show</a>
|
637
|
+
|
638
|
+
</p>
|
639
|
+
<div id="method-i-create_source" class="dyn-source">
|
640
|
+
<pre><span class="ruby-comment"># File lib/nanook/wallet.rb, line 145</span>
|
641
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">create</span>
|
642
|
+
<span class="ruby-identifier">rpc</span>(<span class="ruby-value">:wallet_create</span>)[<span class="ruby-value">:wallet</span>]
|
643
|
+
<span class="ruby-keyword">end</span></pre>
|
644
|
+
</div>
|
645
|
+
</div>
|
646
|
+
|
647
|
+
</div>
|
648
|
+
|
649
|
+
<div class="method">
|
650
|
+
<div class="title method-title" id="method-i-destroy">
|
651
|
+
|
652
|
+
<b>destroy</b>()
|
653
|
+
|
654
|
+
<a href="../../classes/Nanook/Wallet.html#method-i-destroy" name="method-i-destroy" class="permalink">Link</a>
|
655
|
+
</div>
|
656
|
+
|
657
|
+
|
658
|
+
<div class="description">
|
659
|
+
<p>Destroy the wallet. Returns a boolean indicating whether the action was
|
660
|
+
successful or not.</p>
|
661
|
+
|
662
|
+
<h4 id="method-i-destroy-label-Example+Response">Example Response</h4>
|
663
|
+
|
664
|
+
<pre><code>true
|
665
|
+
</code></pre>
|
666
|
+
</div>
|
667
|
+
|
668
|
+
|
669
|
+
|
670
|
+
|
671
|
+
|
672
|
+
|
673
|
+
|
674
|
+
|
675
|
+
<div class="sourcecode">
|
676
|
+
|
677
|
+
<p class="source-link">
|
678
|
+
Source:
|
679
|
+
<a href="javascript:toggleSource('method-i-destroy_source')" id="l_method-i-destroy_source">show</a>
|
680
|
+
|
681
|
+
</p>
|
682
|
+
<div id="method-i-destroy_source" class="dyn-source">
|
683
|
+
<pre><span class="ruby-comment"># File lib/nanook/wallet.rb, line 154</span>
|
684
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">destroy</span>
|
685
|
+
<span class="ruby-identifier">wallet_required!</span>
|
686
|
+
<span class="ruby-identifier">rpc</span>(<span class="ruby-value">:wallet_destroy</span>)
|
687
|
+
<span class="ruby-keyword">true</span>
|
688
|
+
<span class="ruby-keyword">end</span></pre>
|
689
|
+
</div>
|
690
|
+
</div>
|
691
|
+
|
692
|
+
</div>
|
693
|
+
|
694
|
+
<div class="method">
|
695
|
+
<div class="title method-title" id="method-i-export">
|
696
|
+
|
697
|
+
<b>export</b>()
|
698
|
+
|
699
|
+
<a href="../../classes/Nanook/Wallet.html#method-i-export" name="method-i-export" class="permalink">Link</a>
|
700
|
+
</div>
|
701
|
+
|
702
|
+
|
703
|
+
<div class="description">
|
704
|
+
<p>Generates a String containing a JSON representation of your wallet.</p>
|
705
|
+
|
706
|
+
<h4 id="method-i-export-label-Example+response">Example response</h4>
|
707
|
+
|
708
|
+
<pre><code>"{\n \"0000000000000000000000000000000000000000000000000000000000000000\": \"0000000000000000000000000000000000000000000000000000000000000003\",\n \"0000000000000000000000000000000000000000000000000000000000000001\": \"C3A176FC3B90113277BFC91F55128FC9A1F1B6166A73E7446927CFFCA4C2C9D9\",\n \"0000000000000000000000000000000000000000000000000000000000000002\": \"3E58EC805B99C52B4715598BD332C234A1FBF1780577137E18F53B9B7F85F04B\",\n \"0000000000000000000000000000000000000000000000000000000000000003\": \"5FF8021122F3DEE0E4EC4241D35A3F41DEF63CCF6ADA66AF235DE857718498CD\",\n \"0000000000000000000000000000000000000000000000000000000000000004\": \"A30E0A32ED41C8607AA9212843392E853FCBCB4E7CB194E35C94F07F91DE59EF\",\n \"0000000000000000000000000000000000000000000000000000000000000005\": \"E707002E84143AA5F030A6DB8DD0C0480F2FFA75AB1FFD657EC22B5AA8E395D5\",\n \"0000000000000000000000000000000000000000000000000000000000000006\": \"0000000000000000000000000000000000000000000000000000000000000001\",\n \"8646C0423160DEAEAA64034F9C6858F7A5C8A329E73E825A5B16814F6CCAFFE3\": \"0000000000000000000000000000000000000000000000000000000100000000\"\n}\n"
|
709
|
+
</code></pre>
|
710
|
+
</div>
|
711
|
+
|
712
|
+
|
713
|
+
|
714
|
+
|
715
|
+
|
716
|
+
|
717
|
+
|
718
|
+
|
719
|
+
<div class="sourcecode">
|
720
|
+
|
721
|
+
<p class="source-link">
|
722
|
+
Source:
|
723
|
+
<a href="javascript:toggleSource('method-i-export_source')" id="l_method-i-export_source">show</a>
|
724
|
+
|
725
|
+
</p>
|
726
|
+
<div id="method-i-export_source" class="dyn-source">
|
727
|
+
<pre><span class="ruby-comment"># File lib/nanook/wallet.rb, line 165</span>
|
728
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">export</span>
|
729
|
+
<span class="ruby-identifier">wallet_required!</span>
|
730
|
+
<span class="ruby-identifier">rpc</span>(<span class="ruby-value">:wallet_export</span>)[<span class="ruby-value">:json</span>]
|
731
|
+
<span class="ruby-keyword">end</span></pre>
|
732
|
+
</div>
|
733
|
+
</div>
|
734
|
+
|
735
|
+
</div>
|
736
|
+
|
737
|
+
<div class="method">
|
738
|
+
<div class="title method-title" id="method-i-locked-3F">
|
739
|
+
|
740
|
+
<b>locked?</b>()
|
741
|
+
|
742
|
+
<a href="../../classes/Nanook/Wallet.html#method-i-locked-3F" name="method-i-locked-3F" class="permalink">Link</a>
|
743
|
+
</div>
|
744
|
+
|
745
|
+
|
746
|
+
<div class="description">
|
747
|
+
<p>Returns a boolean to indicate if the wallet is locked.</p>
|
748
|
+
|
749
|
+
<h4 id="method-i-locked-3F-label-Example+response">Example response</h4>
|
750
|
+
|
751
|
+
<pre><code>true
|
752
|
+
</code></pre>
|
753
|
+
</div>
|
754
|
+
|
755
|
+
|
756
|
+
|
757
|
+
|
758
|
+
|
759
|
+
|
760
|
+
|
761
|
+
|
762
|
+
<div class="sourcecode">
|
763
|
+
|
764
|
+
<p class="source-link">
|
765
|
+
Source:
|
766
|
+
<a href="javascript:toggleSource('method-i-locked-3F_source')" id="l_method-i-locked-3F_source">show</a>
|
767
|
+
|
768
|
+
</p>
|
769
|
+
<div id="method-i-locked-3F_source" class="dyn-source">
|
770
|
+
<pre><span class="ruby-comment"># File lib/nanook/wallet.rb, line 261</span>
|
771
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">locked?</span>
|
772
|
+
<span class="ruby-identifier">wallet_required!</span>
|
773
|
+
<span class="ruby-identifier">response</span> = <span class="ruby-identifier">rpc</span>(<span class="ruby-value">:wallet_locked</span>)
|
774
|
+
<span class="ruby-operator">!</span><span class="ruby-identifier">response</span>.<span class="ruby-identifier">empty?</span> <span class="ruby-operator">&&</span> <span class="ruby-identifier">response</span>[<span class="ruby-value">:locked</span>] <span class="ruby-operator">!=</span> <span class="ruby-value">0</span>
|
775
|
+
<span class="ruby-keyword">end</span></pre>
|
776
|
+
</div>
|
777
|
+
</div>
|
778
|
+
|
779
|
+
</div>
|
780
|
+
|
781
|
+
<div class="method">
|
782
|
+
<div class="title method-title" id="method-i-pay">
|
783
|
+
|
784
|
+
<b>pay</b>(from:, to:, amount:, id:)
|
785
|
+
|
786
|
+
<a href="../../classes/Nanook/Wallet.html#method-i-pay" name="method-i-pay" class="permalink">Link</a>
|
787
|
+
</div>
|
788
|
+
|
789
|
+
|
790
|
+
<div class="description">
|
791
|
+
<p>Make a payment from an account in your wallet to another account on the
|
792
|
+
nano network. Returns a <em>send</em> block hash if successful, or an error
|
793
|
+
String if unsuccessful.</p>
|
794
|
+
|
795
|
+
<h4 id="method-i-pay-label-Arguments">Arguments</h4>
|
796
|
+
<table class="rdoc-list label-list"><tbody><tr><td class='label'><code>from:</code></td><td>
|
797
|
+
<p>String account id of an account in your wallet</p>
|
798
|
+
</td></tr><tr><td class='label'><code>to:</code></td><td>
|
799
|
+
<p>String account id of the recipient of your payment</p>
|
800
|
+
</td></tr><tr><td class='label'><code>amount:</code></td><td>
|
801
|
+
<p>Can be either an Integer or Float. Unit is NANO (which is currently
|
802
|
+
technically 1Mnano - see <a
|
803
|
+
href="https://nano.org/en/faq#what-are-nano-units-">What are Nano’s
|
804
|
+
Units</a>).</p>
|
805
|
+
</td></tr><tr><td class='label'><code>id:</code></td><td>
|
806
|
+
<p>String. Must be unique per payment. It serves an important purpose; it
|
807
|
+
allows you to make the same call multiple times with the same
|
808
|
+
<code>id</code> and be reassured that you will only ever send that nano
|
809
|
+
payment once.</p>
|
810
|
+
</td></tr></tbody></table>
|
811
|
+
|
812
|
+
<p>Note, there may be a delay in receiving a response due to Proof of Work
|
813
|
+
being done. From the <a
|
814
|
+
href="https://github.com/nanocurrency/raiblocks/wiki/RPC-protocol#account-create">Nano
|
815
|
+
RPC</a>:</p>
|
816
|
+
|
817
|
+
<p><em>Proof of Work is precomputed for one transaction in the background. If
|
818
|
+
it has been a while since your last transaction it will send instantly, the
|
819
|
+
next one will need to wait for Proof of Work to be generated.</em></p>
|
820
|
+
|
821
|
+
<h4 id="method-i-pay-label-Example">Example</h4>
|
822
|
+
|
823
|
+
<pre><code>wallet.pay(from: "xrb_...", to: "xrb_...", amount: 0.001, id: "myUniqueId123")
|
824
|
+
</code></pre>
|
825
|
+
|
826
|
+
<h4 id="method-i-pay-label-Example+responses">Example responses</h4>
|
827
|
+
|
828
|
+
<pre><code>"718CC2121C3E641059BC1C2CFC45666C99E8AE922F7A807B7D07B62C995D79E2"
|
829
|
+
</code></pre>
|
830
|
+
|
831
|
+
<p>Or:</p>
|
832
|
+
|
833
|
+
<pre><code>"Account not found"
|
834
|
+
</code></pre>
|
835
|
+
</div>
|
836
|
+
|
837
|
+
|
838
|
+
|
839
|
+
|
840
|
+
|
841
|
+
|
842
|
+
|
843
|
+
|
844
|
+
<div class="sourcecode">
|
845
|
+
|
846
|
+
<p class="source-link">
|
847
|
+
Source:
|
848
|
+
<a href="javascript:toggleSource('method-i-pay_source')" id="l_method-i-pay_source">show</a>
|
849
|
+
|
850
|
+
</p>
|
851
|
+
<div id="method-i-pay_source" class="dyn-source">
|
852
|
+
<pre><span class="ruby-comment"># File lib/nanook/wallet.rb, line 214</span>
|
853
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">pay</span>(<span class="ruby-value">from:</span>, <span class="ruby-value">to:</span>, <span class="ruby-value">amount:</span>, <span class="ruby-value">id:</span>)
|
854
|
+
<span class="ruby-identifier">wallet_required!</span>
|
855
|
+
<span class="ruby-identifier">validate_wallet_contains_account!</span>(<span class="ruby-identifier">from</span>)
|
856
|
+
<span class="ruby-identifier">account</span>(<span class="ruby-identifier">from</span>).<span class="ruby-identifier">pay</span>(<span class="ruby-value">to:</span> <span class="ruby-identifier">to</span>, <span class="ruby-value">amount:</span> <span class="ruby-identifier">amount</span>, <span class="ruby-value">id:</span> <span class="ruby-identifier">id</span>)
|
857
|
+
<span class="ruby-keyword">end</span></pre>
|
858
|
+
</div>
|
859
|
+
</div>
|
860
|
+
|
861
|
+
</div>
|
862
|
+
|
863
|
+
<div class="method">
|
864
|
+
<div class="title method-title" id="method-i-receive">
|
865
|
+
|
866
|
+
<b>receive</b>(block=nil, into:)
|
867
|
+
|
868
|
+
<a href="../../classes/Nanook/Wallet.html#method-i-receive" name="method-i-receive" class="permalink">Link</a>
|
869
|
+
</div>
|
870
|
+
|
871
|
+
|
872
|
+
<div class="description">
|
873
|
+
<p>Receives a pending payment into an account in the wallet.</p>
|
874
|
+
|
875
|
+
<p>When called with no <code>block</code> argument, the latest pending payment
|
876
|
+
for the account will be received.</p>
|
877
|
+
|
878
|
+
<p>Returns a <em>receive</em> block hash if a receive was successful, or
|
879
|
+
<code>false</code> if there were no pending payments to receive.</p>
|
880
|
+
|
881
|
+
<p>You can also receive a specific pending block if you know it by passing the
|
882
|
+
block has in as an argument.</p>
|
883
|
+
|
884
|
+
<h4 id="method-i-receive-label-Arguments">Arguments</h4>
|
885
|
+
<table class="rdoc-list label-list"><tbody><tr><td class='label'><code>block</code></td><td>
|
886
|
+
<p>Optional block hash of pending payment. If not provided, the latest pending
|
887
|
+
payment will be received</p>
|
888
|
+
</td></tr><tr><td class='label'><code>into:</code></td><td>
|
889
|
+
<p>String account id of account in your wallet to receive the payment into</p>
|
890
|
+
</td></tr></tbody></table>
|
891
|
+
|
892
|
+
<h4 id="method-i-receive-label-Examples">Examples</h4>
|
893
|
+
|
894
|
+
<pre><code>wallet.receive(into: "xrb...")
|
895
|
+
wallet.receive("718CC21...", into: "xrb...")
|
896
|
+
</code></pre>
|
897
|
+
|
898
|
+
<h4 id="method-i-receive-label-Example+responses">Example responses</h4>
|
899
|
+
|
900
|
+
<pre><code>"718CC2121C3E641059BC1C2CFC45666C99E8AE922F7A807B7D07B62C995D79E2"
|
901
|
+
</code></pre>
|
902
|
+
|
903
|
+
<p>Or:</p>
|
904
|
+
|
905
|
+
<pre><code>false
|
906
|
+
</code></pre>
|
907
|
+
</div>
|
908
|
+
|
909
|
+
|
910
|
+
|
911
|
+
|
912
|
+
|
913
|
+
|
914
|
+
|
915
|
+
|
916
|
+
<div class="sourcecode">
|
917
|
+
|
918
|
+
<p class="source-link">
|
919
|
+
Source:
|
920
|
+
<a href="javascript:toggleSource('method-i-receive_source')" id="l_method-i-receive_source">show</a>
|
921
|
+
|
922
|
+
</p>
|
923
|
+
<div id="method-i-receive_source" class="dyn-source">
|
924
|
+
<pre><span class="ruby-comment"># File lib/nanook/wallet.rb, line 250</span>
|
925
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">receive</span>(<span class="ruby-identifier">block</span>=<span class="ruby-keyword">nil</span>, <span class="ruby-value">into:</span>)
|
926
|
+
<span class="ruby-identifier">wallet_required!</span>
|
927
|
+
<span class="ruby-identifier">validate_wallet_contains_account!</span>(<span class="ruby-identifier">into</span>)
|
928
|
+
<span class="ruby-identifier">account</span>(<span class="ruby-identifier">into</span>).<span class="ruby-identifier">receive</span>(<span class="ruby-identifier">block</span>)
|
929
|
+
<span class="ruby-keyword">end</span></pre>
|
930
|
+
</div>
|
931
|
+
</div>
|
932
|
+
|
933
|
+
</div>
|
934
|
+
|
935
|
+
<div class="method">
|
936
|
+
<div class="title method-title" id="method-i-unlock">
|
937
|
+
|
938
|
+
<b>unlock</b>(password)
|
939
|
+
|
940
|
+
<a href="../../classes/Nanook/Wallet.html#method-i-unlock" name="method-i-unlock" class="permalink">Link</a>
|
941
|
+
</div>
|
942
|
+
|
943
|
+
|
944
|
+
<div class="description">
|
945
|
+
<p>Unlocks a previously locked wallet. Returns a boolean to indicate if the
|
946
|
+
action was successful.</p>
|
947
|
+
|
948
|
+
<h4 id="method-i-unlock-label-Example+response">Example response</h4>
|
949
|
+
|
950
|
+
<pre><code>true
|
951
|
+
</code></pre>
|
952
|
+
</div>
|
953
|
+
|
954
|
+
|
955
|
+
|
956
|
+
|
957
|
+
|
958
|
+
|
959
|
+
|
960
|
+
|
961
|
+
<div class="sourcecode">
|
962
|
+
|
963
|
+
<p class="source-link">
|
964
|
+
Source:
|
965
|
+
<a href="javascript:toggleSource('method-i-unlock_source')" id="l_method-i-unlock_source">show</a>
|
966
|
+
|
967
|
+
</p>
|
968
|
+
<div id="method-i-unlock_source" class="dyn-source">
|
969
|
+
<pre><span class="ruby-comment"># File lib/nanook/wallet.rb, line 273</span>
|
970
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">unlock</span>(<span class="ruby-identifier">password</span>)
|
971
|
+
<span class="ruby-identifier">wallet_required!</span>
|
972
|
+
<span class="ruby-identifier">rpc</span>(<span class="ruby-value">:password_enter</span>, <span class="ruby-value">password:</span> <span class="ruby-identifier">password</span>)[<span class="ruby-value">:valid</span>] <span class="ruby-operator">==</span> <span class="ruby-value">1</span>
|
973
|
+
<span class="ruby-keyword">end</span></pre>
|
974
|
+
</div>
|
975
|
+
</div>
|
976
|
+
|
977
|
+
</div>
|
978
|
+
|
979
|
+
|
980
|
+
|
981
|
+
|
982
|
+
</div>
|
983
|
+
|
984
|
+
</div>
|
985
|
+
</body>
|
986
|
+
</html>
|