@neuraiproject/neurai-rpc 0.2.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +282 -0
- package/createDocs.js +42 -0
- package/docs.json +174 -0
- package/docs.ts +5266 -0
- package/index.ts +251 -0
- package/neurai_methods.md +4580 -0
- package/package.json +43 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 Raven Rebels
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
# neurai-rpc
|
|
2
|
+
|
|
3
|
+
A package that will help you do RPC calls from Node.js to your Raven core node, that is your full Neurai node.
|
|
4
|
+
|
|
5
|
+
# Install
|
|
6
|
+
```
|
|
7
|
+
npm install @neuraiproject/neurai-rpc
|
|
8
|
+
```
|
|
9
|
+
# Example
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
const { getRPC, methods } = require("@neuraiproject/neurai-rpc");
|
|
14
|
+
//methods is a list of all available methods/functions/commands/procedures
|
|
15
|
+
|
|
16
|
+
const rpc = getRPC("UsernameSecret", "PasswordSecret", "http://localhost:8766");
|
|
17
|
+
|
|
18
|
+
const promise = rpc(methods.getassetdata, ["ELVIS"]);
|
|
19
|
+
promise.catch((e) => {
|
|
20
|
+
console.dir(e);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
promise.then((response) => {
|
|
24
|
+
console.log(response);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
will print out
|
|
31
|
+
|
|
32
|
+
```
|
|
33
|
+
{ name: 'ELVIS', amount: 1, units: 8, reissuable: 1, has_ipfs: 0 }
|
|
34
|
+
```
|
|
35
|
+
## Example list all generated addresses in a Wallet (Raven core)
|
|
36
|
+
Use method `listreceivedbyaddress` to receive a list of all generated addresses.
|
|
37
|
+
Write the result to a .json file
|
|
38
|
+
```
|
|
39
|
+
const { getRPC, methods } = require("@neuraiproject/neurai-rpc");
|
|
40
|
+
//methods is a list of all available methods/functions/commands/procedures
|
|
41
|
+
|
|
42
|
+
const method = methods.listreceivedbyaddress;
|
|
43
|
+
const minConfirmations = 1;
|
|
44
|
+
const includeEmpty = true;
|
|
45
|
+
|
|
46
|
+
const params = [minConfirmations, includeEmpty];
|
|
47
|
+
|
|
48
|
+
const rpc = getRPC("UsernameSecret", "PasswordSecret", "http://localhost:8766");
|
|
49
|
+
|
|
50
|
+
const promise = rpc(method, params);
|
|
51
|
+
promise.catch((e) => {
|
|
52
|
+
console.dir(e);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
promise.then((response) => {
|
|
56
|
+
const addresses = [];
|
|
57
|
+
response.map(function (obj) {
|
|
58
|
+
addresses.push(obj.address);
|
|
59
|
+
});
|
|
60
|
+
writeToFile(addresses);
|
|
61
|
+
console.log("DONE, check out addresses.json");
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
function writeToFile(list){
|
|
65
|
+
const json = JSON.stringify(list, null, 4);
|
|
66
|
+
require("fs").writeFileSync("./addresses.json", json);
|
|
67
|
+
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
```
|
|
71
|
+
# Methods / commands / Procedure calls
|
|
72
|
+
Here is a list of all method/commands [All methods](neurai_methods.md)
|
|
73
|
+
|
|
74
|
+
In your local Raven core wallet, you can go to
|
|
75
|
+
|
|
76
|
+
help > debug window > console
|
|
77
|
+
|
|
78
|
+
type `help`
|
|
79
|
+
..and you get a list of all available commands
|
|
80
|
+
|
|
81
|
+
```
|
|
82
|
+
== Addressindex ==
|
|
83
|
+
getaddressbalance
|
|
84
|
+
getaddressdeltas
|
|
85
|
+
getaddressmempool
|
|
86
|
+
getaddresstxids
|
|
87
|
+
getaddressutxos
|
|
88
|
+
|
|
89
|
+
== Assets ==
|
|
90
|
+
getassetdata "asset_name"
|
|
91
|
+
getcacheinfo
|
|
92
|
+
getsnapshot "asset_name" block_height
|
|
93
|
+
issue "asset_name" qty "( to_address )" "( change_address )" ( units ) ( reissuable ) ( has_ipfs ) "( ipfs_hash )"
|
|
94
|
+
issueunique "root_name" [asset_tags] ( [ipfs_hashes] ) "( to_address )" "( change_address )"
|
|
95
|
+
listaddressesbyasset "asset_name" (onlytotal) (count) (start)
|
|
96
|
+
listassetbalancesbyaddress "address" (onlytotal) (count) (start)
|
|
97
|
+
listassets "( asset )" ( verbose ) ( count ) ( start )
|
|
98
|
+
listmyassets "( asset )" ( verbose ) ( count ) ( start ) (confs)
|
|
99
|
+
purgesnapshot "asset_name" block_height
|
|
100
|
+
reissue "asset_name" qty "to_address" "change_address" ( reissuable ) ( new_units) "( new_ipfs )"
|
|
101
|
+
transfer "asset_name" qty "to_address" "message" expire_time "change_address" "asset_change_address"
|
|
102
|
+
transferfromaddress "asset_name" "from_address" qty "to_address" "message" expire_time "xna_change_address" "asset_change_address"
|
|
103
|
+
transferfromaddresses "asset_name" ["from_addresses"] qty "to_address" "message" expire_time "xna_change_address" "asset_change_address"
|
|
104
|
+
|
|
105
|
+
== Blockchain ==
|
|
106
|
+
clearmempool
|
|
107
|
+
decodeblock "blockhex"
|
|
108
|
+
getbestblockhash
|
|
109
|
+
getblock "blockhash" ( verbosity )
|
|
110
|
+
getblockchaininfo
|
|
111
|
+
getblockcount
|
|
112
|
+
|
|
113
|
+
getblockhash height
|
|
114
|
+
getblockhashes timestamp
|
|
115
|
+
getblockheader "hash" ( verbose )
|
|
116
|
+
getchaintips
|
|
117
|
+
getchaintxstats ( nblocks blockhash )
|
|
118
|
+
getdifficulty
|
|
119
|
+
getmempoolancestors txid (verbose)
|
|
120
|
+
getmempooldescendants txid (verbose)
|
|
121
|
+
getmempoolentry txid
|
|
122
|
+
getmempoolinfo
|
|
123
|
+
getrawmempool ( verbose )
|
|
124
|
+
getspentinfo
|
|
125
|
+
gettxout "txid" n ( include_mempool )
|
|
126
|
+
gettxoutproof ["txid",...] ( blockhash )
|
|
127
|
+
gettxoutsetinfo
|
|
128
|
+
preciousblock "blockhash"
|
|
129
|
+
pruneblockchain
|
|
130
|
+
savemempool
|
|
131
|
+
verifychain ( checklevel nblocks )
|
|
132
|
+
verifytxoutproof "proof"
|
|
133
|
+
|
|
134
|
+
== Control ==
|
|
135
|
+
getinfo
|
|
136
|
+
getmemoryinfo ("mode")
|
|
137
|
+
getrpcinfo
|
|
138
|
+
help ( "command" )
|
|
139
|
+
stop
|
|
140
|
+
uptime
|
|
141
|
+
|
|
142
|
+
== Generating ==
|
|
143
|
+
generate nblocks ( maxtries )
|
|
144
|
+
generatetoaddress nblocks address (maxtries)
|
|
145
|
+
getgenerate
|
|
146
|
+
setgenerate generate ( genproclimit )
|
|
147
|
+
|
|
148
|
+
== Messages ==
|
|
149
|
+
clearmessages
|
|
150
|
+
sendmessage "channel_name" "ipfs_hash" (expire_time)
|
|
151
|
+
subscribetochannel
|
|
152
|
+
unsubscribefromchannel
|
|
153
|
+
viewallmessagechannels
|
|
154
|
+
viewallmessages
|
|
155
|
+
|
|
156
|
+
== Mining ==
|
|
157
|
+
getblocktemplate ( TemplateRequest )
|
|
158
|
+
getkawpowhash "header_hash" "mix_hash" nonce, height, "target"
|
|
159
|
+
getmininginfo
|
|
160
|
+
getnetworkhashps ( nblocks height )
|
|
161
|
+
pprpcsb "header_hash" "mix_hash" "nonce"
|
|
162
|
+
prioritisetransaction <txid> <dummy value> <fee delta>
|
|
163
|
+
submitblock "hexdata" ( "dummy" )
|
|
164
|
+
|
|
165
|
+
== Network ==
|
|
166
|
+
addnode "node" "add|remove|onetry"
|
|
167
|
+
clearbanned
|
|
168
|
+
disconnectnode "[address]" [nodeid]
|
|
169
|
+
getaddednodeinfo ( "node" )
|
|
170
|
+
getconnectioncount
|
|
171
|
+
getnettotals
|
|
172
|
+
getnetworkinfo
|
|
173
|
+
getpeerinfo
|
|
174
|
+
listbanned
|
|
175
|
+
ping
|
|
176
|
+
setban "subnet" "add|remove" (bantime) (absolute)
|
|
177
|
+
setnetworkactive true|false
|
|
178
|
+
|
|
179
|
+
== Rawtransactions ==
|
|
180
|
+
combinerawtransaction ["hexstring",...]
|
|
181
|
+
createrawtransaction [{"txid":"id","vout":n},...] {"address":(amount or object),"data":"hex",...}
|
|
182
|
+
decoderawtransaction "hexstring"
|
|
183
|
+
decodescript "hexstring"
|
|
184
|
+
fundrawtransaction "hexstring" ( options )
|
|
185
|
+
getrawtransaction "txid" ( verbose )
|
|
186
|
+
sendrawtransaction "hexstring" ( allowhighfees )
|
|
187
|
+
signrawtransaction "hexstring" ( [{"txid":"id","vout":n,"scriptPubKey":"hex","redeemScript":"hex"},...] ["privatekey1",...] sighashtype )
|
|
188
|
+
testmempoolaccept ["rawtxs"] ( allowhighfees )
|
|
189
|
+
|
|
190
|
+
== Restricted assets ==
|
|
191
|
+
addtagtoaddress tag_name to_address (change_address) (asset_data)
|
|
192
|
+
checkaddressrestriction address restricted_name
|
|
193
|
+
checkaddresstag address tag_name
|
|
194
|
+
checkglobalrestriction restricted_name
|
|
195
|
+
freezeaddress asset_name address (change_address) (asset_data)
|
|
196
|
+
freezerestrictedasset asset_name (change_address) (asset_data)
|
|
197
|
+
getverifierstring restricted_name
|
|
198
|
+
issuequalifierasset "asset_name" qty "( to_address )" "( change_address )" ( has_ipfs ) "( ipfs_hash )"
|
|
199
|
+
issuerestrictedasset "asset_name" qty "verifier" "to_address" "( change_address )" (units) ( reissuable ) ( has_ipfs ) "( ipfs_hash )"
|
|
200
|
+
isvalidverifierstring verifier_string
|
|
201
|
+
listaddressesfortag tag_name
|
|
202
|
+
listaddressrestrictions address
|
|
203
|
+
listglobalrestrictions
|
|
204
|
+
listtagsforaddress address
|
|
205
|
+
reissuerestrictedasset "asset_name" qty to_address ( change_verifier ) ( "new_verifier" ) "( change_address )" ( new_units ) ( reissuable ) "( new_ipfs )"
|
|
206
|
+
removetagfromaddress tag_name to_address (change_address) (asset_data)
|
|
207
|
+
transferqualifier "qualifier_name" qty "to_address" ("change_address") ("message") (expire_time)
|
|
208
|
+
unfreezeaddress asset_name address (change_address) (asset_data)
|
|
209
|
+
unfreezerestrictedasset asset_name (change_address) (asset_data)
|
|
210
|
+
|
|
211
|
+
== Restricted ==
|
|
212
|
+
viewmyrestrictedaddresses
|
|
213
|
+
viewmytaggedaddresses
|
|
214
|
+
|
|
215
|
+
== Rewards ==
|
|
216
|
+
cancelsnapshotrequest "asset_name" block_height
|
|
217
|
+
distributereward "asset_name" snapshot_height "distribution_asset_name" gross_distribution_amount ( "exception_addresses" ) ("change_address") ("dry_run")
|
|
218
|
+
getdistributestatus "asset_name" snapshot_height "distribution_asset_name" gross_distribution_amount ( "exception_addresses" )
|
|
219
|
+
getsnapshotrequest "asset_name" block_height
|
|
220
|
+
listsnapshotrequests ["asset_name" [block_height]]
|
|
221
|
+
requestsnapshot "asset_name" block_height
|
|
222
|
+
|
|
223
|
+
== Util ==
|
|
224
|
+
createmultisig nrequired ["key",...]
|
|
225
|
+
estimatefee nblocks
|
|
226
|
+
estimatesmartfee conf_target ("estimate_mode")
|
|
227
|
+
signmessagewithprivkey "privkey" "message"
|
|
228
|
+
validateaddress "address"
|
|
229
|
+
verifymessage "address" "signature" "message"
|
|
230
|
+
|
|
231
|
+
== Wallet ==
|
|
232
|
+
abandontransaction "txid"
|
|
233
|
+
abortrescan
|
|
234
|
+
addmultisigaddress nrequired ["key",...] ( "account" )
|
|
235
|
+
addwitnessaddress "address"
|
|
236
|
+
backupwallet "destination"
|
|
237
|
+
bumpfee has been deprecated on the XNA Wallet.
|
|
238
|
+
dumpprivkey "address"
|
|
239
|
+
dumpwallet "filename"
|
|
240
|
+
encryptwallet "passphrase"
|
|
241
|
+
getaccount "address"
|
|
242
|
+
getaccountaddress "account"
|
|
243
|
+
getaddressesbyaccount "account"
|
|
244
|
+
getbalance ( "account" minconf include_watchonly )
|
|
245
|
+
getmasterkeyinfo
|
|
246
|
+
getmywords ( "account" )
|
|
247
|
+
getnewaddress ( "account" )
|
|
248
|
+
getrawchangeaddress
|
|
249
|
+
getreceivedbyaccount "account" ( minconf )
|
|
250
|
+
getreceivedbyaddress "address" ( minconf )
|
|
251
|
+
gettransaction "txid" ( include_watchonly )
|
|
252
|
+
getunconfirmedbalance
|
|
253
|
+
getwalletinfo
|
|
254
|
+
importaddress "address" ( "label" rescan p2sh )
|
|
255
|
+
importmulti "requests" ( "options" )
|
|
256
|
+
importprivkey "privkey" ( "label" ) ( rescan )
|
|
257
|
+
importprunedfunds
|
|
258
|
+
importpubkey "pubkey" ( "label" rescan )
|
|
259
|
+
importwallet "filename"
|
|
260
|
+
keypoolrefill ( newsize )
|
|
261
|
+
listaccounts ( minconf include_watchonly)
|
|
262
|
+
listaddressgroupings
|
|
263
|
+
listlockunspent
|
|
264
|
+
listreceivedbyaccount ( minconf include_empty include_watchonly)
|
|
265
|
+
listreceivedbyaddress ( minconf include_empty include_watchonly)
|
|
266
|
+
listsinceblock ( "blockhash" target_confirmations include_watchonly include_removed )
|
|
267
|
+
listtransactions ( "account" count skip include_watchonly)
|
|
268
|
+
listunspent ( minconf maxconf ["addresses",...] [include_unsafe] [query_options])
|
|
269
|
+
listwallets
|
|
270
|
+
lockunspent unlock ([{"txid":"txid","vout":n},...])
|
|
271
|
+
move "fromaccount" "toaccount" amount ( minconf "comment" )
|
|
272
|
+
removeprunedfunds "txid"
|
|
273
|
+
rescanblockchain ("start_height") ("stop_height")
|
|
274
|
+
sendfrom "fromaccount" "toaddress" amount ( minconf "comment" "comment_to" )
|
|
275
|
+
sendfromaddress "from_address" "to_address" amount ( "comment" "comment_to" subtractfeefromamount replaceable conf_target "estimate_mode")
|
|
276
|
+
sendmany "fromaccount" {"address":amount,...} ( minconf "comment" ["address",...] replaceable conf_target "estimate_mode")
|
|
277
|
+
sendtoaddress "address" amount ( "comment" "comment_to" subtractfeefromamount replaceable conf_target "estimate_mode")
|
|
278
|
+
setaccount "address" "account"
|
|
279
|
+
settxfee amount
|
|
280
|
+
signmessage "address" "message"
|
|
281
|
+
|
|
282
|
+
```
|
package/createDocs.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
const docs = require("./docs.json");
|
|
2
|
+
|
|
3
|
+
const keys = Object.keys(docs).sort();
|
|
4
|
+
|
|
5
|
+
//Create docs.ts
|
|
6
|
+
{
|
|
7
|
+
const result = [];
|
|
8
|
+
result.push(`
|
|
9
|
+
export const methods ={
|
|
10
|
+
`);
|
|
11
|
+
|
|
12
|
+
for (let key of keys) {
|
|
13
|
+
if (!key) {
|
|
14
|
+
continue;
|
|
15
|
+
}
|
|
16
|
+
const doc = docs[key];
|
|
17
|
+
|
|
18
|
+
result.push(`\r\n\r\n\r\n\r\n\r\n\r\n/** ${doc}**/`);
|
|
19
|
+
result.push(`\n${key}:'${key}',`);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
result.push("\n}");
|
|
23
|
+
|
|
24
|
+
require("fs").writeFileSync("./docs.ts", result.join(""));
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
//Create neurai_method.md
|
|
28
|
+
{
|
|
29
|
+
const result = [];
|
|
30
|
+
result.push("# Neurai remote procedure calls/methods");
|
|
31
|
+
result.push("\r\n[Home](README.md)");
|
|
32
|
+
for (let key of keys) {
|
|
33
|
+
if (!key) {
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
const doc = docs[key];
|
|
37
|
+
result.push("\r\n <br> <br/>");
|
|
38
|
+
result.push("\r\n## " + key);
|
|
39
|
+
result.push(`\r\n <br/> ${doc} `);
|
|
40
|
+
}
|
|
41
|
+
require("fs").writeFileSync("./neurai_methods.md", result.join(""));
|
|
42
|
+
}
|