bytom 1.0.1
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.
- checksums.yaml +7 -0
- data/.gitignore +8 -0
- data/.idea/.rakeTasks +7 -0
- data/.idea/bytom.iml +13 -0
- data/.idea/codeStyles/codeStyleConfig.xml +5 -0
- data/.idea/encodings.xml +4 -0
- data/.idea/inspectionProfiles/Project_Default.xml +6 -0
- data/.idea/misc.xml +7 -0
- data/.idea/modules.xml +8 -0
- data/.idea/vcs.xml +6 -0
- data/.idea/workspace.xml +505 -0
- data/.travis.yml +7 -0
- data/API-Reference.md +4081 -0
- data/CHANGELOG.md +0 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +5 -0
- data/Gemfile.lock +40 -0
- data/README.md +145 -0
- data/Rakefile +10 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/bytom.gemspec +42 -0
- data/lib/bytom.rb +2 -0
- data/lib/bytom/api/access_token.rb +55 -0
- data/lib/bytom/api/accounts.rb +111 -0
- data/lib/bytom/api/address.rb +66 -0
- data/lib/bytom/api/asset.rb +63 -0
- data/lib/bytom/api/balances.rb +22 -0
- data/lib/bytom/api/block.rb +76 -0
- data/lib/bytom/api/coinbase.rb +31 -0
- data/lib/bytom/api/core_config.rb +38 -0
- data/lib/bytom/api/keys.rb +124 -0
- data/lib/bytom/api/message.rb +48 -0
- data/lib/bytom/api/other.rb +56 -0
- data/lib/bytom/api/peer.rb +42 -0
- data/lib/bytom/api/transactions.rb +210 -0
- data/lib/bytom/api/wallet.rb +57 -0
- data/lib/bytom/api/work.rb +43 -0
- data/lib/bytom/client.rb +89 -0
- data/lib/bytom/constants.rb +6 -0
- data/lib/bytom/request.rb +32 -0
- data/lib/bytom/version.rb +3 -0
- metadata +143 -0
data/.travis.yml
ADDED
data/API-Reference.md
ADDED
@@ -0,0 +1,4081 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
|
4
|
+
|
5
|
+
## Bytom SDK for Ruby
|
6
|
+
|
7
|
+
## Basic Usage
|
8
|
+
|
9
|
+
First, you need to initialize the client.
|
10
|
+
```ruby
|
11
|
+
# Local node
|
12
|
+
bytom_client = Bytom::Client.new(base_url: 'http://127.0.0.1:9888')
|
13
|
+
|
14
|
+
# Remote node
|
15
|
+
bytom_client = Bytom::Client.new(base_url: 'xxx', token: 'xxx')
|
16
|
+
|
17
|
+
```
|
18
|
+
|
19
|
+
## API methods
|
20
|
+
|
21
|
+
### available with wallet enable
|
22
|
+
|
23
|
+
* [`create-key`](#create-key)
|
24
|
+
* [`list-keys`](#list-keys)
|
25
|
+
* [`update-key-alias`](#update-key-alias)
|
26
|
+
* [`delete-key`](#delete-key)
|
27
|
+
* [`check-key-password`](#check-key-password)
|
28
|
+
* [`reset-key-password`](#reset-key-password)
|
29
|
+
* [`create-account`](#create-account)
|
30
|
+
* [`list-accounts`](#list-accounts)
|
31
|
+
* [`update-account-alias`](#update-account-alias)
|
32
|
+
* [`delete-account`](#delete-account)
|
33
|
+
* [`create-account-receiver`](#create-account-receiver)
|
34
|
+
* [`list-addresses`](#list-addresses)
|
35
|
+
* [`validate-address`](#validate-address)
|
36
|
+
* [`get-mining-address`](#get-mining-address)
|
37
|
+
* [`set-mining-address`](#set-mining-address)
|
38
|
+
* [`get-coinbase-arbitrary`](#get-coinbase-arbitrary)
|
39
|
+
* [`set-coinbase-arbitrary`](#set-coinbase-arbitrary)
|
40
|
+
* [`list-pubkeys`](#list-pubkeys)
|
41
|
+
* [`create-asset`](#create-asset)
|
42
|
+
* [`get-asset`](#get-asset)
|
43
|
+
* [`list-assets`](#list-assets)
|
44
|
+
* [`update-asset-alias`](#update-asset-alias)
|
45
|
+
* [`list-balances`](#list-balances)
|
46
|
+
* [`list-unspent-outputs`](#list-unspent-outputs)
|
47
|
+
* [`backup-wallet`](#backup-wallet)
|
48
|
+
* [`restore-wallet`](#restore-wallet)
|
49
|
+
* [`rescan-wallet`](#rescan-wallet)
|
50
|
+
* [`recovery-wallet`](#recovery-wallet)
|
51
|
+
* [`wallet-info`](#wallet-info)
|
52
|
+
* [`sign-message`](#sign-message)
|
53
|
+
* [`decode-program`](#decode-program)
|
54
|
+
* [`get-transaction`](#get-transaction)
|
55
|
+
* [`list-transactions`](#list-transactions)
|
56
|
+
* [`build-transaction`](#build-transaction)
|
57
|
+
* [`build-chain-transactions`](#build-chain-transactions)
|
58
|
+
* [`sign-transaction`](#sign-transaction)
|
59
|
+
* [`sign-transactions`](#sign-transactions)
|
60
|
+
|
61
|
+
### available Whether or not the wallet is open
|
62
|
+
|
63
|
+
* [`submit-transaction`](#submit-transaction)
|
64
|
+
* [`submit-transactions`](#submit-transactions)
|
65
|
+
* [`estimate-transaction-gas`](#estimate-transaction-gas)
|
66
|
+
* [`create-access-token`](#create-access-token)
|
67
|
+
* [`list-access-tokens`](#list-access-tokens)
|
68
|
+
* [`delete-access-token`](#delete-access-token)
|
69
|
+
* [`check-access-token`](#check-access-token)
|
70
|
+
* [`create-transaction-feed`](#create-transaction-feed)
|
71
|
+
* [`get-transaction-feed`](#get-transaction-feed)
|
72
|
+
* [`list-transaction-feeds`](#list-transaction-feeds)
|
73
|
+
* [`delete-transaction-feed`](#delete-transaction-feed)
|
74
|
+
* [`update-transaction-feed`](#update-transaction-feed)
|
75
|
+
* [`get-unconfirmed-transaction`](#get-unconfirmed-transaction)
|
76
|
+
* [`list-unconfirmed-transactions`](#list-unconfirmed-transactions)
|
77
|
+
* [`decode-raw-transaction`](#decode-raw-transaction)
|
78
|
+
* [`get-block-count`](#get-block-count)
|
79
|
+
* [`get-block-hash`](#get-block-hash)
|
80
|
+
* [`get-block`](#get-block)
|
81
|
+
* [`get-block-header`](#get-block-header)
|
82
|
+
* [`get-difficulty`](#get-difficulty)
|
83
|
+
* [`get-hash-rate`](#get-hash-rate)
|
84
|
+
* [`net-info`](#net-info)
|
85
|
+
* [`is-mining`](#is-mining)
|
86
|
+
* [`set-mining`](#set-mining)
|
87
|
+
* [`gas-rate`](#gas-rate)
|
88
|
+
* [`verify-message`](#verify-message)
|
89
|
+
* [`compile`](#compile)
|
90
|
+
* [`list-peers`](#list-peers)
|
91
|
+
* [`disconnect-peer`](#disconnect-peer)
|
92
|
+
* [`connect-peer`](#connect-peer)
|
93
|
+
* [`get-work`](#get-work)
|
94
|
+
* [`submit-work`](#submit-work)
|
95
|
+
* [`get-work-json`](#get-work-json)
|
96
|
+
* [`submit-work-json`](#submit-work-json)
|
97
|
+
|
98
|
+
----
|
99
|
+
|
100
|
+
#### `create-key`
|
101
|
+
|
102
|
+
It is to create private key essentially, returns the information of key. The private key is encrypted in the file and not visible to the user.
|
103
|
+
|
104
|
+
##### Parameters
|
105
|
+
|
106
|
+
`Object`:
|
107
|
+
|
108
|
+
- `String` - *alias*, name of the key.
|
109
|
+
- `String` - *password*, password of the key.
|
110
|
+
- `String` - *language*, mnemonic language of the key.
|
111
|
+
|
112
|
+
Optional:
|
113
|
+
|
114
|
+
- `String` - *mnemonic*, mnemonic of the key, create key by specified mnemonic.
|
115
|
+
|
116
|
+
##### Returns
|
117
|
+
|
118
|
+
`Object`:
|
119
|
+
|
120
|
+
- `String` - *alias*, name of the key.
|
121
|
+
- `String` - *xpub*, root pubkey of the key.
|
122
|
+
- `String` - *file*, path to the file of key.
|
123
|
+
|
124
|
+
Optional:
|
125
|
+
|
126
|
+
- `String` - *mnemonic*, mnemonic of the key, exist when the request mnemonic is null.
|
127
|
+
|
128
|
+
##### Example
|
129
|
+
|
130
|
+
create key by random pattern:
|
131
|
+
|
132
|
+
```ruby
|
133
|
+
bytom_client.keys.create_key(
|
134
|
+
alias_name: 'dayone',
|
135
|
+
password: '123456',
|
136
|
+
language: 'en'
|
137
|
+
)
|
138
|
+
|
139
|
+
# Response example
|
140
|
+
{
|
141
|
+
"status" =>"success",
|
142
|
+
"data" => {
|
143
|
+
"alias" =>"dayone",
|
144
|
+
"xpub" =>"f788208af6d16ce5ae523256caedf8b9463f9cdfa33f58aa1ffde0b673c98769ceb9299052bddd6c8436d749500198635d77682eae565378ac16d1b9ba574e5f",
|
145
|
+
"file" =>"/Path/to/Library/Application Support/Bytom/keystore/UTC--2019-01-16T11-34-36.239356000Z--7b900b8e-2b3c-4136-857b-ded76257c7c5",
|
146
|
+
"mnemonic" =>"knock rocket siren eye skate adapt spatial flight latin purse tuna lunar"
|
147
|
+
}
|
148
|
+
}
|
149
|
+
```
|
150
|
+
|
151
|
+
create key by specified mnemonic:
|
152
|
+
|
153
|
+
```ruby
|
154
|
+
bytom_client = Bytom::Client.new(base_url: 'http://127.0.0.1:9888')
|
155
|
+
mnemonic = "please observe raw beauty blue sea believe then boat float beyond position"
|
156
|
+
bytom_client.keys.create_key(
|
157
|
+
alias_name: 'dayone2',
|
158
|
+
password: '123456',
|
159
|
+
language: 'en',
|
160
|
+
mnemonic: mnemonic
|
161
|
+
)
|
162
|
+
|
163
|
+
# Response example
|
164
|
+
{
|
165
|
+
"status" =>"success",
|
166
|
+
"data" => {
|
167
|
+
"alias" =>"dayone2",
|
168
|
+
"xpub" =>"7d23d604dc03913d6719fa0fa3b2d9978beef3b4a8c81d7770ec83d2335f7860e8f081009094679ef66381d6a3a4d08063bc48666cb41479924fd4a5b41bf8f9",
|
169
|
+
"file" =>"/Users/xiudong/Library/Application Support/Bytom/keystore/UTC--2019-01-16T11-35-22.778202000Z--e01d4fc8-ac16-4ddd-a1b7-b6bf4df623c9",
|
170
|
+
"mnemonic" =>"trap column derive melody okay angle cousin brother smoke trend misery sugar"
|
171
|
+
}
|
172
|
+
}
|
173
|
+
```
|
174
|
+
|
175
|
+
|
176
|
+
|
177
|
+
------
|
178
|
+
|
179
|
+
#### list-keys
|
180
|
+
|
181
|
+
Returns the list of all available keys.
|
182
|
+
|
183
|
+
##### Parameters
|
184
|
+
|
185
|
+
none
|
186
|
+
|
187
|
+
##### Returns
|
188
|
+
|
189
|
+
- `Array of Object`, keys owned by the client.
|
190
|
+
- `Object`:
|
191
|
+
- `String` - *alias*, name of the key.
|
192
|
+
- `String` - *xpub*, pubkey of the key.
|
193
|
+
|
194
|
+
##### Example
|
195
|
+
|
196
|
+
```ruby
|
197
|
+
bytom_client.keys.list_keys
|
198
|
+
|
199
|
+
# Response data
|
200
|
+
[
|
201
|
+
{
|
202
|
+
"alias": "dayone",
|
203
|
+
"xpub": "a7dae957c2d35b42efe7e6871cf5a75ebd2a0d0e51caffe767db42d3e6d69dbe211d1ca492ecf05908fe6fa625ad61b3253375ea744c9442dd5551613ba50aea",
|
204
|
+
"file": "/Path/To/Library/Bytom/keystore/UTC--2018-04-21T02-35-15.035935116Z--4f2b8bd7-0576-4b82-8941-6cc6da05efe3"
|
205
|
+
},
|
206
|
+
{
|
207
|
+
"alias": "dayone2",
|
208
|
+
"xpub": "d30a810e88532f73816b7b5007d413cbd21e526ae9159023e5262511893adc1526b8eacd691b27c080201d7d79336a4f3d2cb4c167d997821cad445765916254",
|
209
|
+
"file": "/Path/To/Library/Bytom/keystore/UTC--2018-04-22T06-30-27.609315219Z--0e34293c-8856-4f5f-b934-37456a3820fa"
|
210
|
+
}
|
211
|
+
]
|
212
|
+
```
|
213
|
+
|
214
|
+
----
|
215
|
+
|
216
|
+
#### `update-key-alias`
|
217
|
+
|
218
|
+
Update alias for the existed key.
|
219
|
+
|
220
|
+
##### Parameters
|
221
|
+
|
222
|
+
`Object`:
|
223
|
+
|
224
|
+
- `String` - *xpub*, pubkey of the key.
|
225
|
+
- `String` - *new_alias*, new alias of the key.
|
226
|
+
|
227
|
+
##### Returns
|
228
|
+
|
229
|
+
none if the key alias is updated successfully.
|
230
|
+
|
231
|
+
##### Example
|
232
|
+
|
233
|
+
```ruby
|
234
|
+
xpub = 'f788208af6d16ce5ae523256caedf8b9463f9cdfa33f58aa1ffde0b673c98769ceb9299052bddd6c8436d749500198635d77682eae565378ac16d1b9ba574e5f'
|
235
|
+
bytom_client.keys.update_key_alias(xpub: xpub, new_alias: 'BitDayOne')
|
236
|
+
|
237
|
+
```
|
238
|
+
|
239
|
+
----
|
240
|
+
|
241
|
+
#### `delete-key`
|
242
|
+
|
243
|
+
Delete existed key, please make sure that there is no balance in the related accounts.
|
244
|
+
|
245
|
+
##### Parameters
|
246
|
+
|
247
|
+
`Object`:
|
248
|
+
|
249
|
+
- `String` - *xpub*, pubkey of the key.
|
250
|
+
- `String` - *password*, password of the key.
|
251
|
+
|
252
|
+
##### Returns
|
253
|
+
|
254
|
+
none if the key is deleted successfully.
|
255
|
+
|
256
|
+
##### Example
|
257
|
+
|
258
|
+
```ruby
|
259
|
+
xpub = 'f788208af6d16ce5ae523256caedf8b9463f9cdfa33f58aa1ffde0b673c98769ceb9299052bddd6c8436d749500198635d77682eae565378ac16d1b9ba574e5f'
|
260
|
+
bytom_client.keys.delete_key(xpub: xpub, password: '123456')
|
261
|
+
```
|
262
|
+
|
263
|
+
----
|
264
|
+
|
265
|
+
#### `check-key-password`
|
266
|
+
|
267
|
+
Check key password.
|
268
|
+
|
269
|
+
##### Parameters
|
270
|
+
|
271
|
+
`Object`:
|
272
|
+
|
273
|
+
- `String` - *xpub*, pubkey of the key.
|
274
|
+
- `String` - *password*, password of the key.
|
275
|
+
|
276
|
+
##### Returns
|
277
|
+
|
278
|
+
`Object`:
|
279
|
+
|
280
|
+
- `Boolean` - *check_result*, result of check key password, true is check successfully, otherwise is false.
|
281
|
+
|
282
|
+
##### Example
|
283
|
+
|
284
|
+
```ruby
|
285
|
+
xpub = 'f788208af6d16ce5ae523256caedf8b9463f9cdfa33f58aa1ffde0b673c98769ceb9299052bddd6c8436d749500198635d77682eae565378ac16d1b9ba574e5f'
|
286
|
+
bytom_client.keys.check_key_password(xpub: xpub,password: '123456')
|
287
|
+
# Response data
|
288
|
+
{"status"=>"success", "data"=>{"check_result"=>true}}
|
289
|
+
```
|
290
|
+
|
291
|
+
----
|
292
|
+
|
293
|
+
#### `reset-key-password`
|
294
|
+
|
295
|
+
Reset key password.
|
296
|
+
|
297
|
+
##### Parameters
|
298
|
+
|
299
|
+
`Object`:
|
300
|
+
|
301
|
+
- `String` - *xpub*, pubkey of the key.
|
302
|
+
- `String` - *old_password*, old password of the key.
|
303
|
+
- `String` - *new_password*, new password of the key.
|
304
|
+
|
305
|
+
##### Returns
|
306
|
+
|
307
|
+
`Object`:
|
308
|
+
|
309
|
+
- `Boolean` - *changed*, result of reset key password, true is reset successfully, otherwise is false.
|
310
|
+
|
311
|
+
##### Example
|
312
|
+
|
313
|
+
```ruby
|
314
|
+
xpub = 'f788208af6d16ce5ae523256caedf8b9463f9cdfa33f58aa1ffde0b673c98769ceb9299052bddd6c8436d749500198635d77682eae565378ac16d1b9ba574e5f'
|
315
|
+
bytom_client.keys.reset_key_password(xpub: xpub, old_password: '123456', new_password: '12345678')
|
316
|
+
|
317
|
+
# Response data
|
318
|
+
{"status"=>"success", "data"=>{"changed"=>true}}
|
319
|
+
```
|
320
|
+
|
321
|
+
----
|
322
|
+
|
323
|
+
#### `create-account`
|
324
|
+
|
325
|
+
Create account to manage addresses. single sign account contain only one root_xpubs and quorum; however multi sign account contain many number of root_xpubs and quorum, quorum is the number of verify signature, the range is [1, len(root_xpubs)].
|
326
|
+
|
327
|
+
##### Parameters
|
328
|
+
|
329
|
+
`Object`:
|
330
|
+
|
331
|
+
- `Array of String` - *root_xpubs*, pubkey array.
|
332
|
+
- `String` - *alias*, name of the account.
|
333
|
+
- `Integer` - *quorum*, the default value is `1`, threshold of keys that must sign a transaction to spend asset units controlled by the account.
|
334
|
+
|
335
|
+
Optional:
|
336
|
+
|
337
|
+
- `String` - *access_token*, if optional when creating account locally. However, if you want to create account remotely, it's indispensable.
|
338
|
+
|
339
|
+
##### Returns
|
340
|
+
|
341
|
+
`Object`:
|
342
|
+
|
343
|
+
- `String` - *id*, account id.
|
344
|
+
- `String` - *alias*, name of account.
|
345
|
+
- `Integer` - *key_index*, key index of account.
|
346
|
+
- `Integer` - *quorom*, threshold of keys that must sign a transaction to spend asset units controlled by the account.
|
347
|
+
- `Array of Object` - *xpubs*, pubkey array.
|
348
|
+
|
349
|
+
##### Example
|
350
|
+
|
351
|
+
```ruby
|
352
|
+
root_xpubs = ['f788208af6d16ce5ae523256caedf8b9463f9cdfa33f58aa1ffde0b673c98769ceb9299052bddd6c8436d749500198635d77682eae565378ac16d1b9ba574e5f']
|
353
|
+
bytom_client.accounts.create_account(
|
354
|
+
root_xpubs: root_xpubs,
|
355
|
+
alias_name: 'dayone_account_001',
|
356
|
+
quorum: 1
|
357
|
+
)
|
358
|
+
|
359
|
+
# Response data
|
360
|
+
{
|
361
|
+
"status" =>"success",
|
362
|
+
"data" => {
|
363
|
+
"id" =>"0NO14DLP00A02",
|
364
|
+
"alias" =>"dayone_account_001",
|
365
|
+
"xpubs" => [
|
366
|
+
"f788208af6d16ce5ae523256caedf8b9463f9cdfa33f58aa1ffde0b673c98769ceb9299052bddd6c8436d749500198635d77682eae565378ac16d1b9ba574e5f"
|
367
|
+
],
|
368
|
+
"quorum" =>1,
|
369
|
+
"key_index" =>1,
|
370
|
+
"derive_rule" =>1
|
371
|
+
}
|
372
|
+
}
|
373
|
+
```
|
374
|
+
|
375
|
+
----
|
376
|
+
|
377
|
+
#### `list-accounts`
|
378
|
+
|
379
|
+
Returns the list of all available accounts.
|
380
|
+
|
381
|
+
##### Parameters
|
382
|
+
|
383
|
+
Optional:
|
384
|
+
|
385
|
+
- `String` - *id*, account id.
|
386
|
+
- `String` - *alias*, name of account.
|
387
|
+
|
388
|
+
##### Returns
|
389
|
+
|
390
|
+
- `Array of Object`, account array.
|
391
|
+
- `Object`:
|
392
|
+
- `String` - *id*, account id.
|
393
|
+
- `String` - *alias*, name of account.
|
394
|
+
- `Integer` - *key_index*, key index of account.
|
395
|
+
- `Integer` - *quorom*, threshold of keys that must sign a transaction to spend asset units controlled by the account.
|
396
|
+
- `Array of Object` - *xpubs*, pubkey array.
|
397
|
+
|
398
|
+
##### Example
|
399
|
+
|
400
|
+
list all the available accounts:
|
401
|
+
|
402
|
+
```js
|
403
|
+
# Usage 1
|
404
|
+
bytom_client.accounts.list_accounts
|
405
|
+
# Usage 2
|
406
|
+
bytom_client.accounts.list_accounts(id: "0NO155F1G0A0A")
|
407
|
+
# Usage 3
|
408
|
+
bytom_client.accounts.list_accounts(alias_name:"dayone_account_005")
|
409
|
+
|
410
|
+
// Result
|
411
|
+
{
|
412
|
+
"status" = >"success",
|
413
|
+
"data" = >[{
|
414
|
+
"id" = >"0NMKVC90G0A02",
|
415
|
+
"alias" = >"test",
|
416
|
+
"xpubs" = >["c8d4487f0fc13287235262ec5005a7519e5d376c66900bf4c58dd2e1827ce5224fd228e5b64bbd5c66c6d5cf69226cb1e7c83ba0d4f11eed8c429dc33fd1d95c"],
|
417
|
+
"quorum" = >1,
|
418
|
+
"key_index" = >1,
|
419
|
+
"derive_rule" = >1
|
420
|
+
}]
|
421
|
+
}
|
422
|
+
```
|
423
|
+
|
424
|
+
----
|
425
|
+
|
426
|
+
#### `update-account-alias`
|
427
|
+
|
428
|
+
Update alias for the existed account.
|
429
|
+
|
430
|
+
##### Parameters
|
431
|
+
|
432
|
+
`Object`: account_alias | account_id
|
433
|
+
|
434
|
+
- `String` - *new_alias*, new alias of account.
|
435
|
+
|
436
|
+
optional:
|
437
|
+
|
438
|
+
- `String` - *account_alias*, alias of account.
|
439
|
+
- `String` - *account_id*, id of account.
|
440
|
+
|
441
|
+
|
442
|
+
##### Returns
|
443
|
+
|
444
|
+
none if the account alias is updated successfully.
|
445
|
+
|
446
|
+
##### Example
|
447
|
+
|
448
|
+
```ruby
|
449
|
+
# update by account_id
|
450
|
+
bytom_client.accounts.update_account_alias_by_id(
|
451
|
+
account_id: "0NO155F1G0A0A",
|
452
|
+
new_alias: 'new_dayone_account_005'
|
453
|
+
)
|
454
|
+
# update by account_alias
|
455
|
+
bytom_client.accounts.update_account_alias_by_alias(
|
456
|
+
account_alias: "new_dayone_account_005",
|
457
|
+
new_alias: 'new_dayone_account_005_re'
|
458
|
+
)
|
459
|
+
|
460
|
+
```
|
461
|
+
|
462
|
+
----
|
463
|
+
|
464
|
+
#### `delete-account`
|
465
|
+
|
466
|
+
Delete existed account, please make sure that there is no balance in the related addresses.
|
467
|
+
|
468
|
+
##### Parameters
|
469
|
+
|
470
|
+
`Object`: account_alias | account_id
|
471
|
+
|
472
|
+
optional:
|
473
|
+
|
474
|
+
- `String` - *account_alias*, alias of account.
|
475
|
+
- `String` - *account_id*, id of account.
|
476
|
+
|
477
|
+
##### Returns
|
478
|
+
|
479
|
+
none if the account is deleted successfully.
|
480
|
+
|
481
|
+
##### Example
|
482
|
+
|
483
|
+
```ruby
|
484
|
+
# delete account by id
|
485
|
+
bytom_client.accounts.delete_account_by_id(account_id: "0NO155F1G0A0A")
|
486
|
+
# detelte account by alias name
|
487
|
+
bytom_client.accounts.delete_account_by_alias(account_alias: 'dayone_account_004')
|
488
|
+
|
489
|
+
```
|
490
|
+
|
491
|
+
----
|
492
|
+
|
493
|
+
#### `create-account-receiver`
|
494
|
+
|
495
|
+
create address and control program, the address and control program is are one to one relationship. in build-transaction API, receiver is address when action type is control_address, and receiver is control program when action type is control_program, they are the same result.
|
496
|
+
|
497
|
+
##### Parameters
|
498
|
+
|
499
|
+
`Object`: account_alias | account_id
|
500
|
+
|
501
|
+
optional:
|
502
|
+
|
503
|
+
- `String` - *account_alias*, alias of account.
|
504
|
+
- `String` - *account_id*, id of account.
|
505
|
+
|
506
|
+
##### Returns
|
507
|
+
|
508
|
+
`Object`:
|
509
|
+
|
510
|
+
- `String` - *address*, address of account.
|
511
|
+
- `String` - *control_program*, control program of account.
|
512
|
+
|
513
|
+
##### Example
|
514
|
+
|
515
|
+
```ruby
|
516
|
+
// Usage 1
|
517
|
+
bytom_client.accounts.create_account_receiver(account_id: '0NO14DLP00A02')
|
518
|
+
// Usage 2
|
519
|
+
bytom_client.accounts.create_account_receiver(account_alias: 'dayone_account_001')
|
520
|
+
// Usage 3
|
521
|
+
bytom_client.accounts.create_account_receiver(account_id: '0NO14DLP00A02', account_alias: 'dayone_account_001')
|
522
|
+
|
523
|
+
# Response data
|
524
|
+
{
|
525
|
+
"status"=>"success",
|
526
|
+
"data"=>{
|
527
|
+
"control_program"=>"00145b0c433fd9d2868742d268a1922ea99b7295ef4c", "address"=>"tm1qtvxyx07e62rgwskjdzseyt4fndeftm6vmxa8k4"
|
528
|
+
}
|
529
|
+
}
|
530
|
+
```
|
531
|
+
----
|
532
|
+
|
533
|
+
#### `list-addresses`
|
534
|
+
|
535
|
+
Returns the sub list of all available addresses by account.
|
536
|
+
|
537
|
+
##### Parameters
|
538
|
+
|
539
|
+
- `String` - *account_alias*, alias of account.
|
540
|
+
- `String` - *account_id*, id of account.
|
541
|
+
- `Integer` - *from*, the start position of first address
|
542
|
+
- `Integer` - *count*, the number of returned
|
543
|
+
|
544
|
+
##### Returns
|
545
|
+
|
546
|
+
- `Array of Object`, account address array.
|
547
|
+
- `Object`:
|
548
|
+
- `String` - *account_alias*, alias of account.
|
549
|
+
- `String` - *account_id*, id of account.
|
550
|
+
- `String` - *address*, address of account.
|
551
|
+
- `Boolean` - *change*, whether the account address is change.
|
552
|
+
|
553
|
+
##### Example
|
554
|
+
|
555
|
+
list three addresses from first position by account_id or account_alias:
|
556
|
+
|
557
|
+
```ruby
|
558
|
+
bytom_client.address.list_addresses(
|
559
|
+
account_alias: 'dayone_account_001',
|
560
|
+
account_id: '0NO14DLP00A02',
|
561
|
+
from: 0,
|
562
|
+
count: 3
|
563
|
+
)
|
564
|
+
|
565
|
+
# Response data
|
566
|
+
{
|
567
|
+
"status" =>"success",
|
568
|
+
"data" => [
|
569
|
+
{
|
570
|
+
"account_alias" =>"dayone_account_001",
|
571
|
+
"account_id" =>"0NO14DLP00A02",
|
572
|
+
"address" =>"tm1q20gt090mcfz7cn0urg6dy22ec327deseew7vtz",
|
573
|
+
"control_program" =>"001453d0b795fbc245ec4dfc1a34d22959c455e6e619",
|
574
|
+
"change" =>false,
|
575
|
+
"key_index" =>1
|
576
|
+
},
|
577
|
+
{
|
578
|
+
"account_alias" =>"dayone_account_001",
|
579
|
+
"account_id" =>"0NO14DLP00A02",
|
580
|
+
"address" =>"tm1qlhr257v5y03j6gxw4z9wqqnteglv2xdf6jcc02",
|
581
|
+
"control_program" =>"0014fdc6aa799423e32d20cea88ae0026bca3ec519a9",
|
582
|
+
"change" =>false,
|
583
|
+
"key_index" =>2
|
584
|
+
},
|
585
|
+
{
|
586
|
+
"account_alias" =>"dayone_account_001",
|
587
|
+
"account_id" =>"0NO14DLP00A02",
|
588
|
+
"address" =>"tm1q3qtu353ts3ct3ny53mrp07ye9c8qd2ljk9rexm",
|
589
|
+
"control_program" =>"00148817c8d22b8470b8cc948ec617f8992e0e06abf2",
|
590
|
+
"change" =>false,
|
591
|
+
"key_index" =>3
|
592
|
+
}
|
593
|
+
]
|
594
|
+
}
|
595
|
+
```
|
596
|
+
|
597
|
+
----
|
598
|
+
|
599
|
+
#### `validate-address`
|
600
|
+
|
601
|
+
Verify the address is valid, and judge the address is own.
|
602
|
+
|
603
|
+
##### Parameters
|
604
|
+
|
605
|
+
`Object`:
|
606
|
+
|
607
|
+
- `string` - *address*, address of account.
|
608
|
+
|
609
|
+
##### Returns
|
610
|
+
|
611
|
+
`Object`:
|
612
|
+
|
613
|
+
- `Boolean` - *valid*, whether the account address is valid.
|
614
|
+
- `Boolean` - *is_local*, whether the account address is local.
|
615
|
+
|
616
|
+
##### Example
|
617
|
+
|
618
|
+
check whether the address is valid or not.
|
619
|
+
|
620
|
+
```ruby
|
621
|
+
bytom_client.address.validate_address(
|
622
|
+
address: 'tm1q3qtu353ts3ct3ny53mrp07ye9c8qd2ljk9rexm'
|
623
|
+
)
|
624
|
+
|
625
|
+
# Response data
|
626
|
+
{
|
627
|
+
"status" = >"success",
|
628
|
+
"data" = >{
|
629
|
+
"valid" = >true,
|
630
|
+
"is_local" = >true
|
631
|
+
}
|
632
|
+
}
|
633
|
+
```
|
634
|
+
|
635
|
+
----
|
636
|
+
|
637
|
+
#### `get-mining-address`
|
638
|
+
|
639
|
+
Query the current mining address.
|
640
|
+
|
641
|
+
##### Parameters
|
642
|
+
|
643
|
+
none
|
644
|
+
|
645
|
+
##### Returns
|
646
|
+
|
647
|
+
`Object`:
|
648
|
+
|
649
|
+
- `String` - *mining_address*, the current mining address being used.
|
650
|
+
|
651
|
+
##### Example
|
652
|
+
|
653
|
+
```ruby
|
654
|
+
bytom_client.address.get_mining_address
|
655
|
+
# Response data
|
656
|
+
{
|
657
|
+
"status" = >"success",
|
658
|
+
"data" = >{
|
659
|
+
"mining_address" = >"tm1qwq7xrl2mkta0eyp3y877y6p8ceqd3gzt4sn7lx"
|
660
|
+
}
|
661
|
+
}
|
662
|
+
```
|
663
|
+
|
664
|
+
----
|
665
|
+
|
666
|
+
#### `set-mining-address`
|
667
|
+
|
668
|
+
Set the current mining address, no matter whethere the address is a local one. It returns an error message if the address format is incorrect.
|
669
|
+
|
670
|
+
##### Parameters
|
671
|
+
|
672
|
+
`Object`:
|
673
|
+
|
674
|
+
- `String` - *mining_address*, mining address to set.
|
675
|
+
|
676
|
+
##### Returns
|
677
|
+
|
678
|
+
`Object`:
|
679
|
+
|
680
|
+
- `String` - *mining_address*, the new mining address.
|
681
|
+
|
682
|
+
##### Example
|
683
|
+
|
684
|
+
```ruby
|
685
|
+
bytom_client.address.set_mining_address(
|
686
|
+
mining_address: 'tm1q3qtu353ts3ct3ny53mrp07ye9c8qd2ljk9rexm'
|
687
|
+
)
|
688
|
+
|
689
|
+
# Response data
|
690
|
+
{
|
691
|
+
"status" = >"success",
|
692
|
+
"data" = >{
|
693
|
+
"mining_address" = >"tm1q8q2594zptqz4mjhdvvmww4m5yau3tl7r8gnhp9"
|
694
|
+
}
|
695
|
+
}
|
696
|
+
```
|
697
|
+
|
698
|
+
----
|
699
|
+
|
700
|
+
#### `get-coinbase-arbitrary`
|
701
|
+
|
702
|
+
Get coinbase arbitrary.
|
703
|
+
|
704
|
+
##### Parameters
|
705
|
+
|
706
|
+
none
|
707
|
+
|
708
|
+
##### Returns
|
709
|
+
|
710
|
+
`Object`:
|
711
|
+
|
712
|
+
- `String` - *arbitrary*, the abitrary data append to coinbase, in hexdecimal format. (The full coinbase data for a block will be `0x00`&block_height&abitrary.)
|
713
|
+
|
714
|
+
##### Example
|
715
|
+
|
716
|
+
```ruby
|
717
|
+
bytom_client.coinbase.get_coinbase_arbitrary
|
718
|
+
# Response data
|
719
|
+
{"status"=>"success", "data"=>{"arbitrary"=>"ff"}}
|
720
|
+
```
|
721
|
+
|
722
|
+
----
|
723
|
+
|
724
|
+
#### `set-coinbase-arbitrary`
|
725
|
+
|
726
|
+
Set coinbase arbitrary.
|
727
|
+
|
728
|
+
##### Parameters
|
729
|
+
|
730
|
+
`Object`:
|
731
|
+
|
732
|
+
- `String` - *arbitrary*, the abitrary data to be appended to coinbase, in hexdecimal format.
|
733
|
+
|
734
|
+
##### Returns
|
735
|
+
|
736
|
+
`Object`:
|
737
|
+
|
738
|
+
- `String` - *arbitrary*, the abitrary data being appended to coinbase, in hexdecimal format. (The full coinbase data for a block will be `0x00`&block_height&abitrary.)
|
739
|
+
|
740
|
+
##### Example
|
741
|
+
|
742
|
+
```ruby
|
743
|
+
bytom_client.coinbase.set_coinbase_arbitrary(arbitrary: 'ff')
|
744
|
+
# Response data
|
745
|
+
{"status"=>"success", "data"=>{"arbitrary"=>"ff"}}
|
746
|
+
```
|
747
|
+
|
748
|
+
----
|
749
|
+
|
750
|
+
#### `list-pubkeys`
|
751
|
+
|
752
|
+
Returns the list of all available pubkeys by account.
|
753
|
+
|
754
|
+
##### Parameters
|
755
|
+
|
756
|
+
`Object`: account_alias | account_id
|
757
|
+
|
758
|
+
optional:
|
759
|
+
|
760
|
+
- `String` - *account_alias*, alias of account.
|
761
|
+
- `String` - *account_id*, id of account.
|
762
|
+
- `string` - *public_key*, public key.
|
763
|
+
|
764
|
+
##### Returns
|
765
|
+
|
766
|
+
`Object`:
|
767
|
+
|
768
|
+
- `string` - *root_xpub*, root xpub.
|
769
|
+
- `Array of Object` -*pubkey_infos*, public key array.
|
770
|
+
- `String` - *pubkey*, public key.
|
771
|
+
- `Object` - *derivation_path*, derivated path for root xpub.
|
772
|
+
|
773
|
+
##### Example
|
774
|
+
|
775
|
+
```ruby
|
776
|
+
bytom_client.keys.list_pubkeys(account_id: '0NO14DLP00A02')
|
777
|
+
bytom_client.keys.list_pubkeys(account_alias: 'dayone_account_001')
|
778
|
+
|
779
|
+
# Response data
|
780
|
+
{
|
781
|
+
"status" = >"success",
|
782
|
+
"data" = >{
|
783
|
+
"root_xpub" = >"c8d4487f0fc13287235262ec5005a7519e5d376c66900bf4c58dd2e1827ce5224fd228e5b64bbd5c66c6d5cf69226cb1e7c83ba0d4f11eed8c429dc33fd1d95c",
|
784
|
+
"pubkey_infos" = >[{
|
785
|
+
"pubkey" = >"6444be58a4c48a182d6e54fbf10abec0b311f670e779c7374ee24abe9e803ca7",
|
786
|
+
"derivation_path" = >["2c000000", "99000000", "02000000", "00000000", "01000000"]
|
787
|
+
},
|
788
|
+
{
|
789
|
+
"pubkey" = >"ce21fac4ab032efccecc3f6e1408472a46e025bfa21234b96d49db3522245482",
|
790
|
+
"derivation_path" = >["2c000000", "99000000", "02000000", "00000000", "02000000"]
|
791
|
+
},
|
792
|
+
{
|
793
|
+
"pubkey" = >"e55a4aad4cc3acc4968bbb48758533b6fb87fa16c377cd9562d142ebbd9cdea6",
|
794
|
+
"derivation_path" = >["2c000000", "99000000", "02000000", "00000000", "03000000"]
|
795
|
+
}]
|
796
|
+
}
|
797
|
+
}
|
798
|
+
|
799
|
+
```
|
800
|
+
|
801
|
+
----
|
802
|
+
|
803
|
+
#### `create-asset`
|
804
|
+
|
805
|
+
Create asset definition, it prepares for the issuance of asset.
|
806
|
+
|
807
|
+
##### Parameters
|
808
|
+
|
809
|
+
`Object`:
|
810
|
+
|
811
|
+
- `String` - *alias*, name of the asset.
|
812
|
+
- `Object` - *definition*, definition of asset.
|
813
|
+
|
814
|
+
Optional:(please pick one form the following two ways)
|
815
|
+
|
816
|
+
- `Array of String` - *root_xpubs*, xpub array.
|
817
|
+
- `Integer` - *quorum*, the default value is `1`, threshold of keys that must sign a transaction to spend asset units controlled by the account.
|
818
|
+
|
819
|
+
or
|
820
|
+
|
821
|
+
- `String` - *issuance_program*, user-defined contract program.
|
822
|
+
|
823
|
+
##### Returns
|
824
|
+
|
825
|
+
`Object`:
|
826
|
+
|
827
|
+
- `String` - *id*, asset id.
|
828
|
+
- `String` - *alias*, name of the asset.
|
829
|
+
- `String` - *issuance_program*, control program of the issuance of asset.
|
830
|
+
- `Array of Object` - *keys*, information of asset pubkey.
|
831
|
+
- `String` - *definition*, definition of asset.
|
832
|
+
- `Integer` - *quorum*, threshold of keys that must sign a transaction to spend asset units controlled by the account.
|
833
|
+
|
834
|
+
##### Example
|
835
|
+
|
836
|
+
create asset by xpubs:
|
837
|
+
|
838
|
+
```ruby
|
839
|
+
# create asset by xpubs:
|
840
|
+
bytom_client.asset.create_asset(
|
841
|
+
alias_name: 'Property01',
|
842
|
+
root_xpubs: ['f788208af6d16ce5ae523256caedf8b9463f9cdfa33f58aa1ffde0b673c98769ceb9299052bddd6c8436d749500198635d77682eae565378ac16d1b9ba574e5f'],
|
843
|
+
quorum: 1
|
844
|
+
)
|
845
|
+
# Response data
|
846
|
+
{
|
847
|
+
"status" =>"success",
|
848
|
+
"data" => {
|
849
|
+
"id" =>"41b2c7a02e610c9e7117e5b2407573b953b3ebbec90302cf217ecaf134851622",
|
850
|
+
"alias" =>"PROPERTY01",
|
851
|
+
"issuance_program" =>"ae204c09d66bfad30f9017ad2283484f3931810bfe7821f75427cb1417bac08b48885151ad",
|
852
|
+
"keys" => [
|
853
|
+
{
|
854
|
+
"root_xpub" =>"f788208af6d16ce5ae523256caedf8b9463f9cdfa33f58aa1ffde0b673c98769ceb9299052bddd6c8436d749500198635d77682eae565378ac16d1b9ba574e5f",
|
855
|
+
"asset_pubkey" =>"4c09d66bfad30f9017ad2283484f3931810bfe7821f75427cb1417bac08b48881c21cf8627fbe7063b0acaa760dd4cd310c2b5dd39244ab21d92ea3a5c273d7f",
|
856
|
+
"asset_derivation_path" => [
|
857
|
+
"000300000000000000"
|
858
|
+
]
|
859
|
+
}
|
860
|
+
],
|
861
|
+
"quorum" =>1,
|
862
|
+
"definition" => {
|
863
|
+
|
864
|
+
}
|
865
|
+
}
|
866
|
+
}
|
867
|
+
|
868
|
+
```
|
869
|
+
|
870
|
+
create asset by issuance_program:
|
871
|
+
|
872
|
+
```ruby
|
873
|
+
# create asset by issuance_program:
|
874
|
+
bytom_client.asset.create_asset(
|
875
|
+
alias_name: 'TESTASSET1',
|
876
|
+
issuance_program: '20e9108d3ca8049800727f6a3505b3a2710dc579405dde03c250f16d9a7e1e6e78160014c5a5b563c4623018557fb299259542b8739f6bc20163201e074b22ed7ae8470c7ba5d8a7bc95e83431a753a17465e8673af68a82500c22741a547a6413000000007b7b51547ac1631a000000547a547aae7cac0090',
|
877
|
+
definition: {
|
878
|
+
name: "TESTASSET1",
|
879
|
+
symbol: "TESTASSET1",
|
880
|
+
decimals: 8,
|
881
|
+
description: {}
|
882
|
+
}
|
883
|
+
)
|
884
|
+
|
885
|
+
# Response data
|
886
|
+
{
|
887
|
+
"status" =>"success",
|
888
|
+
"data" => {
|
889
|
+
"id" =>"8ce2e19c1677261b0777619490b8e67311ae2cac7c5bd943e269f9d78f809dcb",
|
890
|
+
"alias" =>"TESTASSET1",
|
891
|
+
"issuance_program" =>"20e9108d3ca8049800727f6a3505b3a2710dc579405dde03c250f16d9a7e1e6e78160014c5a5b563c4623018557fb299259542b8739f6bc20163201e074b22ed7ae8470c7ba5d8a7bc95e83431a753a17465e8673af68a82500c22741a547a6413000000007b7b51547ac1631a000000547a547aae7cac0090",
|
892
|
+
"keys" =>nil,
|
893
|
+
"quorum" =>0,
|
894
|
+
"definition" => {
|
895
|
+
"decimals" =>8,
|
896
|
+
"description" => {
|
897
|
+
|
898
|
+
},
|
899
|
+
"name" =>"TESTASSET1",
|
900
|
+
"symbol" =>"TESTASSET1"
|
901
|
+
}
|
902
|
+
}
|
903
|
+
}
|
904
|
+
|
905
|
+
```
|
906
|
+
|
907
|
+
----
|
908
|
+
|
909
|
+
#### `get-asset`
|
910
|
+
|
911
|
+
Query detail asset by asset ID.
|
912
|
+
|
913
|
+
##### Parameters
|
914
|
+
|
915
|
+
`Object`:
|
916
|
+
|
917
|
+
- `String` - *id*, id of asset.
|
918
|
+
|
919
|
+
##### Returns
|
920
|
+
|
921
|
+
`Object`:
|
922
|
+
|
923
|
+
- `String` - *id*, asset id.
|
924
|
+
- `String` - *alias*, name of the asset.
|
925
|
+
- `String` - *issuance_program*, control program of the issuance of asset.
|
926
|
+
- `Integer` - *key_index*, index of key for xpub.
|
927
|
+
- `Integer` - *quorum*, threshold of keys that must sign a transaction to spend asset units controlled by the account.
|
928
|
+
- `Array of Object` - *xpubs*, pubkey array.
|
929
|
+
- `String` - *type*, type of asset.
|
930
|
+
- `Integer` - *vm_version*, version of VM.
|
931
|
+
- `String` - *raw_definition_byte*, byte of asset definition.
|
932
|
+
- `Object` - *definition*, description of asset.
|
933
|
+
|
934
|
+
##### Example
|
935
|
+
|
936
|
+
get asset by assetID.
|
937
|
+
|
938
|
+
```ruby
|
939
|
+
bytom_client.asset.get_asset(
|
940
|
+
id: '41b2c7a02e610c9e7117e5b2407573b953b3ebbec90302cf217ecaf134851622'
|
941
|
+
)
|
942
|
+
|
943
|
+
# Response data
|
944
|
+
{
|
945
|
+
"status" =>"success",
|
946
|
+
"data" => {
|
947
|
+
"type" =>"asset",
|
948
|
+
"xpubs" => [
|
949
|
+
"f788208af6d16ce5ae523256caedf8b9463f9cdfa33f58aa1ffde0b673c98769ceb9299052bddd6c8436d749500198635d77682eae565378ac16d1b9ba574e5f"
|
950
|
+
],
|
951
|
+
"quorum" =>1,
|
952
|
+
"key_index" =>3,
|
953
|
+
"derive_rule" =>0,
|
954
|
+
"id" =>"41b2c7a02e610c9e7117e5b2407573b953b3ebbec90302cf217ecaf134851622",
|
955
|
+
"alias" =>"PROPERTY01",
|
956
|
+
"vm_version" =>1,
|
957
|
+
"issue_program" =>"ae204c09d66bfad30f9017ad2283484f3931810bfe7821f75427cb1417bac08b48885151ad",
|
958
|
+
"raw_definition_byte" =>"7b7d",
|
959
|
+
"definition" => {
|
960
|
+
|
961
|
+
}
|
962
|
+
}
|
963
|
+
}
|
964
|
+
```
|
965
|
+
|
966
|
+
----
|
967
|
+
|
968
|
+
#### `list-assets`
|
969
|
+
|
970
|
+
Returns the list of all available assets.
|
971
|
+
|
972
|
+
##### Parameters
|
973
|
+
|
974
|
+
none
|
975
|
+
|
976
|
+
##### Returns
|
977
|
+
|
978
|
+
- `Array of Object`, asset array.
|
979
|
+
- `Object`:
|
980
|
+
- `String` - *id*, asset id.
|
981
|
+
- `String` - *alias*, name of the asset.
|
982
|
+
- `String` - *issuance_program*, control program of the issuance of asset.
|
983
|
+
- `Integer` - *key_index*, index of key for xpub.
|
984
|
+
- `Integer` - *quorum*, threshold of keys that must sign a transaction to spend asset units controlled by the account.
|
985
|
+
- `Array of Object` - *xpubs*, pubkey array.
|
986
|
+
- `String` - *type*, type of asset.
|
987
|
+
- `Integer` - *vm_version*, version of VM.
|
988
|
+
- `String` - *raw_definition_byte*, byte of asset definition.
|
989
|
+
- `Object` - *definition*, description of asset.
|
990
|
+
|
991
|
+
##### Example
|
992
|
+
|
993
|
+
list all the available assets:
|
994
|
+
|
995
|
+
```js
|
996
|
+
bytom_client.asset.list_assets
|
997
|
+
|
998
|
+
# Response data
|
999
|
+
{
|
1000
|
+
"status" = >"success",
|
1001
|
+
"data" = >[{
|
1002
|
+
"type" = >"internal",
|
1003
|
+
"xpubs" = >nil,
|
1004
|
+
"quorum" = >0,
|
1005
|
+
"key_index" = >0,
|
1006
|
+
"derive_rule" = >0,
|
1007
|
+
"id" = >"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
|
1008
|
+
"alias" = >"BTM",
|
1009
|
+
"vm_version" = >1,
|
1010
|
+
"issue_program" = >"",
|
1011
|
+
"raw_definition_byte" = >"7b0a202022646563696d616c73223a20382c0a2020226465736372697074696f6e223a20224279746f6d204f6666696369616c204973737565222c0a2020226e616d65223a202242544d222c0a20202273796d626f6c223a202242544d220a7d",
|
1012
|
+
"definition" = >{
|
1013
|
+
"decimals" = >8,
|
1014
|
+
"description" = >"Bytom Official Issue",
|
1015
|
+
"name" = >"BTM",
|
1016
|
+
"symbol" = >"BTM"
|
1017
|
+
}
|
1018
|
+
},
|
1019
|
+
{
|
1020
|
+
"id" = >"0e11c2fa26623b3b1580d2b04a9cebb1ed13e04c18929fc1ac8c11ae62b87db5",
|
1021
|
+
"alias" = >"TESTASSET",
|
1022
|
+
"vm_version" = >1,
|
1023
|
+
"issue_program" = >"20e9108d3ca8049800727f6a3505b3a2710dc579405dde03c250f16d9a7e1e6e78160014c5a5b563c4623018557fb299259542b8739f6bc20163201e074b22ed7ae8470c7ba5d8a7bc95e83431a753a17465e8673af68a82500c22741a547a6413000000007b7b51547ac1631a000000547a547aae7cac00c0",
|
1024
|
+
"raw_definition_byte" = >"7b0a202022646563696d616c73223a20382c0a2020226465736372697074696f6e223a207b7d2c0a2020226e616d65223a2022544553544153534554222c0a20202273796d626f6c223a2022544553544153534554220a7d",
|
1025
|
+
"definition" = >{
|
1026
|
+
"decimals" = >8,
|
1027
|
+
"description" = >{},
|
1028
|
+
"name" = >"TESTASSET",
|
1029
|
+
"symbol" = >"TESTASSET"
|
1030
|
+
}
|
1031
|
+
},
|
1032
|
+
{
|
1033
|
+
"type" = >"asset",
|
1034
|
+
"xpubs" = >["c8d4487f0fc13287235262ec5005a7519e5d376c66900bf4c58dd2e1827ce5224fd228e5b64bbd5c66c6d5cf69226cb1e7c83ba0d4f11eed8c429dc33fd1d95c"],
|
1035
|
+
"quorum" = >1,
|
1036
|
+
"key_index" = >1,
|
1037
|
+
"derive_rule" = >0,
|
1038
|
+
"id" = >"e3e940fd9026a619ebb3c3dd1a1f0fc846cd57d2b33c55005605c1405135d2ef",
|
1039
|
+
"alias" = >"GOLD",
|
1040
|
+
"vm_version" = >1,
|
1041
|
+
"issue_program" = >"ae20334dfa534262c970ebf9e43e9573c7fbc4ecc6ce2db77204b63e1a277a7eae175151ad",
|
1042
|
+
"raw_definition_byte" = >"7b7d",
|
1043
|
+
"definition" = >nil
|
1044
|
+
}]
|
1045
|
+
}
|
1046
|
+
```
|
1047
|
+
|
1048
|
+
----
|
1049
|
+
|
1050
|
+
#### `update-asset-alias`
|
1051
|
+
|
1052
|
+
Update asset alias by assetID.
|
1053
|
+
|
1054
|
+
##### Parameters
|
1055
|
+
|
1056
|
+
`Object`:
|
1057
|
+
|
1058
|
+
- `String` - *id*, id of asset.
|
1059
|
+
- `String` - *alias*, new alias of asset.
|
1060
|
+
|
1061
|
+
##### Returns
|
1062
|
+
|
1063
|
+
none if the asset alias is updated success.
|
1064
|
+
|
1065
|
+
##### Example
|
1066
|
+
|
1067
|
+
update asset alias.
|
1068
|
+
|
1069
|
+
```js
|
1070
|
+
bytom_client.asset.update_asset_alias(
|
1071
|
+
id: '41b2c7a02e610c9e7117e5b2407573b953b3ebbec90302cf217ecaf134851622',
|
1072
|
+
alias_name: 'Property'
|
1073
|
+
)
|
1074
|
+
|
1075
|
+
# Response data
|
1076
|
+
```
|
1077
|
+
|
1078
|
+
----
|
1079
|
+
|
1080
|
+
#### `list-balances`
|
1081
|
+
|
1082
|
+
Returns the list of all available account balances.
|
1083
|
+
|
1084
|
+
##### Parameters
|
1085
|
+
|
1086
|
+
Optional:
|
1087
|
+
|
1088
|
+
- `String` - *account_id*, account id.
|
1089
|
+
- `String` - *account_alias*, name of account.
|
1090
|
+
|
1091
|
+
##### Returns
|
1092
|
+
|
1093
|
+
- `Array of Object`, balances owned by the account.
|
1094
|
+
- `Object`:
|
1095
|
+
- `String` - *account_id*, account id.
|
1096
|
+
- `String` - *account_alias*, name of account.
|
1097
|
+
- `String` - *asset_id*, asset id.
|
1098
|
+
- `String` - *asset_alias*, name of asset.
|
1099
|
+
- `Integer` - *amount*, specified asset balance of account.
|
1100
|
+
|
1101
|
+
##### Example
|
1102
|
+
|
1103
|
+
list all the available account balances.
|
1104
|
+
|
1105
|
+
```ruby
|
1106
|
+
#bytom_client = Bytom::Client.new(base_url: 'http://127.0.0.1:9888')
|
1107
|
+
bytom_client.balances.list_balances
|
1108
|
+
|
1109
|
+
# response data
|
1110
|
+
{
|
1111
|
+
"status" =>"success",
|
1112
|
+
"data" => [
|
1113
|
+
{
|
1114
|
+
"account_id" =>"0NO14DLP00A02",
|
1115
|
+
"account_alias" =>"dayone_account_001",
|
1116
|
+
"asset_alias" =>"BTM",
|
1117
|
+
"asset_id" =>"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
|
1118
|
+
"amount" =>1000000000,
|
1119
|
+
"asset_definition" => {
|
1120
|
+
"decimals" =>8,
|
1121
|
+
"description" =>"Bytom Official Issue",
|
1122
|
+
"name" =>"BTM",
|
1123
|
+
"symbol" =>"BTM"
|
1124
|
+
}
|
1125
|
+
},
|
1126
|
+
{
|
1127
|
+
"account_id" =>"0NO14VPOG0A04",
|
1128
|
+
"account_alias" =>"dayone_account_002",
|
1129
|
+
"asset_alias" =>"BTM",
|
1130
|
+
"asset_id" =>"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
|
1131
|
+
"amount" =>2000000000,
|
1132
|
+
"asset_definition" => {
|
1133
|
+
"decimals" =>8,
|
1134
|
+
"description" =>"Bytom Official Issue",
|
1135
|
+
"name" =>"BTM",
|
1136
|
+
"symbol" =>"BTM"
|
1137
|
+
}
|
1138
|
+
}
|
1139
|
+
]
|
1140
|
+
}
|
1141
|
+
```
|
1142
|
+
|
1143
|
+
list available account balances by the given account_id:
|
1144
|
+
|
1145
|
+
```ruby
|
1146
|
+
bytom_client.balances.list_balances(account_id: '0NO14VPOG0A04')
|
1147
|
+
bytom_client.balances.list_balances(account_alias: 'dayone_account_002')
|
1148
|
+
# response data
|
1149
|
+
{
|
1150
|
+
"status" =>"success",
|
1151
|
+
"data" => [
|
1152
|
+
{
|
1153
|
+
"account_id" =>"0NO14VPOG0A04",
|
1154
|
+
"account_alias" =>"dayone_account_002",
|
1155
|
+
"asset_alias" =>"BTM",
|
1156
|
+
"asset_id" =>"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
|
1157
|
+
"amount" =>2000000000,
|
1158
|
+
"asset_definition" => {
|
1159
|
+
"decimals" =>8,
|
1160
|
+
"description" =>"Bytom Official Issue",
|
1161
|
+
"name" =>"BTM",
|
1162
|
+
"symbol" =>"BTM"
|
1163
|
+
}
|
1164
|
+
}
|
1165
|
+
]
|
1166
|
+
}
|
1167
|
+
```
|
1168
|
+
|
1169
|
+
----
|
1170
|
+
|
1171
|
+
#### `list-unspent-outputs`
|
1172
|
+
|
1173
|
+
Returns the sub list of all available unspent outputs for all accounts in your wallet.
|
1174
|
+
|
1175
|
+
##### Parameters
|
1176
|
+
|
1177
|
+
`Object`:
|
1178
|
+
|
1179
|
+
optional:
|
1180
|
+
|
1181
|
+
- `String` - *id*, id of unspent output.
|
1182
|
+
- `Boolean` - *unconfirmed*, is include unconfirmed utxo
|
1183
|
+
- `Boolean` - *smart_contract*, is contract utxo
|
1184
|
+
- `Integer` - *from*, the start position of first utxo
|
1185
|
+
- `Integer` - *count*, the number of returned
|
1186
|
+
- `String` - *account_id*, account id.
|
1187
|
+
- `String` - *account_alias*, name of account.
|
1188
|
+
|
1189
|
+
##### Returns
|
1190
|
+
|
1191
|
+
- `Array of Object`, unspent output array.
|
1192
|
+
- `Object`:
|
1193
|
+
- `String` - *account_id*, account id.
|
1194
|
+
- `String` - *account_alias*, name of account.
|
1195
|
+
- `String` - *asset_id*, asset id.
|
1196
|
+
- `String` - *asset_alias*, name of asset.
|
1197
|
+
- `Integer` - *amount*, specified asset balance of account.
|
1198
|
+
- `String` - *address*, address of account.
|
1199
|
+
- `Boolean` - *change*, whether the account address is change.
|
1200
|
+
- `String` - *id*, unspent output id.
|
1201
|
+
- `String` - *program*, program of account.
|
1202
|
+
- `String` - *control_program_index*, index of program.
|
1203
|
+
- `String` - *source_id*, source unspent output id.
|
1204
|
+
- `String` - *source_pos*, position of source unspent output id in block.
|
1205
|
+
- `String` - *valid_height*, valid height.
|
1206
|
+
|
1207
|
+
##### Example
|
1208
|
+
|
1209
|
+
list all the available unspent outputs:
|
1210
|
+
|
1211
|
+
```ruby
|
1212
|
+
bytom_client.other.list_unspent_outputs
|
1213
|
+
|
1214
|
+
# response data
|
1215
|
+
{
|
1216
|
+
"status" =>"success",
|
1217
|
+
"data" => [
|
1218
|
+
{
|
1219
|
+
"account_alias" =>"dayone_account_001",
|
1220
|
+
"id" =>"d49567a31855a8d83ce13e3d2169d753c7d117cb97739744d34a976b1ee6cdae",
|
1221
|
+
"asset_id" =>"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
|
1222
|
+
"asset_alias" =>"BTM",
|
1223
|
+
"amount" =>1000000000,
|
1224
|
+
"account_id" =>"0NO14DLP00A02",
|
1225
|
+
"address" =>"tm1qlhr257v5y03j6gxw4z9wqqnteglv2xdf6jcc02",
|
1226
|
+
"control_program_index" =>2,
|
1227
|
+
"program" =>"0014fdc6aa799423e32d20cea88ae0026bca3ec519a9",
|
1228
|
+
"source_id" =>"5835d2a35141e44415bfb2277e0ba370cd43336931cfa31eff23db31ccd45394",
|
1229
|
+
"source_pos" =>1,
|
1230
|
+
"valid_height" =>0,
|
1231
|
+
"change" =>false,
|
1232
|
+
"derive_rule" =>0
|
1233
|
+
},
|
1234
|
+
{
|
1235
|
+
"account_alias" =>"dayone_account_002",
|
1236
|
+
"id" =>"240eb6ee1aa3583779eb0af6b450aeacd42c1375d914f8442f28cfd71f11f265",
|
1237
|
+
"asset_id" =>"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
|
1238
|
+
"asset_alias" =>"BTM",
|
1239
|
+
"amount" =>1000000000,
|
1240
|
+
"account_id" =>"0NO14VPOG0A04",
|
1241
|
+
"address" =>"tm1qgpw5p3t750jyapx8ecqjyvs5mkcr45h786ed32",
|
1242
|
+
"control_program_index" =>1,
|
1243
|
+
"program" =>"0014405d40c57ea3e44e84c7ce01223214ddb03ad2fe",
|
1244
|
+
"source_id" =>"ea01e22daecbcb7dbebcbddca8a8c604e722f99acd9f938e303d944e66314a8f",
|
1245
|
+
"source_pos" =>1,
|
1246
|
+
"valid_height" =>0,
|
1247
|
+
"change" =>false,
|
1248
|
+
"derive_rule" =>0
|
1249
|
+
},
|
1250
|
+
{
|
1251
|
+
"account_alias" =>"dayone_account_002",
|
1252
|
+
"id" =>"141d3c5447fc01f5dd2eac4567dc14295ada4cfedc59d6674d1564f5c4e9369c",
|
1253
|
+
"asset_id" =>"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
|
1254
|
+
"asset_alias" =>"BTM",
|
1255
|
+
"amount" =>1000000000,
|
1256
|
+
"account_id" =>"0NO14VPOG0A04",
|
1257
|
+
"address" =>"tm1qgpw5p3t750jyapx8ecqjyvs5mkcr45h786ed32",
|
1258
|
+
"control_program_index" =>1,
|
1259
|
+
"program" =>"0014405d40c57ea3e44e84c7ce01223214ddb03ad2fe",
|
1260
|
+
"source_id" =>"aec2b2b48d20eddb811584412ac79c78c8633d856016a2ec1f2ca9df1d4f363e",
|
1261
|
+
"source_pos" =>1,
|
1262
|
+
"valid_height" =>0,
|
1263
|
+
"change" =>false,
|
1264
|
+
"derive_rule" =>0
|
1265
|
+
}
|
1266
|
+
]
|
1267
|
+
}
|
1268
|
+
```
|
1269
|
+
|
1270
|
+
list the unspent output matching the given id:
|
1271
|
+
|
1272
|
+
```ruby
|
1273
|
+
bytom_client.other.list_unspent_outputs(
|
1274
|
+
id: '240eb6ee1aa3583779eb0af6b450aeacd42c1375d914f8442f28cfd71f11f265'
|
1275
|
+
)
|
1276
|
+
# response data
|
1277
|
+
{
|
1278
|
+
"status" =>"success",
|
1279
|
+
"data" => [
|
1280
|
+
{
|
1281
|
+
"account_alias" =>"dayone_account_002",
|
1282
|
+
"id" =>"240eb6ee1aa3583779eb0af6b450aeacd42c1375d914f8442f28cfd71f11f265",
|
1283
|
+
"asset_id" =>"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
|
1284
|
+
"asset_alias" =>"BTM",
|
1285
|
+
"amount" =>1000000000,
|
1286
|
+
"account_id" =>"0NO14VPOG0A04",
|
1287
|
+
"address" =>"tm1qgpw5p3t750jyapx8ecqjyvs5mkcr45h786ed32",
|
1288
|
+
"control_program_index" =>1,
|
1289
|
+
"program" =>"0014405d40c57ea3e44e84c7ce01223214ddb03ad2fe",
|
1290
|
+
"source_id" =>"ea01e22daecbcb7dbebcbddca8a8c604e722f99acd9f938e303d944e66314a8f",
|
1291
|
+
"source_pos" =>1,
|
1292
|
+
"valid_height" =>0,
|
1293
|
+
"change" =>false,
|
1294
|
+
"derive_rule" =>0
|
1295
|
+
}
|
1296
|
+
]
|
1297
|
+
}
|
1298
|
+
```
|
1299
|
+
|
1300
|
+
----
|
1301
|
+
|
1302
|
+
#### `backup-wallet`
|
1303
|
+
|
1304
|
+
Backup wallet to image file, it contain accounts image, assets image and keys image.
|
1305
|
+
|
1306
|
+
##### Parameters
|
1307
|
+
|
1308
|
+
none
|
1309
|
+
|
1310
|
+
##### Returns
|
1311
|
+
|
1312
|
+
`Object`:
|
1313
|
+
|
1314
|
+
- `Object` - *account_image*, account image.
|
1315
|
+
- `Object` - *asset_image*, asset image.
|
1316
|
+
- `Object` - *key_images*, key image.
|
1317
|
+
|
1318
|
+
##### Example
|
1319
|
+
|
1320
|
+
```ruby
|
1321
|
+
bytom_client.wallet.backup_wallet
|
1322
|
+
|
1323
|
+
# return
|
1324
|
+
{
|
1325
|
+
"status" =>"success",
|
1326
|
+
"data" => {
|
1327
|
+
"account_image" => {
|
1328
|
+
"slices" => [ ]
|
1329
|
+
},
|
1330
|
+
"asset_image" => {
|
1331
|
+
"assets" => [ ]
|
1332
|
+
},
|
1333
|
+
"key_images" => {
|
1334
|
+
"xkeys" => [ ]
|
1335
|
+
}
|
1336
|
+
}
|
1337
|
+
}
|
1338
|
+
```
|
1339
|
+
|
1340
|
+
----
|
1341
|
+
|
1342
|
+
#### `restore-wallet`
|
1343
|
+
|
1344
|
+
Restore wallet by image file.
|
1345
|
+
|
1346
|
+
##### Parameters
|
1347
|
+
|
1348
|
+
`Object`:
|
1349
|
+
|
1350
|
+
- `Object` - *account_image*, account image.
|
1351
|
+
- `Object` - *asset_image*, asset image.
|
1352
|
+
- `Object` - *key_images*, key image.
|
1353
|
+
|
1354
|
+
##### Returns
|
1355
|
+
|
1356
|
+
none if restore wallet success.
|
1357
|
+
|
1358
|
+
##### Example
|
1359
|
+
|
1360
|
+
```ruby
|
1361
|
+
|
1362
|
+
bytom_client.wallet.restore_wallet(
|
1363
|
+
account_image: {}, #'please input you data'
|
1364
|
+
asset_image: {}, #'please input you data'
|
1365
|
+
key_images: {} #'please input you data'
|
1366
|
+
)
|
1367
|
+
```
|
1368
|
+
|
1369
|
+
----
|
1370
|
+
|
1371
|
+
#### `rescan-wallet`
|
1372
|
+
|
1373
|
+
Trigger to rescan block information into related wallet.
|
1374
|
+
|
1375
|
+
##### Parameters
|
1376
|
+
|
1377
|
+
none
|
1378
|
+
|
1379
|
+
##### Returns
|
1380
|
+
|
1381
|
+
none if restore wallet success.
|
1382
|
+
|
1383
|
+
##### Example
|
1384
|
+
|
1385
|
+
```ruby
|
1386
|
+
bytom_client.wallet.rescan_wallet
|
1387
|
+
|
1388
|
+
```
|
1389
|
+
|
1390
|
+
----
|
1391
|
+
|
1392
|
+
#### `recovery-wallet`
|
1393
|
+
|
1394
|
+
Recovery wallet and accounts from root XPubs.
|
1395
|
+
All accounts and balances of bip44 multi-account hierarchy for deterministic wallets can be restored via root xpubs.
|
1396
|
+
|
1397
|
+
##### Parameters
|
1398
|
+
|
1399
|
+
`Object`:
|
1400
|
+
|
1401
|
+
- `Object` - *xpubs*, root XPubs.
|
1402
|
+
|
1403
|
+
|
1404
|
+
##### Returns
|
1405
|
+
|
1406
|
+
Status of recovery wallet.
|
1407
|
+
|
1408
|
+
##### Example
|
1409
|
+
|
1410
|
+
```
|
1411
|
+
bytom_client.wallet.recovery_wallet(
|
1412
|
+
xpubs: ['d46c29a44c36553b950a7a7eada946258042065e4c594b548056e12bc4f010a4b617b9ed9f10c05cb02b6bdee82828f65d9f8e7746c2342d63da72e6c2ef3089']
|
1413
|
+
)
|
1414
|
+
```
|
1415
|
+
----
|
1416
|
+
|
1417
|
+
#### `wallet-info`
|
1418
|
+
|
1419
|
+
Return the information of wallet.
|
1420
|
+
|
1421
|
+
##### Parameters
|
1422
|
+
|
1423
|
+
none
|
1424
|
+
|
1425
|
+
##### Returns
|
1426
|
+
|
1427
|
+
`Object`:
|
1428
|
+
|
1429
|
+
- `Integer` - *best_block_height*, current block height.
|
1430
|
+
- `Integer` - *wallet_height*, current block height for wallet.
|
1431
|
+
|
1432
|
+
##### Example
|
1433
|
+
|
1434
|
+
```ruby
|
1435
|
+
bytom_client.wallet.wallet_info
|
1436
|
+
|
1437
|
+
# Response data
|
1438
|
+
{"status"=>"success", "data"=>{"best_block_height"=>119081, "wallet_height"=>119081}}
|
1439
|
+
```
|
1440
|
+
|
1441
|
+
----
|
1442
|
+
|
1443
|
+
#### `sign-message`
|
1444
|
+
|
1445
|
+
Sign a message with the key password(decode encrypted private key) of an address.
|
1446
|
+
|
1447
|
+
##### Parameters
|
1448
|
+
|
1449
|
+
`Object`:
|
1450
|
+
|
1451
|
+
- `String` - *address*, address for account.
|
1452
|
+
- `String` - *message*, message for signature by address xpub.
|
1453
|
+
- `String` - *password*, password of account.
|
1454
|
+
|
1455
|
+
##### Returns
|
1456
|
+
|
1457
|
+
`Object`:
|
1458
|
+
|
1459
|
+
- `String` - *derived_xpub*, derived xpub.
|
1460
|
+
- `String` - *signature*, signature of message.
|
1461
|
+
|
1462
|
+
##### Example
|
1463
|
+
|
1464
|
+
```ruby
|
1465
|
+
bytom_client.message.sign_message(
|
1466
|
+
address: 'tm1q20gt090mcfz7cn0urg6dy22ec327deseew7vtz',
|
1467
|
+
message: 'This is a new message',
|
1468
|
+
password: '123456'
|
1469
|
+
)
|
1470
|
+
|
1471
|
+
# Request
|
1472
|
+
curl -X POST http://127.0.0.1:9888/sign-message -d '{"address":"tm1q20gt090mcfz7cn0urg6dy22ec327deseew7vtz", "message":"this is a test message", "password":"123456"}'
|
1473
|
+
|
1474
|
+
# Result
|
1475
|
+
{
|
1476
|
+
"signature": "74da3d6572233736e3a439166719244dab57dd0047f8751b1efa2da26eeab251d915c1211dcad77e8b013267b86d96e91ae67ff0be520ef4ec326e911410b609",
|
1477
|
+
"derived_xpub": "6ff8c3d1321ce39a3c3550f57ba70b67dcbcef821e9b85f6150edb7f2f3f91009e67f3075e6e76ed5f657ee4b1a5f4749b7a8c74c8e7e6a1b0e5918ebd5df4d0"
|
1478
|
+
}
|
1479
|
+
```
|
1480
|
+
|
1481
|
+
----
|
1482
|
+
|
1483
|
+
#### `decode-program`
|
1484
|
+
|
1485
|
+
Decode program.
|
1486
|
+
|
1487
|
+
##### Parameters
|
1488
|
+
|
1489
|
+
`Object`:
|
1490
|
+
|
1491
|
+
- `String` - *program*, program for account.
|
1492
|
+
|
1493
|
+
##### Returns
|
1494
|
+
|
1495
|
+
`Object`:
|
1496
|
+
|
1497
|
+
- `String` - *instructions*, instructions and data for program.
|
1498
|
+
|
1499
|
+
##### Example
|
1500
|
+
|
1501
|
+
```ruby
|
1502
|
+
bytom_client.other.decode_program(
|
1503
|
+
program: "0014a86c83ee12e6d790fb388345cc2e2b87056a0773"
|
1504
|
+
)
|
1505
|
+
# response data
|
1506
|
+
{
|
1507
|
+
"status" =>"success",
|
1508
|
+
"data" => {
|
1509
|
+
"instructions" =>"DUP \nHASH160 \nDATA_20 a86c83ee12e6d790fb388345cc2e2b87056a0773\nEQUALVERIFY \nTXSIGHASH \nSWAP \nCHECKSIG \n"
|
1510
|
+
}
|
1511
|
+
}
|
1512
|
+
```
|
1513
|
+
|
1514
|
+
----
|
1515
|
+
|
1516
|
+
#### `get-transaction`
|
1517
|
+
|
1518
|
+
Query the account related transaction by transaction ID.
|
1519
|
+
|
1520
|
+
##### Parameters
|
1521
|
+
|
1522
|
+
`Object`:
|
1523
|
+
|
1524
|
+
- `String` - *tx_id*, transaction id, hash of transaction.
|
1525
|
+
|
1526
|
+
##### Returns
|
1527
|
+
|
1528
|
+
`Object`:
|
1529
|
+
|
1530
|
+
- `String` - *tx_id*, transaction id, hash of the transaction.
|
1531
|
+
- `Integer` - *block_time*, the unix timestamp for when the requst was responsed.
|
1532
|
+
- `String` - *block_hash*, hash of the block where this transaction was in.
|
1533
|
+
- `Integer` - *block_height*, block height where this transaction was in.
|
1534
|
+
- `Integer` - *block_index*, position of the transaction in the block.
|
1535
|
+
- `Integer` - *block_transactions_count*, transactions count where this transaction was in the block.
|
1536
|
+
- `Boolean` - *status_fail*, whether the state of the transaction request has failed.
|
1537
|
+
- `Integer` - *size*, size of transaction.
|
1538
|
+
- `Array of Object` - *inputs*, object of inputs for the transaction.
|
1539
|
+
- `String` - *type*, the type of input action, available option include: 'spend', 'issue', 'coinbase'.
|
1540
|
+
- `String` - *asset_id*, asset id.
|
1541
|
+
- `String` - *asset_alias*, name of asset.
|
1542
|
+
- `Object` - *asset_definition*, definition of asset(json object).
|
1543
|
+
- `Integer` - *amount*, amount of asset.
|
1544
|
+
- `Object` - *issuance_program*, issuance program, it only exist when type is 'issue'.
|
1545
|
+
- `Object` - *control_program*, control program of account, it only exist when type is 'spend'.
|
1546
|
+
- `String` - *address*, address of account, it only exist when type is 'spend'.
|
1547
|
+
- `String` - *spent_output_id*, the front of outputID to be spent in this input, it only exist when type is 'spend'.
|
1548
|
+
- `String` - *account_id*, account id.
|
1549
|
+
- `String` - *account_alias*, name of account.
|
1550
|
+
- `Object` - *arbitrary*, arbitrary infomation can be set by miner, it only exist when type is 'coinbase'.
|
1551
|
+
- `String` - *input_id*, hash of input action.
|
1552
|
+
- `Array of String` - *witness_arguments*, witness arguments.
|
1553
|
+
- `Array of Object` - *outputs*, object of outputs for the transaction.
|
1554
|
+
- `String` - *type*, the type of output action, available option include: 'retire', 'control'.
|
1555
|
+
- `String` - *id*, outputid related to utxo.
|
1556
|
+
- `Integer` - *position*, position of outputs.
|
1557
|
+
- `String` - *asset_id*, asset id.
|
1558
|
+
- `String` - *asset_alias*, name of asset.
|
1559
|
+
- `Object` - *asset_definition*, definition of asset(json object).
|
1560
|
+
- `Integer` - *amount*, amount of asset.
|
1561
|
+
- `String` - *account_id*, account id.
|
1562
|
+
- `String` - *account_alias*, name of account.
|
1563
|
+
- `Object` - *control_program*, control program of account.
|
1564
|
+
- `String` - *address*, address of account.
|
1565
|
+
|
1566
|
+
##### Example
|
1567
|
+
|
1568
|
+
```ruby
|
1569
|
+
bytom_client.transactions.get_transaction(
|
1570
|
+
tx_id: 'bf48ce62e78466a40e26dd8497ffb6cd4a6064a2293c9a01ed57e3e1bb293266'
|
1571
|
+
)
|
1572
|
+
|
1573
|
+
# response data
|
1574
|
+
{
|
1575
|
+
"status" =>"success",
|
1576
|
+
"data" => {
|
1577
|
+
"tx_id" =>"bf48ce62e78466a40e26dd8497ffb6cd4a6064a2293c9a01ed57e3e1bb293266",
|
1578
|
+
"block_time" =>1547715214,
|
1579
|
+
"block_hash" =>"bb155a108fb769506bc33ffd756c5ac4f112b48d81701ce9306942abdaa76ecf",
|
1580
|
+
"block_height" =>119228,
|
1581
|
+
"block_index" =>1,
|
1582
|
+
"block_transactions_count" =>2,
|
1583
|
+
"inputs" => [
|
1584
|
+
{
|
1585
|
+
"type" =>"spend",
|
1586
|
+
"asset_id" =>"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
|
1587
|
+
"asset_alias" =>"BTM",
|
1588
|
+
"asset_definition" => {
|
1589
|
+
"decimals" =>8,
|
1590
|
+
"description" =>"Bytom Official Issue",
|
1591
|
+
"name" =>"BTM",
|
1592
|
+
"symbol" =>"BTM"
|
1593
|
+
},
|
1594
|
+
"amount" =>35860000000,
|
1595
|
+
"control_program" =>"0014ebd24bd4394a7b136e45e1787126344989389cd9",
|
1596
|
+
"address" =>"tm1qa0fyh4peffa3xmj9u9u8zf35fxyn38xej27fls",
|
1597
|
+
"spent_output_id" =>"2d0367b043e53d58a1bd266d6e73907c8abf6fe370cf38bb3b6674daf72c63cf",
|
1598
|
+
"input_id" =>"3dc91ddccfeab72500a4b792ec52afcf5de62f650a22350986aca435ca1cb307",
|
1599
|
+
"witness_arguments" => [
|
1600
|
+
"be89ee618fc96a6b9722cbd6d1cf31a4fe7428ded1e7d494e187a5a3f0862eebed18423b7bc61c66be39e82656c8e43ac99556b2c7f610e9a9b3b01ed81e4c03",
|
1601
|
+
"a25abccb8332f3336069bf750128896c85aef777fbef3107276920d5727d2ff8"
|
1602
|
+
]
|
1603
|
+
}
|
1604
|
+
],
|
1605
|
+
"outputs" => [
|
1606
|
+
{
|
1607
|
+
"type" =>"control",
|
1608
|
+
"id" =>"93e951305b8ed0a2500df0beec6f82e72853a4ab2edaed1fad18dce915eeb7bd",
|
1609
|
+
"position" =>0,
|
1610
|
+
"asset_id" =>"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
|
1611
|
+
"asset_alias" =>"BTM",
|
1612
|
+
"asset_definition" => {
|
1613
|
+
"decimals" =>8,
|
1614
|
+
"description" =>"Bytom Official Issue",
|
1615
|
+
"name" =>"BTM",
|
1616
|
+
"symbol" =>"BTM"
|
1617
|
+
},
|
1618
|
+
"amount" =>34850000000,
|
1619
|
+
"control_program" =>"0014f365d81eca39f8be2f7a39908fcc36b4005d6040",
|
1620
|
+
"address" =>"tm1q7djas8k288ututm68xgglnpkksq96czqhpxttj"
|
1621
|
+
},
|
1622
|
+
{
|
1623
|
+
"type" =>"control",
|
1624
|
+
"id" =>"240eb6ee1aa3583779eb0af6b450aeacd42c1375d914f8442f28cfd71f11f265",
|
1625
|
+
"position" =>1,
|
1626
|
+
"asset_id" =>"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
|
1627
|
+
"asset_alias" =>"BTM",
|
1628
|
+
"asset_definition" => {
|
1629
|
+
"decimals" =>8,
|
1630
|
+
"description" =>"Bytom Official Issue",
|
1631
|
+
"name" =>"BTM",
|
1632
|
+
"symbol" =>"BTM"
|
1633
|
+
},
|
1634
|
+
"amount" =>1000000000,
|
1635
|
+
"account_id" =>"0NO14VPOG0A04",
|
1636
|
+
"account_alias" =>"dayone_account_002",
|
1637
|
+
"control_program" =>"0014405d40c57ea3e44e84c7ce01223214ddb03ad2fe",
|
1638
|
+
"address" =>"tm1qgpw5p3t750jyapx8ecqjyvs5mkcr45h786ed32"
|
1639
|
+
}
|
1640
|
+
],
|
1641
|
+
"status_fail" =>false,
|
1642
|
+
"size" =>337
|
1643
|
+
}
|
1644
|
+
}
|
1645
|
+
```
|
1646
|
+
|
1647
|
+
----
|
1648
|
+
|
1649
|
+
#### `list-transactions`
|
1650
|
+
|
1651
|
+
Returns the sub list of all the account related transactions.
|
1652
|
+
|
1653
|
+
##### Parameters
|
1654
|
+
|
1655
|
+
`Object`:
|
1656
|
+
|
1657
|
+
optional:
|
1658
|
+
|
1659
|
+
- `String` - *id*, transaction id, hash of transaction.
|
1660
|
+
- `String` - *account_id*, id of account.
|
1661
|
+
- `Boolean` - *detail* , flag of detail transactions, default false (only return transaction summary)
|
1662
|
+
- `Boolean` - *unconfirmed*, flag of unconfirmed transactions(query result include all confirmed and unconfirmed transactions), default false.
|
1663
|
+
- `Integer` - *from*, the start position of first transaction
|
1664
|
+
- `Integer` - *count*, the number of returned
|
1665
|
+
|
1666
|
+
##### Returns
|
1667
|
+
|
1668
|
+
`Array of Object`, transaction array.
|
1669
|
+
|
1670
|
+
optional:
|
1671
|
+
|
1672
|
+
- `Object`:(summary transaction)
|
1673
|
+
- `String` - *tx_id*, transaction id, hash of the transaction.
|
1674
|
+
- `Integer` - *block_time*, the unix timestamp for when the requst was responsed.
|
1675
|
+
- `Array of Object` - *inputs*, object of summary inputs for the transaction.
|
1676
|
+
- `String` - *type*, the type of input action, available option include: 'spend', 'issue', 'coinbase'.
|
1677
|
+
- `String` - *asset_id*, asset id.
|
1678
|
+
- `String` - *asset_alias*, name of asset.
|
1679
|
+
- `Integer` - *amount*, amount of asset.
|
1680
|
+
- `String` - *account_id*, account id.
|
1681
|
+
- `String` - *account_alias*, name of account.
|
1682
|
+
- `Object` - *arbitrary*, arbitrary infomation can be set by miner, it only exist when type is 'coinbase'.
|
1683
|
+
- `Array of Object` - *outputs*, object of summary outputs for the transaction.
|
1684
|
+
- `String` - *type*, the type of output action, available option include: 'retire', 'control'.
|
1685
|
+
- `String` - *asset_id*, asset id.
|
1686
|
+
- `String` - *asset_alias*, name of asset.
|
1687
|
+
- `Integer` - *amount*, amount of asset.
|
1688
|
+
- `String` - *account_id*, account id.
|
1689
|
+
- `String` - *account_alias*, name of account.
|
1690
|
+
- `Object` - *arbitrary*, arbitrary infomation can be set by miner, it only exist when type is input 'coinbase'(this place is empty).
|
1691
|
+
|
1692
|
+
- `Object`:(detail transaction)
|
1693
|
+
- `String` - *tx_id*, transaction id, hash of the transaction.
|
1694
|
+
- `Integer` - *block_time*, the unix timestamp for when the requst was responsed.
|
1695
|
+
- `String` - *block_hash*, hash of the block where this transaction was in.
|
1696
|
+
- `Integer` - *block_height*, block height where this transaction was in.
|
1697
|
+
- `Integer` - *block_index*, position of the transaction in the block.
|
1698
|
+
- `Integer` - *block_transactions_count*, transactions count where this transaction was in the block.
|
1699
|
+
- `Boolean` - *status_fail*, whether the state of the transaction request has failed.
|
1700
|
+
- `Integer` - *size*, size of transaction.
|
1701
|
+
- `Array of Object` - *inputs*, object of inputs for the transaction.
|
1702
|
+
- `String` - *type*, the type of input action, available option include: 'spend', 'issue', 'coinbase'.
|
1703
|
+
- `String` - *asset_id*, asset id.
|
1704
|
+
- `String` - *asset_alias*, name of asset.
|
1705
|
+
- `Object` - *asset_definition*, definition of asset(json object).
|
1706
|
+
- `Integer` - *amount*, amount of asset.
|
1707
|
+
- `Object` - *issuance_program*, issuance program, it only exist when type is 'issue'.
|
1708
|
+
- `Object` - *control_program*, control program of account, it only exist when type is 'spend'.
|
1709
|
+
- `String` - *address*, address of account, it only exist when type is 'spend'.
|
1710
|
+
- `String` - *spent_output_id*, the front of outputID to be spent in this input, it only exist when type is 'spend'.
|
1711
|
+
- `String` - *account_id*, account id.
|
1712
|
+
- `String` - *account_alias*, name of account.
|
1713
|
+
- `Object` - *arbitrary*, arbitrary infomation can be set by miner, it only exist when type is 'coinbase'.
|
1714
|
+
- `String` - *input_id*, hash of input action.
|
1715
|
+
- `Array of String` - *witness_arguments*, witness arguments.
|
1716
|
+
- `Array of Object` - *outputs*, object of outputs for the transaction.
|
1717
|
+
- `String` - *type*, the type of output action, available option include: 'retire', 'control'.
|
1718
|
+
- `String` - *id*, outputid related to utxo.
|
1719
|
+
- `Integer` - *position*, position of outputs.
|
1720
|
+
- `String` - *asset_id*, asset id.
|
1721
|
+
- `String` - *asset_alias*, name of asset.
|
1722
|
+
- `Object` - *asset_definition*, definition of asset(json object).
|
1723
|
+
- `Integer` - *amount*, amount of asset.
|
1724
|
+
- `String` - *account_id*, account id.
|
1725
|
+
- `String` - *account_alias*, name of account.
|
1726
|
+
- `Object` - *control_program*, control program of account.
|
1727
|
+
- `String` - *address*, address of account.
|
1728
|
+
|
1729
|
+
##### Example
|
1730
|
+
|
1731
|
+
list all the available transactions:
|
1732
|
+
|
1733
|
+
```ruby
|
1734
|
+
#bytom_client = Bytom::Client.new(base_url: 'http://127.0.0.1:9888')
|
1735
|
+
bytom_client.transactions.list_transactions
|
1736
|
+
|
1737
|
+
# response data
|
1738
|
+
{
|
1739
|
+
"status" =>"success",
|
1740
|
+
"data" => [
|
1741
|
+
{
|
1742
|
+
"tx_id" =>"bf48ce62e78466a40e26dd8497ffb6cd4a6064a2293c9a01ed57e3e1bb293266",
|
1743
|
+
"block_time" =>1547715214,
|
1744
|
+
"inputs" => [
|
1745
|
+
{
|
1746
|
+
"type" =>"spend",
|
1747
|
+
"asset_id" =>"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
|
1748
|
+
"asset_alias" =>"BTM",
|
1749
|
+
"amount" =>35860000000
|
1750
|
+
}
|
1751
|
+
],
|
1752
|
+
"outputs" => [
|
1753
|
+
{
|
1754
|
+
"type" =>"control",
|
1755
|
+
"asset_id" =>"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
|
1756
|
+
"asset_alias" =>"BTM",
|
1757
|
+
"amount" =>34850000000
|
1758
|
+
},
|
1759
|
+
{
|
1760
|
+
"type" =>"control",
|
1761
|
+
"asset_id" =>"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
|
1762
|
+
"asset_alias" =>"BTM",
|
1763
|
+
"amount" =>1000000000,
|
1764
|
+
"account_id" =>"0NO14VPOG0A04",
|
1765
|
+
"account_alias" =>"dayone_account_002"
|
1766
|
+
}
|
1767
|
+
]
|
1768
|
+
},
|
1769
|
+
{
|
1770
|
+
"tx_id" =>"b9cfc401cba53c6a873c8df40cf68f474314495f73828c206606d803426c48b9",
|
1771
|
+
"block_time" =>1547715091,
|
1772
|
+
"inputs" => [
|
1773
|
+
{
|
1774
|
+
"type" =>"spend",
|
1775
|
+
"asset_id" =>"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
|
1776
|
+
"asset_alias" =>"BTM",
|
1777
|
+
"amount" =>27780000000
|
1778
|
+
}
|
1779
|
+
],
|
1780
|
+
"outputs" => [
|
1781
|
+
{
|
1782
|
+
"type" =>"control",
|
1783
|
+
"asset_id" =>"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
|
1784
|
+
"asset_alias" =>"BTM",
|
1785
|
+
"amount" =>26770000000
|
1786
|
+
},
|
1787
|
+
{
|
1788
|
+
"type" =>"control",
|
1789
|
+
"asset_id" =>"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
|
1790
|
+
"asset_alias" =>"BTM",
|
1791
|
+
"amount" =>1000000000,
|
1792
|
+
"account_id" =>"0NO14VPOG0A04",
|
1793
|
+
"account_alias" =>"dayone_account_002"
|
1794
|
+
}
|
1795
|
+
]
|
1796
|
+
},
|
1797
|
+
{
|
1798
|
+
"tx_id" =>"be6a59fe11eb395358875ad4c1a1f01a52ca07367684bfdd8c21a0dcc5256299",
|
1799
|
+
"block_time" =>1547715091,
|
1800
|
+
"inputs" => [
|
1801
|
+
{
|
1802
|
+
"type" =>"spend",
|
1803
|
+
"asset_id" =>"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
|
1804
|
+
"asset_alias" =>"BTM",
|
1805
|
+
"amount" =>4550000000
|
1806
|
+
}
|
1807
|
+
],
|
1808
|
+
"outputs" => [
|
1809
|
+
{
|
1810
|
+
"type" =>"control",
|
1811
|
+
"asset_id" =>"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
|
1812
|
+
"asset_alias" =>"BTM",
|
1813
|
+
"amount" =>3540000000
|
1814
|
+
},
|
1815
|
+
{
|
1816
|
+
"type" =>"control",
|
1817
|
+
"asset_id" =>"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
|
1818
|
+
"asset_alias" =>"BTM",
|
1819
|
+
"amount" =>1000000000,
|
1820
|
+
"account_id" =>"0NO14DLP00A02",
|
1821
|
+
"account_alias" =>"dayone_account_001"
|
1822
|
+
}
|
1823
|
+
]
|
1824
|
+
}
|
1825
|
+
]
|
1826
|
+
}
|
1827
|
+
```
|
1828
|
+
|
1829
|
+
list the transaction matching the given tx_id with detail:
|
1830
|
+
|
1831
|
+
```ruby
|
1832
|
+
bytom_client.transactions.list_transactions(
|
1833
|
+
id: 'bf48ce62e78466a40e26dd8497ffb6cd4a6064a2293c9a01ed57e3e1bb293266'
|
1834
|
+
)
|
1835
|
+
|
1836
|
+
# response data
|
1837
|
+
{
|
1838
|
+
"status" =>"success",
|
1839
|
+
"data" => [
|
1840
|
+
{
|
1841
|
+
"tx_id" =>"bf48ce62e78466a40e26dd8497ffb6cd4a6064a2293c9a01ed57e3e1bb293266",
|
1842
|
+
"block_time" =>1547715214,
|
1843
|
+
"inputs" => [
|
1844
|
+
{
|
1845
|
+
"type" =>"spend",
|
1846
|
+
"asset_id" =>"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
|
1847
|
+
"asset_alias" =>"BTM",
|
1848
|
+
"amount" =>35860000000
|
1849
|
+
}
|
1850
|
+
],
|
1851
|
+
"outputs" => [
|
1852
|
+
{
|
1853
|
+
"type" =>"control",
|
1854
|
+
"asset_id" =>"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
|
1855
|
+
"asset_alias" =>"BTM",
|
1856
|
+
"amount" =>34850000000
|
1857
|
+
},
|
1858
|
+
{
|
1859
|
+
"type" =>"control",
|
1860
|
+
"asset_id" =>"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
|
1861
|
+
"asset_alias" =>"BTM",
|
1862
|
+
"amount" =>1000000000,
|
1863
|
+
"account_id" =>"0NO14VPOG0A04",
|
1864
|
+
"account_alias" =>"dayone_account_002"
|
1865
|
+
}
|
1866
|
+
]
|
1867
|
+
}
|
1868
|
+
]
|
1869
|
+
}
|
1870
|
+
|
1871
|
+
|
1872
|
+
bytom_client.transactions.list_transactions(
|
1873
|
+
id: 'bf48ce62e78466a40e26dd8497ffb6cd4a6064a2293c9a01ed57e3e1bb293266',
|
1874
|
+
detail: true
|
1875
|
+
)
|
1876
|
+
|
1877
|
+
# response data
|
1878
|
+
{
|
1879
|
+
"status" =>"success",
|
1880
|
+
"data" => [
|
1881
|
+
{
|
1882
|
+
"tx_id" =>"bf48ce62e78466a40e26dd8497ffb6cd4a6064a2293c9a01ed57e3e1bb293266",
|
1883
|
+
"block_time" =>1547715214,
|
1884
|
+
"block_hash" =>"bb155a108fb769506bc33ffd756c5ac4f112b48d81701ce9306942abdaa76ecf",
|
1885
|
+
"block_height" =>119228,
|
1886
|
+
"block_index" =>1,
|
1887
|
+
"block_transactions_count" =>2,
|
1888
|
+
"inputs" => [
|
1889
|
+
{
|
1890
|
+
"type" =>"spend",
|
1891
|
+
"asset_id" =>"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
|
1892
|
+
"asset_alias" =>"BTM",
|
1893
|
+
"asset_definition" => {
|
1894
|
+
"decimals" =>8,
|
1895
|
+
"description" =>"Bytom Official Issue",
|
1896
|
+
"name" =>"BTM",
|
1897
|
+
"symbol" =>"BTM"
|
1898
|
+
},
|
1899
|
+
"amount" =>35860000000,
|
1900
|
+
"control_program" =>"0014ebd24bd4394a7b136e45e1787126344989389cd9",
|
1901
|
+
"address" =>"tm1qa0fyh4peffa3xmj9u9u8zf35fxyn38xej27fls",
|
1902
|
+
"spent_output_id" =>"2d0367b043e53d58a1bd266d6e73907c8abf6fe370cf38bb3b6674daf72c63cf",
|
1903
|
+
"input_id" =>"3dc91ddccfeab72500a4b792ec52afcf5de62f650a22350986aca435ca1cb307",
|
1904
|
+
"witness_arguments" => [
|
1905
|
+
"be89ee618fc96a6b9722cbd6d1cf31a4fe7428ded1e7d494e187a5a3f0862eebed18423b7bc61c66be39e82656c8e43ac99556b2c7f610e9a9b3b01ed81e4c03",
|
1906
|
+
"a25abccb8332f3336069bf750128896c85aef777fbef3107276920d5727d2ff8"
|
1907
|
+
]
|
1908
|
+
}
|
1909
|
+
],
|
1910
|
+
"outputs" => [
|
1911
|
+
{
|
1912
|
+
"type" =>"control",
|
1913
|
+
"id" =>"93e951305b8ed0a2500df0beec6f82e72853a4ab2edaed1fad18dce915eeb7bd",
|
1914
|
+
"position" =>0,
|
1915
|
+
"asset_id" =>"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
|
1916
|
+
"asset_alias" =>"BTM",
|
1917
|
+
"asset_definition" => {
|
1918
|
+
"decimals" =>8,
|
1919
|
+
"description" =>"Bytom Official Issue",
|
1920
|
+
"name" =>"BTM",
|
1921
|
+
"symbol" =>"BTM"
|
1922
|
+
},
|
1923
|
+
"amount" =>34850000000,
|
1924
|
+
"control_program" =>"0014f365d81eca39f8be2f7a39908fcc36b4005d6040",
|
1925
|
+
"address" =>"tm1q7djas8k288ututm68xgglnpkksq96czqhpxttj"
|
1926
|
+
},
|
1927
|
+
{
|
1928
|
+
"type" =>"control",
|
1929
|
+
"id" =>"240eb6ee1aa3583779eb0af6b450aeacd42c1375d914f8442f28cfd71f11f265",
|
1930
|
+
"position" =>1,
|
1931
|
+
"asset_id" =>"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
|
1932
|
+
"asset_alias" =>"BTM",
|
1933
|
+
"asset_definition" => {
|
1934
|
+
"decimals" =>8,
|
1935
|
+
"description" =>"Bytom Official Issue",
|
1936
|
+
"name" =>"BTM",
|
1937
|
+
"symbol" =>"BTM"
|
1938
|
+
},
|
1939
|
+
"amount" =>1000000000,
|
1940
|
+
"account_id" =>"0NO14VPOG0A04",
|
1941
|
+
"account_alias" =>"dayone_account_002",
|
1942
|
+
"control_program" =>"0014405d40c57ea3e44e84c7ce01223214ddb03ad2fe",
|
1943
|
+
"address" =>"tm1qgpw5p3t750jyapx8ecqjyvs5mkcr45h786ed32"
|
1944
|
+
}
|
1945
|
+
],
|
1946
|
+
"status_fail" =>false,
|
1947
|
+
"size" =>337
|
1948
|
+
}
|
1949
|
+
]
|
1950
|
+
}
|
1951
|
+
```
|
1952
|
+
|
1953
|
+
list the transaction matching the given account_id and unconfirmed flag(unconfirmed transaction's block_hash, block_height and block_index is default for zero):
|
1954
|
+
|
1955
|
+
```ruby
|
1956
|
+
bytom_client.transactions.list_transactions(
|
1957
|
+
account_id: '0NO14DLP00A02',
|
1958
|
+
unconfirmed: true,
|
1959
|
+
detail: true
|
1960
|
+
)
|
1961
|
+
|
1962
|
+
# response data
|
1963
|
+
{
|
1964
|
+
"status" =>"success",
|
1965
|
+
"data" => [
|
1966
|
+
{
|
1967
|
+
"tx_id" =>"be6a59fe11eb395358875ad4c1a1f01a52ca07367684bfdd8c21a0dcc5256299",
|
1968
|
+
"block_time" =>1547715091,
|
1969
|
+
"block_hash" =>"d570b5a319ea26b20d5695c8665d189cdf3328a09be169b87201c1e53895239c",
|
1970
|
+
"block_height" =>119227,
|
1971
|
+
"block_index" =>1,
|
1972
|
+
"block_transactions_count" =>3,
|
1973
|
+
"inputs" => [
|
1974
|
+
{
|
1975
|
+
"type" =>"spend",
|
1976
|
+
"asset_id" =>"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
|
1977
|
+
"asset_alias" =>"BTM",
|
1978
|
+
"asset_definition" => {
|
1979
|
+
"decimals" =>8,
|
1980
|
+
"description" =>"Bytom Official Issue",
|
1981
|
+
"name" =>"BTM",
|
1982
|
+
"symbol" =>"BTM"
|
1983
|
+
},
|
1984
|
+
"amount" =>4550000000,
|
1985
|
+
"control_program" =>"0014040724739563503585bcf96b22bc5ae8857340c0",
|
1986
|
+
"address" =>"tm1qqsrjguu4vdgrtpdul94j90z6azzhxsxqj64ym8",
|
1987
|
+
"spent_output_id" =>"3911b9bea240594e7f0412de3088f7912096e2b15525ab1d997750c9e8fa2961",
|
1988
|
+
"input_id" =>"a34cd66ff0a76cea49869d9aa019c0b4436d412f7faef246c0b0d2f16fe5823b",
|
1989
|
+
"witness_arguments" => [
|
1990
|
+
"39ad2271c6aad68f6856acf701ab06174cc2ee23fad34dd0ed3ba2c30c711eaef8e3a83b067d6b76df57f714413ff79c39a0e60f264f054c0232b455dfb8bc03",
|
1991
|
+
"b3ea1d30db23be82c4dd957382f33a2bf0cbe2b756334f50900e14e0fd13f8ce"
|
1992
|
+
]
|
1993
|
+
}
|
1994
|
+
],
|
1995
|
+
"outputs" => [
|
1996
|
+
{
|
1997
|
+
"type" =>"control",
|
1998
|
+
"id" =>"f4b7d757f30a595209992e9146fe5e4f04be853ff14a6f0b1404571b7eb8df94",
|
1999
|
+
"position" =>0,
|
2000
|
+
"asset_id" =>"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
|
2001
|
+
"asset_alias" =>"BTM",
|
2002
|
+
"asset_definition" => {
|
2003
|
+
"decimals" =>8,
|
2004
|
+
"description" =>"Bytom Official Issue",
|
2005
|
+
"name" =>"BTM",
|
2006
|
+
"symbol" =>"BTM"
|
2007
|
+
},
|
2008
|
+
"amount" =>3540000000,
|
2009
|
+
"control_program" =>"0014a3dc0032b66424a170d538185104dc9467f1f12a",
|
2010
|
+
"address" =>"tm1q50wqqv4kvsj2zux48qv9zpxuj3nlruf282qyyh"
|
2011
|
+
},
|
2012
|
+
{
|
2013
|
+
"type" =>"control",
|
2014
|
+
"id" =>"d49567a31855a8d83ce13e3d2169d753c7d117cb97739744d34a976b1ee6cdae",
|
2015
|
+
"position" =>1,
|
2016
|
+
"asset_id" =>"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
|
2017
|
+
"asset_alias" =>"BTM",
|
2018
|
+
"asset_definition" => {
|
2019
|
+
"decimals" =>8,
|
2020
|
+
"description" =>"Bytom Official Issue",
|
2021
|
+
"name" =>"BTM",
|
2022
|
+
"symbol" =>"BTM"
|
2023
|
+
},
|
2024
|
+
"amount" =>1000000000,
|
2025
|
+
"account_id" =>"0NO14DLP00A02",
|
2026
|
+
"account_alias" =>"dayone_account_001",
|
2027
|
+
"control_program" =>"0014fdc6aa799423e32d20cea88ae0026bca3ec519a9",
|
2028
|
+
"address" =>"tm1qlhr257v5y03j6gxw4z9wqqnteglv2xdf6jcc02"
|
2029
|
+
}
|
2030
|
+
],
|
2031
|
+
"status_fail" =>false,
|
2032
|
+
"size" =>335
|
2033
|
+
}
|
2034
|
+
]
|
2035
|
+
}
|
2036
|
+
```
|
2037
|
+
|
2038
|
+
----
|
2039
|
+
|
2040
|
+
#### `build-transaction`
|
2041
|
+
|
2042
|
+
Build transaction.
|
2043
|
+
|
2044
|
+
##### Parameters
|
2045
|
+
|
2046
|
+
`Object`:
|
2047
|
+
|
2048
|
+
- `String` - *base_transaction*, base data for the transaction, default is null.
|
2049
|
+
- `Integer` - *ttl*, integer of the time to live in milliseconds, it means utxo will be reserved(locked) for builded transaction in this time range, if the transaction will not to be submitted into block, it will be auto unlocked for build transaction again after this ttl time. it will be set to 5 minutes(300 seconds) defaultly when ttl is 0.
|
2050
|
+
- `Integer` - *time_range*, the block height at which this transaction will be allowed to be included in a block. If the block height of the main chain exceeds this value, the transaction will expire and no longer be valid.
|
2051
|
+
- `Arrary of Object` - *actions*:
|
2052
|
+
- `Object`:
|
2053
|
+
- `String` - *account_id* | *account_alias*, (type is spend_account) alias or ID of account.
|
2054
|
+
- `String` - *asset_id* | *asset_alias*, (type is spend_account, issue, retire, control_program and control_address) alias or ID of asset.
|
2055
|
+
- `Integer` - *amount*, (type is spend_account, issue, retire, control_program and control_address) the specified asset of the amount sent with this transaction.
|
2056
|
+
- `String`- *type*, type of transaction, valid types: 'spend_account', 'issue', 'spend_account_unspent_output', 'control_address', 'control_program', 'retire'.
|
2057
|
+
- `String` - *address*, (type is control_address) address of receiver, the style of address is P2PKH or P2SH.
|
2058
|
+
- `String` - *control_program*, (type is control_program) control program of receiver.
|
2059
|
+
- `String` - *use_unconfirmed*, (type is spend_account and spend_account_unspent_output) flag of use unconfirmed UTXO, default is false.
|
2060
|
+
- `String` - *arbitrary*, (type is retire) arbitrary additional data by hexadecimal.
|
2061
|
+
- `Arrary of Object` - *arguments*, (type is issue and spend_account_unspent_output) arguments of contract, null when it's not contract.
|
2062
|
+
- `String`- *type*, type of argument, valid types: 'raw_tx_signature', 'data'.
|
2063
|
+
- `Object`- *raw_data*, json object of argument content.
|
2064
|
+
- `String`- *xpub*, (type is raw_tx_signature) root xpub.
|
2065
|
+
- `String`- *derivation_path*, (type is raw_tx_signature) derived path.
|
2066
|
+
- `String`- *value*, (type is data) string of binary value.
|
2067
|
+
|
2068
|
+
##### Returns
|
2069
|
+
|
2070
|
+
- `Object of build-transaction` - *transaction*, builded transaction.
|
2071
|
+
|
2072
|
+
##### Example
|
2073
|
+
|
2074
|
+
- `spend` - transaction type is spend
|
2075
|
+
```ruby
|
2076
|
+
bytom_client = Bytom::Client.new(base_url: 'http://127.0.0.1:9888')
|
2077
|
+
actions = [
|
2078
|
+
{
|
2079
|
+
account_id: "0NO14VPOG0A04",
|
2080
|
+
amount: 20000000,
|
2081
|
+
asset_id: "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
|
2082
|
+
type: "spend_account"
|
2083
|
+
},
|
2084
|
+
{
|
2085
|
+
account_id: "0NO14DLP00A02",
|
2086
|
+
amount: 99,
|
2087
|
+
asset_id: "9bd4bcc1e8a84ecabcd8e9f751181bc35e9377c91e46e1eb92f2c30767a67840",
|
2088
|
+
type: "spend_account"
|
2089
|
+
},
|
2090
|
+
{
|
2091
|
+
amount: 99,
|
2092
|
+
asset_id: "9bd4bcc1e8a84ecabcd8e9f751181bc35e9377c91e46e1eb92f2c30767a67840",
|
2093
|
+
address: "tm1qgpw5p3t750jyapx8ecqjyvs5mkcr45h786ed32",
|
2094
|
+
type: "control_address"
|
2095
|
+
}
|
2096
|
+
]
|
2097
|
+
bytom_client.transactions.build_transaction(
|
2098
|
+
base_transaction: nil,
|
2099
|
+
ttl: 0,
|
2100
|
+
time_range: 43432,
|
2101
|
+
actions: actions
|
2102
|
+
)
|
2103
|
+
|
2104
|
+
// Request
|
2105
|
+
curl -X POST build-transaction -d '{"base_transaction":null,"actions":[{"account_id":"0BF63M2U00A04","amount":20000000,"asset_id":"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff","type":"spend_account"},{"account_id":"0BF63M2U00A04","amount":99,"asset_id":"3152a15da72be51b330e1c0f8e1c0db669269809da4f16443ff266e07cc43680","type":"spend_account"},{"amount":99,"asset_id":"3152a15da72be51b330e1c0f8e1c0db669269809da4f16443ff266e07cc43680","address":"bm1q50u3z8empm5ke0g3ngl2t3sqtr6sd7cepd3z68","type":"control_address"}],"ttl":0,"time_range": 43432}'
|
2106
|
+
```
|
2107
|
+
|
2108
|
+
- `issue` - transaction type is issue
|
2109
|
+
```ruby
|
2110
|
+
#bytom_client = Bytom::Client.new(base_url: 'http://127.0.0.1:9888')
|
2111
|
+
actions = [
|
2112
|
+
{
|
2113
|
+
account_id:"0NO14DLP00A02",
|
2114
|
+
amount: 20000000,
|
2115
|
+
asset_id:"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
|
2116
|
+
type:"spend_account"
|
2117
|
+
},
|
2118
|
+
{
|
2119
|
+
amount:10000,
|
2120
|
+
asset_id:"41b2c7a02e610c9e7117e5b2407573b953b3ebbec90302cf217ecaf134851622",
|
2121
|
+
type:"issue"
|
2122
|
+
},
|
2123
|
+
{
|
2124
|
+
amount:10000,
|
2125
|
+
asset_id: "41b2c7a02e610c9e7117e5b2407573b953b3ebbec90302cf217ecaf134851622",
|
2126
|
+
address: "tm1q20gt090mcfz7cn0urg6dy22ec327deseew7vtz",
|
2127
|
+
type: "control_address"
|
2128
|
+
}
|
2129
|
+
]
|
2130
|
+
|
2131
|
+
bytom_client.transactions.build_transaction(
|
2132
|
+
base_transaction: nil,
|
2133
|
+
ttl: 0,
|
2134
|
+
time_range: 43432,
|
2135
|
+
actions: actions
|
2136
|
+
)
|
2137
|
+
|
2138
|
+
# response data
|
2139
|
+
|
2140
|
+
{
|
2141
|
+
"status" =>"success",
|
2142
|
+
"data" => {
|
2143
|
+
"raw_transaction" =>"0701a8d302020160015e5835d2a35141e44415bfb2277e0ba370cd43336931cfa31eff23db31ccd45394ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8094ebdc030101160014fdc6aa799423e32d20cea88ae0026bca3ec519a90100012c0008dbb2c6821a7487f241b2c7a02e610c9e7117e5b2407573b953b3ebbec90302cf217ecaf134851622904e2b027b7d0125ae204c09d66bfad30f9017ad2283484f3931810bfe7821f75427cb1417bac08b48885151ad0002013dffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff80baa6d303011600149ff0508a1fffcfb63028882085bfdb771a9fe39b00013a41b2c7a02e610c9e7117e5b2407573b953b3ebbec90302cf217ecaf134851622904e0116001453d0b795fbc245ec4dfc1a34d22959c455e6e61900",
|
2144
|
+
"signing_instructions" => [
|
2145
|
+
{
|
2146
|
+
"position" =>0,
|
2147
|
+
"witness_components" => [
|
2148
|
+
{
|
2149
|
+
"type" =>"raw_tx_signature",
|
2150
|
+
"quorum" =>1,
|
2151
|
+
"keys" => [
|
2152
|
+
{
|
2153
|
+
"xpub" =>"f788208af6d16ce5ae523256caedf8b9463f9cdfa33f58aa1ffde0b673c98769ceb9299052bddd6c8436d749500198635d77682eae565378ac16d1b9ba574e5f",
|
2154
|
+
"derivation_path" => [
|
2155
|
+
"2c000000",
|
2156
|
+
"99000000",
|
2157
|
+
"01000000",
|
2158
|
+
"00000000",
|
2159
|
+
"02000000"
|
2160
|
+
]
|
2161
|
+
}
|
2162
|
+
],
|
2163
|
+
"signatures" =>nil
|
2164
|
+
},
|
2165
|
+
{
|
2166
|
+
"type" =>"data",
|
2167
|
+
"value" =>"866b276a6c55a3925fda2708883321dc1dde9004503291d3255a296382618c4a"
|
2168
|
+
}
|
2169
|
+
]
|
2170
|
+
},
|
2171
|
+
{
|
2172
|
+
"position" =>1,
|
2173
|
+
"witness_components" => [
|
2174
|
+
{
|
2175
|
+
"type" =>"raw_tx_signature",
|
2176
|
+
"quorum" =>1,
|
2177
|
+
"keys" => [
|
2178
|
+
{
|
2179
|
+
"xpub" =>"f788208af6d16ce5ae523256caedf8b9463f9cdfa33f58aa1ffde0b673c98769ceb9299052bddd6c8436d749500198635d77682eae565378ac16d1b9ba574e5f",
|
2180
|
+
"derivation_path" => [
|
2181
|
+
"000300000000000000"
|
2182
|
+
]
|
2183
|
+
}
|
2184
|
+
],
|
2185
|
+
"signatures" =>nil
|
2186
|
+
}
|
2187
|
+
]
|
2188
|
+
}
|
2189
|
+
],
|
2190
|
+
"fee" =>20000000,
|
2191
|
+
"allow_additional_actions" =>false
|
2192
|
+
}
|
2193
|
+
}
|
2194
|
+
|
2195
|
+
|
2196
|
+
# Request
|
2197
|
+
curl -X POST http://127.0.0.1:9888/build-transaction -d '{"base_transaction":null,"actions":[{"account_id":"0NO14DLP00A02","amount":20000000,"asset_id":"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff","type":"spend_account"},{"amount":10000,"asset_id":"41b2c7a02e610c9e7117e5b2407573b953b3ebbec90302cf217ecaf134851622","type":"issue"},{"amount":10000,"asset_id":"41b2c7a02e610c9e7117e5b2407573b953b3ebbec90302cf217ecaf134851622","address":"tm1q20gt090mcfz7cn0urg6dy22ec327deseew7vtz","type":"control_address"}],"ttl":0,"time_range": 43432}'
|
2198
|
+
```
|
2199
|
+
|
2200
|
+
- `address` - transaction type is address
|
2201
|
+
```js
|
2202
|
+
actions = [
|
2203
|
+
{
|
2204
|
+
account_id:"0NO14DLP00A02",
|
2205
|
+
amount: 20000000,
|
2206
|
+
asset_id:"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
|
2207
|
+
type:"spend_account"
|
2208
|
+
},
|
2209
|
+
{
|
2210
|
+
amount:10000,
|
2211
|
+
amount: 99,
|
2212
|
+
asset_id:"41b2c7a02e610c9e7117e5b2407573b953b3ebbec90302cf217ecaf134851622",
|
2213
|
+
type:"spend_account"
|
2214
|
+
},
|
2215
|
+
{
|
2216
|
+
amount:10000,
|
2217
|
+
asset_id: "41b2c7a02e610c9e7117e5b2407573b953b3ebbec90302cf217ecaf134851622",
|
2218
|
+
address: "tm1q20gt090mcfz7cn0urg6dy22ec327deseew7vtz",
|
2219
|
+
type: "control_address"
|
2220
|
+
}
|
2221
|
+
]
|
2222
|
+
|
2223
|
+
bytom_client.transactions.build_transaction(
|
2224
|
+
base_transaction: nil,
|
2225
|
+
ttl: 0,
|
2226
|
+
time_range: 43432,
|
2227
|
+
actions: actions
|
2228
|
+
)
|
2229
|
+
|
2230
|
+
|
2231
|
+
// Request
|
2232
|
+
curl -X POST build-transaction -d '{"base_transaction":null,"actions":[{"account_id":"0BF63M2U00A04","amount":20000000,"asset_id":"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff","type":"spend_account"},{"account_id":"0BF63M2U00A04","amount":99,"asset_id":"3152a15da72be51b330e1c0f8e1c0db669269809da4f16443ff266e07cc43680","type":"spend_account"},{"amount":99,"asset_id":"3152a15da72be51b330e1c0f8e1c0db669269809da4f16443ff266e07cc43680","address":"bm1q50u3z8empm5ke0g3ngl2t3sqtr6sd7cepd3z68","type":"control_address"}],"ttl":0,"time_range": 43432}'
|
2233
|
+
```
|
2234
|
+
|
2235
|
+
- `retire` - transaction type is retire
|
2236
|
+
```ruby
|
2237
|
+
actions = [
|
2238
|
+
{
|
2239
|
+
account_id:"0NO14DLP00A02",
|
2240
|
+
amount: 20000000,
|
2241
|
+
asset_id:"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
|
2242
|
+
type:"spend_account"
|
2243
|
+
},
|
2244
|
+
{
|
2245
|
+
amount:10000,
|
2246
|
+
amount: 99,
|
2247
|
+
asset_id:"41b2c7a02e610c9e7117e5b2407573b953b3ebbec90302cf217ecaf134851622",
|
2248
|
+
type:"spend_account"
|
2249
|
+
},
|
2250
|
+
{
|
2251
|
+
amount:10000,
|
2252
|
+
asset_id: "41b2c7a02e610c9e7117e5b2407573b953b3ebbec90302cf217ecaf134851622",
|
2253
|
+
arbitrary:"77656c636f6d65efbc8ce6aca2e8bf8ee69da5e588b0e58e9fe5ad90e4b896e7958c",
|
2254
|
+
type: "retire"
|
2255
|
+
}
|
2256
|
+
]
|
2257
|
+
|
2258
|
+
bytom_client.transactions.build_transaction(
|
2259
|
+
base_transaction: nil,
|
2260
|
+
ttl: 0,
|
2261
|
+
time_range: 43432,
|
2262
|
+
actions: actions
|
2263
|
+
)
|
2264
|
+
# Request
|
2265
|
+
curl -X POST build-transaction -d '{"base_transaction":null,"actions":[{"account_id":"0BF63M2U00A04","amount":20000000,"asset_id":"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff","type":"spend_account"},{"account_id":"0BF63M2U00A04","amount":99,"asset_id":"3152a15da72be51b330e1c0f8e1c0db669269809da4f16443ff266e07cc43680","type":"spend_account"},{"amount":99,"asset_id":"3152a15da72be51b330e1c0f8e1c0db669269809da4f16443ff266e07cc43680","arbitrary":"77656c636f6d65efbc8ce6aca2e8bf8ee69da5e588b0e58e9fe5ad90e4b896e7958c","type":"retire"}],"ttl":0,"time_range":43432}'
|
2266
|
+
```
|
2267
|
+
|
2268
|
+
- `spend_account_unspent_output` - transaction type is spend_account_unspent_output(user can get UTXO information by call `list-unspent-outputs` API)
|
2269
|
+
|
2270
|
+
attention:
|
2271
|
+
- action field `output_id` correspond to UTXO result `id` field
|
2272
|
+
- UTXO asset and amount will be spent in this transaction
|
2273
|
+
- transaction fee is (utxo asset_amount - output asset_amount)
|
2274
|
+
|
2275
|
+
```js
|
2276
|
+
|
2277
|
+
actions = [
|
2278
|
+
{
|
2279
|
+
type:"spend_account_unspent_output",
|
2280
|
+
output_id:"01c6ccc6f522228cd4518bba87e9c43fbf55fdf7eb17f5aa300a037db7dca0cb"
|
2281
|
+
},
|
2282
|
+
{
|
2283
|
+
amount:41243000000,
|
2284
|
+
asset_id:"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
|
2285
|
+
address:"sm1qmw8c5s29zlexknfahrze3ghvlqrtn2huuntvpn",
|
2286
|
+
type:"control_address"
|
2287
|
+
}
|
2288
|
+
]
|
2289
|
+
|
2290
|
+
bytom_client.transactions.build_transaction(
|
2291
|
+
base_transaction: nil,
|
2292
|
+
ttl: 0,
|
2293
|
+
time_range: 43432,
|
2294
|
+
actions: actions
|
2295
|
+
)
|
2296
|
+
// Request
|
2297
|
+
curl -X POST build-transaction -d '{"base_transaction":null,"actions":[{"type":"spend_account_unspent_output","output_id":"01c6ccc6f522228cd4518bba87e9c43fbf55fdf7eb17f5aa300a037db7dca0cb"},{"amount":41243000000,"asset_id":"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff","address":"sm1qmw8c5s29zlexknfahrze3ghvlqrtn2huuntvpn","type":"control_address"}],"ttl":0,"time_range":0}'
|
2298
|
+
```
|
2299
|
+
|
2300
|
+
```js
|
2301
|
+
// Result(this type is spend, the other types are similar.)
|
2302
|
+
{
|
2303
|
+
"allow_additional_actions": false,
|
2304
|
+
"local": true,
|
2305
|
+
"raw_transaction": "07010000020161015fb6a63a3361170afca03c9d5ce1f09fe510187d69545e09f95548b939cd7fffa3ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff80fc93afdf01000116001426bd1b851cf6eb8a701c20c184352ad8720eeee90100015d015bb6a63a3361170afca03c9d5ce1f09fe510187d69545e09f95548b939cd7fffa33152a15da72be51b330e1c0f8e1c0db669269809da4f16443ff266e07cc43680c03e0101160014489a678741ccc844f9e5c502f7fac0a665bedb25010003013effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff80a2cfa5df0101160014948fb4f500e66d20fbacb903fe108ee81f9b6d9500013a3152a15da72be51b330e1c0f8e1c0db669269809da4f16443ff266e07cc43680dd3d01160014cd5a822b34e3084413506076040d508bb12232c70001393152a15da72be51b330e1c0f8e1c0db669269809da4f16443ff266e07cc436806301160014a3f9111f3b0ee96cbd119a3ea5c60058f506fb1900",
|
2306
|
+
"signing_instructions": [
|
2307
|
+
{
|
2308
|
+
"position": 0,
|
2309
|
+
"witness_components": [
|
2310
|
+
{
|
2311
|
+
"keys": [
|
2312
|
+
{
|
2313
|
+
"derivation_path": [
|
2314
|
+
"010100000000000000",
|
2315
|
+
"0500000000000000"
|
2316
|
+
],
|
2317
|
+
"xpub": "ee9dd8affdef7e0cacd0fbbf310217c7f588156c28e414db74c27afaedd8f876cf54547a672b431ff06ee8a146207df9595638a041b55ada1a764a8b5b30bda0"
|
2318
|
+
}
|
2319
|
+
],
|
2320
|
+
"quorum": 1,
|
2321
|
+
"signatures": null,
|
2322
|
+
"type": "raw_tx_signature"
|
2323
|
+
},
|
2324
|
+
{
|
2325
|
+
"type": "data",
|
2326
|
+
"value": "62a73b6b7ffe52b6ad782b0e0efdc8309bf2f057d88f9a17d125e41bb11dbb88"
|
2327
|
+
}
|
2328
|
+
]
|
2329
|
+
},
|
2330
|
+
{
|
2331
|
+
"position": 1,
|
2332
|
+
"witness_components": [
|
2333
|
+
{
|
2334
|
+
"keys": [
|
2335
|
+
{
|
2336
|
+
"derivation_path": [
|
2337
|
+
"010100000000000000",
|
2338
|
+
"0600000000000000"
|
2339
|
+
],
|
2340
|
+
"xpub": "ee9dd8affdef7e0cacd0fbbf310217c7f588156c28e414db74c27afaedd8f876cf54547a672b431ff06ee8a146207df9595638a041b55ada1a764a8b5b30bda0"
|
2341
|
+
}
|
2342
|
+
],
|
2343
|
+
"quorum": 1,
|
2344
|
+
"signatures": null,
|
2345
|
+
"type": "raw_tx_signature"
|
2346
|
+
},
|
2347
|
+
{
|
2348
|
+
"type": "data",
|
2349
|
+
"value": "ba5a63e7416caeb945eefc2ce874f40bc4aaf6005a1fc792557e41046f7e502f"
|
2350
|
+
}
|
2351
|
+
]
|
2352
|
+
}
|
2353
|
+
]
|
2354
|
+
}
|
2355
|
+
```
|
2356
|
+
|
2357
|
+
----
|
2358
|
+
#### `build-chain-transactions`
|
2359
|
+
Build chain transactions. To solve the problem of excessive utxo causing the transaction to fail, the utxo merge will be performed automatically. Currently, only btm transactions are supported.Warning, this feature requires the mine pool bytomd software to be higher than v1.0.6.
|
2360
|
+
|
2361
|
+
|
2362
|
+
##### Parameters
|
2363
|
+
|
2364
|
+
`Object`:
|
2365
|
+
|
2366
|
+
- `String` - *base_transaction*, base data for the transaction, default is null.
|
2367
|
+
- `Integer` - *ttl*, integer of the time to live in milliseconds, it means utxo will be reserved(locked) for builded transaction in this time range, if the transaction will not to be submitted into block, it will be auto unlocked for build transaction again after this ttl time. it will be set to 5 minutes(300 seconds) defaultly when ttl is 0.
|
2368
|
+
- `Integer` - *time_range*, time stamp(block height)is maximum survival time for the transaction, the transaction will be not submit into block after this time stamp.
|
2369
|
+
- `Arrary of Object` - *actions*:
|
2370
|
+
- `Object`:
|
2371
|
+
- `String` - *account_id* | *account_alias*, (type is spend_account) alias or ID of account.
|
2372
|
+
- `String` - *asset_id* | *asset_alias*, (type is spend_account, issue, retire, control_program and control_address) alias or ID of asset.
|
2373
|
+
- `Integer` - *amount*, (type is spend_account, issue, retire, control_program and control_address) the specified asset of the amount sent with this transaction.
|
2374
|
+
- `String`- *type*, type of transaction, valid types: 'spend_account', 'issue', 'spend_account_unspent_output', 'control_address', 'control_program', 'retire'.
|
2375
|
+
- `String` - *address*, (type is control_address) address of receiver, the style of address is P2PKH or P2SH.
|
2376
|
+
- `String` - *control_program*, (type is control_program) control program of receiver.
|
2377
|
+
- `String` - *use_unconfirmed*, (type is spend_account and spend_account_unspent_output) flag of use unconfirmed UTXO, default is false.
|
2378
|
+
- `Arrary of Object` - *arguments*, (type is issue and spend_account_unspent_output) arguments of contract, null when it's not contract.
|
2379
|
+
- `String`- *type*, type of argument, valid types: 'raw_tx_signature', 'data'.
|
2380
|
+
- `Object`- *raw_data*, json object of argument content.
|
2381
|
+
- `String`- *xpub*, (type is raw_tx_signature) root xpub.
|
2382
|
+
- `String`- *derivation_path*, (type is raw_tx_signature) derived path.
|
2383
|
+
- `String`- *value*, (type is data) string of binary value.
|
2384
|
+
|
2385
|
+
##### Returns
|
2386
|
+
|
2387
|
+
- `Object of raw_transaction` - *raw_transaction*, builded transactions.
|
2388
|
+
- `Object of signing_instructions` - *signing_instructions*, Information used to sign a transactions.
|
2389
|
+
##### Example
|
2390
|
+
|
2391
|
+
- `spend` - transaction type is spend
|
2392
|
+
```js
|
2393
|
+
actions = [
|
2394
|
+
{
|
2395
|
+
account_id:"0JCH28A600A02",
|
2396
|
+
amount:30000500000000,
|
2397
|
+
asset_id:"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
|
2398
|
+
type:"spend_account"
|
2399
|
+
},
|
2400
|
+
{
|
2401
|
+
amount:30000490000000,
|
2402
|
+
asset_id:"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
|
2403
|
+
address:"sm1qx93sge8jkgzclc7pled7uqr596hjm2xe558lkr",
|
2404
|
+
type:"control_address"
|
2405
|
+
}
|
2406
|
+
]
|
2407
|
+
|
2408
|
+
bytom_client.transactions.build_chain_transactions(
|
2409
|
+
base_transaction: nil,
|
2410
|
+
ttl: 0,
|
2411
|
+
time_range: 43432,
|
2412
|
+
actions: actions
|
2413
|
+
)
|
2414
|
+
|
2415
|
+
|
2416
|
+
// Request
|
2417
|
+
curl -X POST localhost:9888/build-chain-transactions -d '{"base_transaction": null,"actions":[{"account_id":"0JCH28A600A02","amount":30000500000000,"asset_id":"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff","type": "spend_account"}, {"amount": 30000490000000,"asset_id": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff","address": "sm1qx93sge8jkgzclc7pled7uqr596hjm2xe558lkr","type": "control_address"}],"ttl": 1000000,"time_range": 0}'
|
2418
|
+
```
|
2419
|
+
|
2420
|
+
|
2421
|
+
|
2422
|
+
----
|
2423
|
+
|
2424
|
+
#### `sign-transaction`
|
2425
|
+
|
2426
|
+
Sign transaction.
|
2427
|
+
|
2428
|
+
##### Parameters
|
2429
|
+
|
2430
|
+
`Object`:
|
2431
|
+
|
2432
|
+
- `String` - *password*, signature of the password.
|
2433
|
+
- `Object` - *transaction*, builded transaction.
|
2434
|
+
|
2435
|
+
##### Returns
|
2436
|
+
|
2437
|
+
`Object`:
|
2438
|
+
|
2439
|
+
- `Boolean` - *sign_complete*, returns true if sign succesfully and false otherwise.
|
2440
|
+
- `Object of sign-transaction` - *transaction*, signed transaction.
|
2441
|
+
|
2442
|
+
##### Example
|
2443
|
+
|
2444
|
+
```ruby
|
2445
|
+
# Step 1: Build transaction
|
2446
|
+
actions = [
|
2447
|
+
{
|
2448
|
+
account_id:"0NO14DLP00A02",
|
2449
|
+
amount: 20000000,
|
2450
|
+
asset_id:"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
|
2451
|
+
type:"spend_account"
|
2452
|
+
},
|
2453
|
+
{
|
2454
|
+
amount:10000,
|
2455
|
+
asset_id:"41b2c7a02e610c9e7117e5b2407573b953b3ebbec90302cf217ecaf134851622",
|
2456
|
+
type:"issue"
|
2457
|
+
},
|
2458
|
+
{
|
2459
|
+
amount:10000,
|
2460
|
+
asset_id: "41b2c7a02e610c9e7117e5b2407573b953b3ebbec90302cf217ecaf134851622",
|
2461
|
+
address: "tm1q20gt090mcfz7cn0urg6dy22ec327deseew7vtz",
|
2462
|
+
type: "control_address"
|
2463
|
+
}
|
2464
|
+
]
|
2465
|
+
|
2466
|
+
res = bytom_client.transactions.build_transaction(
|
2467
|
+
base_transaction: nil,
|
2468
|
+
ttl: 0,
|
2469
|
+
time_range: 43432,
|
2470
|
+
actions: actions
|
2471
|
+
)
|
2472
|
+
|
2473
|
+
# Step 2 Sign transaction
|
2474
|
+
transaction = {
|
2475
|
+
allow_additional_actions: false,
|
2476
|
+
local: true,
|
2477
|
+
raw_transaction: res['data']['raw_transaction'],
|
2478
|
+
signing_instructions: res['data']['signing_instructions']
|
2479
|
+
}
|
2480
|
+
sign_data = bytom_client.transactions.sign_transaction(
|
2481
|
+
password: '123456',
|
2482
|
+
transaction: transaction
|
2483
|
+
)
|
2484
|
+
|
2485
|
+
# response data
|
2486
|
+
{
|
2487
|
+
"status" =>"success",
|
2488
|
+
"data" => {
|
2489
|
+
"transaction" => {
|
2490
|
+
"raw_transaction" =>"0701a8d302020160015e5835d2a35141e44415bfb2277e0ba370cd43336931cfa31eff23db31ccd45394ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8094ebdc030101160014fdc6aa799423e32d20cea88ae0026bca3ec519a9220120866b276a6c55a3925fda2708883321dc1dde9004503291d3255a296382618c4a012c00086159bec99f1a083d41b2c7a02e610c9e7117e5b2407573b953b3ebbec90302cf217ecaf134851622904e2b027b7d0125ae204c09d66bfad30f9017ad2283484f3931810bfe7821f75427cb1417bac08b48885151ad0002013dffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff80baa6d303011600149a9965716d974e3e9d797998359db12091db731500013a41b2c7a02e610c9e7117e5b2407573b953b3ebbec90302cf217ecaf134851622904e0116001453d0b795fbc245ec4dfc1a34d22959c455e6e61900",
|
2491
|
+
"signing_instructions" => [
|
2492
|
+
{
|
2493
|
+
"position" =>0,
|
2494
|
+
"witness_components" => [
|
2495
|
+
{
|
2496
|
+
"type" =>"raw_tx_signature",
|
2497
|
+
"quorum" =>1,
|
2498
|
+
"keys" => [
|
2499
|
+
{
|
2500
|
+
"xpub" =>"f788208af6d16ce5ae523256caedf8b9463f9cdfa33f58aa1ffde0b673c98769ceb9299052bddd6c8436d749500198635d77682eae565378ac16d1b9ba574e5f",
|
2501
|
+
"derivation_path" => [
|
2502
|
+
"2c000000",
|
2503
|
+
"99000000",
|
2504
|
+
"01000000",
|
2505
|
+
"00000000",
|
2506
|
+
"02000000"
|
2507
|
+
]
|
2508
|
+
}
|
2509
|
+
],
|
2510
|
+
"signatures" => [
|
2511
|
+
""
|
2512
|
+
]
|
2513
|
+
},
|
2514
|
+
{
|
2515
|
+
"type" =>"data",
|
2516
|
+
"value" =>"866b276a6c55a3925fda2708883321dc1dde9004503291d3255a296382618c4a"
|
2517
|
+
}
|
2518
|
+
]
|
2519
|
+
},
|
2520
|
+
{
|
2521
|
+
"position" =>1,
|
2522
|
+
"witness_components" => [
|
2523
|
+
{
|
2524
|
+
"type" =>"raw_tx_signature",
|
2525
|
+
"quorum" =>1,
|
2526
|
+
"keys" => [
|
2527
|
+
{
|
2528
|
+
"xpub" =>"f788208af6d16ce5ae523256caedf8b9463f9cdfa33f58aa1ffde0b673c98769ceb9299052bddd6c8436d749500198635d77682eae565378ac16d1b9ba574e5f",
|
2529
|
+
"derivation_path" => [
|
2530
|
+
"000300000000000000"
|
2531
|
+
]
|
2532
|
+
}
|
2533
|
+
],
|
2534
|
+
"signatures" => [
|
2535
|
+
""
|
2536
|
+
]
|
2537
|
+
}
|
2538
|
+
]
|
2539
|
+
}
|
2540
|
+
],
|
2541
|
+
"fee" =>0,
|
2542
|
+
"allow_additional_actions" =>false
|
2543
|
+
},
|
2544
|
+
"sign_complete" =>false
|
2545
|
+
}
|
2546
|
+
}
|
2547
|
+
```
|
2548
|
+
----
|
2549
|
+
|
2550
|
+
#### `sign-transactions`
|
2551
|
+
|
2552
|
+
Sign transactions used for batch signing transactions.
|
2553
|
+
|
2554
|
+
##### Parameters
|
2555
|
+
|
2556
|
+
`Object`:
|
2557
|
+
|
2558
|
+
- `String` - *password*, signature of the password.
|
2559
|
+
- `Object` - *transaction*, builded transactions.
|
2560
|
+
|
2561
|
+
##### Returns
|
2562
|
+
|
2563
|
+
`Object`:
|
2564
|
+
|
2565
|
+
- `Boolean` - *sign_complete*, returns true if sign succesfully and false otherwise.
|
2566
|
+
- `Object of sign-transactions` - *transaction*, signed transactions.
|
2567
|
+
|
2568
|
+
##### Example
|
2569
|
+
|
2570
|
+
```ruby
|
2571
|
+
transaction1 = {
|
2572
|
+
allow_additional_actions: false,
|
2573
|
+
local: true,
|
2574
|
+
raw_transaction: res['data']['raw_transaction'],
|
2575
|
+
signing_instructions: res['data']['signing_instructions']
|
2576
|
+
}
|
2577
|
+
transaction2 = {
|
2578
|
+
allow_additional_actions: false,
|
2579
|
+
local: true,
|
2580
|
+
raw_transaction: res2['data']['raw_transaction'],
|
2581
|
+
signing_instructions: res2['data']['signing_instructions']
|
2582
|
+
}
|
2583
|
+
sign_data = bytom_client.transactions.sign_transactions(
|
2584
|
+
password: '123456',
|
2585
|
+
transactions: [
|
2586
|
+
transaction1, transaction2
|
2587
|
+
]
|
2588
|
+
)
|
2589
|
+
|
2590
|
+
# Request
|
2591
|
+
curl -X POST localhost:9888/sign-transactions -d '{"password":"123456","transactions":[{"raw_transaction":"0701000201620160a0d36052ca3d1335120ae48e1ffb2fb6b25588628eff90fa88bef3117dfb4301ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff80ddb2c490e906010116001431630464f2b2058fe3c1fe5bee00742eaf2da8d901000161015f72de2064ab999acf22c05b5cf9c7d53164f80038b46b1ce426708514a30a3485ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff80d4f4f69901000116001431630464f2b2058fe3c1fe5bee00742eaf2da8d9010001013fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8084c5b6aaea060116001431630464f2b2058fe3c1fe5bee00742eaf2da8d900","signing_instructions":[{"position":0,"witness_components":[{"type":"raw_tx_signature","quorum":1,"keys":[{"xpub":"b4d084e77bcda7fd8a37e31135200b2a6af98d19018674125dc6290dd14176f92523f229d9f1f3514b461f6931ac2073f586a35cd628c90270063725e6e1e983","derivation_path":["010100000000000000","0100000000000000"]}],"signatures":null},{"type":"data","value":"a86ab33efa9d71994270898ad99f198d60889ef617d5eaf25e776929a8973919"}]},{"position":1,"witness_components":[{"type":"raw_tx_signature","quorum":1,"keys":[{"xpub":"b4d084e77bcda7fd8a37e31135200b2a6af98d19018674125dc6290dd14176f92523f229d9f1f3514b461f6931ac2073f586a35cd628c90270063725e6e1e983","derivation_path":["010100000000000000","0100000000000000"]}],"signatures":null},{"type":"data","value":"a86ab33efa9d71994270898ad99f198d60889ef617d5eaf25e776929a8973919"}]}],"allow_additional_actions":false},{"raw_transaction":"0701000101620160571cc5d99a2994ff6b192bc9387838a3651245cb66dad4a6bc5f660310cebfa9ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8084c5b6aaea06000116001431630464f2b2058fe3c1fe5bee00742eaf2da8d9010002013effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff80faafed99010116001431630464f2b2058fe3c1fe5bee00742eaf2da8d900013fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff80ddb2c490e9060116001431630464f2b2058fe3c1fe5bee00742eaf2da8d900","signing_instructions":[{"position":0,"witness_components":[{"type":"raw_tx_signature","quorum":1,"keys":[{"xpub":"b4d084e77bcda7fd8a37e31135200b2a6af98d19018674125dc6290dd14176f92523f229d9f1f3514b461f6931ac2073f586a35cd628c90270063725e6e1e983","derivation_path":["010100000000000000","0100000000000000"]}],"signatures":null},{"type":"data","value":"a86ab33efa9d71994270898ad99f198d60889ef617d5eaf25e776929a8973919"}]}],"allow_additional_actions":false}]}'
|
2592
|
+
```
|
2593
|
+
|
2594
|
+
----
|
2595
|
+
|
2596
|
+
#### `submit-transaction`
|
2597
|
+
|
2598
|
+
Submit transaction.
|
2599
|
+
|
2600
|
+
##### Parameters
|
2601
|
+
|
2602
|
+
`Object`:
|
2603
|
+
|
2604
|
+
- `Object` - *raw_transaction*, raw_transaction of signed transaction.
|
2605
|
+
|
2606
|
+
##### Returns
|
2607
|
+
|
2608
|
+
`Object`:
|
2609
|
+
|
2610
|
+
- `String` - *tx_id*, transaction id, hash of transaction.
|
2611
|
+
|
2612
|
+
##### Example
|
2613
|
+
|
2614
|
+
```ruby
|
2615
|
+
bytom_client.transactions.submit_transaction(
|
2616
|
+
raw_transaction: '0701a8d302020160015e5835d2a35141e44415bfb2277e0ba370cd43336931cfa31eff23db31ccd45394ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8094ebdc030101160014fdc6aa799423e32d20cea88ae0026bca3ec519a9220120866b276a6c55a3925fda2708883321dc1dde9004503291d3255a296382618c4a012c00086159bec99f1a083d41b2c7a02e610c9e7117e5b2407573b953b3ebbec90302cf217ecaf134851622904e2b027b7d0125ae204c09d66bfad30f9017ad2283484f3931810bfe7821f75427cb1417bac08b48885151ad0002013dffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff80baa6d303011600149a9965716d974e3e9d797998359db12091db731500013a41b2c7a02e610c9e7117e5b2407573b953b3ebbec90302cf217ecaf134851622904e0116001453d0b795fbc245ec4dfc1a34d22959c455e6e61900'
|
2617
|
+
)
|
2618
|
+
# response data
|
2619
|
+
{
|
2620
|
+
"tx_id": "2c0624a7d251c29d4d1ad14297c69919214e78d995affd57e73fbf84ece316cb"
|
2621
|
+
}
|
2622
|
+
```
|
2623
|
+
----
|
2624
|
+
|
2625
|
+
#### `submit-transactions`
|
2626
|
+
|
2627
|
+
Submit transactions used for batch submit transactions.
|
2628
|
+
|
2629
|
+
##### Parameters
|
2630
|
+
|
2631
|
+
`Object`:
|
2632
|
+
|
2633
|
+
- `Object` - *raw_transactions*, raw_transactions of signed transactions.
|
2634
|
+
|
2635
|
+
##### Returns
|
2636
|
+
|
2637
|
+
`Object`:
|
2638
|
+
|
2639
|
+
- `String` - *tx_id*, transactions id, hash of transactions.
|
2640
|
+
|
2641
|
+
##### Example
|
2642
|
+
|
2643
|
+
```ruby
|
2644
|
+
|
2645
|
+
bytom_client.transactions.submit_transaction(
|
2646
|
+
raw_transactions: [raw_transactions1, raw_transactions2]
|
2647
|
+
)
|
2648
|
+
|
2649
|
+
# Request
|
2650
|
+
curl -X POST localhost:9888/submit-transactions -d '{"raw_transactions":["0701000201620160a0d36052ca3d1335120ae48e1ffb2fb6b25588628eff90fa88bef3117dfb4301ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff80ddb2c490e906010116001431630464f2b2058fe3c1fe5bee00742eaf2da8d9630240acb57bc06f7e5de99ef3e630ce34fc74c33d4694301202968092ca50ae7842e3331bfeb0cf7b65f383e27670c4d58aeeeb0b77e5355957ca729298d2b4e2470c20a86ab33efa9d71994270898ad99f198d60889ef617d5eaf25e776929a89739190161015f72de2064ab999acf22c05b5cf9c7d53164f80038b46b1ce426708514a30a3485ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff80d4f4f69901000116001431630464f2b2058fe3c1fe5bee00742eaf2da8d96302404298424e89e5528f1d0cdd9028489b9d9e3f031ec34a74440cacc7900dc1eac9359c408a4342fc6cef935d2978919df8b23f3912ac4419800d375fac06ddb50620a86ab33efa9d71994270898ad99f198d60889ef617d5eaf25e776929a897391901013fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8084c5b6aaea060116001431630464f2b2058fe3c1fe5bee00742eaf2da8d900","0701000101620160571cc5d99a2994ff6b192bc9387838a3651245cb66dad4a6bc5f660310cebfa9ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8084c5b6aaea06000116001431630464f2b2058fe3c1fe5bee00742eaf2da8d96302408c742d77eba6c56a8db8c114e60be6c6263df6120aefd7538376129d04ec71b78b718c2085bba85254b44bf4600ba31d4c5a7869d0be0c46d88bd5eb27490e0820a86ab33efa9d71994270898ad99f198d60889ef617d5eaf25e776929a897391902013effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff80faafed99010116001431630464f2b2058fe3c1fe5bee00742eaf2da8d900013fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff80ddb2c490e9060116001431630464f2b2058fe3c1fe5bee00742eaf2da8d900"]}'
|
2651
|
+
```
|
2652
|
+
|
2653
|
+
----
|
2654
|
+
|
2655
|
+
#### `estimate-transaction-gas`
|
2656
|
+
|
2657
|
+
Estimate consumed neu(1BTM = 10^8NEU) for the transaction.
|
2658
|
+
|
2659
|
+
##### Parameters
|
2660
|
+
|
2661
|
+
`Object`:
|
2662
|
+
|
2663
|
+
- `Object` - *transaction_template*, builded transaction response.
|
2664
|
+
|
2665
|
+
##### Returns
|
2666
|
+
|
2667
|
+
`Object`:
|
2668
|
+
|
2669
|
+
- `Integer` - *total_neu*, total consumed neu(1BTM = 10^8NEU) for execute transaction, total_neu is rounded up storage_neu + vm_neu.
|
2670
|
+
- `Integer` - *storage_neu*, consumed neu for storage transaction .
|
2671
|
+
- `Integer` - *vm_neu*, consumed neu for execute VM.
|
2672
|
+
|
2673
|
+
##### Example
|
2674
|
+
|
2675
|
+
```ruby
|
2676
|
+
transaction_template = {
|
2677
|
+
allow_additional_actions: false,
|
2678
|
+
raw_transaction: res['data']['raw_transaction'],
|
2679
|
+
signing_instructions: res['data']['signing_instructions']
|
2680
|
+
}
|
2681
|
+
bytom_client.transactions.estimate_transaction_gas(
|
2682
|
+
transaction_template: transaction_template
|
2683
|
+
)
|
2684
|
+
|
2685
|
+
|
2686
|
+
// Request
|
2687
|
+
curl -X POST estimate-transaction-gas -d '{"transaction_template":{"allow_additional_actions":false,"raw_transaction":"070100010161015ffe8a1209937a6a8b22e8c01f056fd5f1730734ba8964d6b79de4a639032cecddffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8099c4d59901000116001485eb6eee8023332da85df60157dc9b16cc553fb2010002013dffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff80afa08b4f011600142b4fd033bc76b4ddf5cb00f625362c4bc7b10efa00013dffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8090dfc04a011600146eea1ce6cfa5b718ae8094376be9bc1a87c9c82700","signing_instructions":[{"position":0,"witness_components":[{"keys":[{"derivation_path":["010100000000000000","0100000000000000"],"xpub":"cb4e5932d808ee060df9552963d87f60edac42360b11d4ad89558ef2acea4d4aaf4818f2ebf5a599382b8dfce0a0c798c7e44ec2667b3a1d34c61ba57609de55"}],"quorum":1,"signatures":null,"type":"raw_tx_signature"},{"type":"data","value":"1c9b5c1db7f4afe31fd1b7e0495a8bb042a271d8d7924d4fc1ff7cf1bff15813"}]}]}}'
|
2688
|
+
|
2689
|
+
# Result
|
2690
|
+
{
|
2691
|
+
"storage_neu": 3840000,
|
2692
|
+
"total_neu": 5259000,
|
2693
|
+
"vm_neu": 1419000
|
2694
|
+
}
|
2695
|
+
```
|
2696
|
+
|
2697
|
+
----
|
2698
|
+
|
2699
|
+
#### `create-access-token`
|
2700
|
+
|
2701
|
+
Create access token, it provides basic access authentication for HTTP protocol, returns token contain username and password, they are separated by a colon.
|
2702
|
+
|
2703
|
+
##### Parameters
|
2704
|
+
|
2705
|
+
`Object`:
|
2706
|
+
|
2707
|
+
- `String` - *id*, token ID.
|
2708
|
+
|
2709
|
+
optional:
|
2710
|
+
|
2711
|
+
- `String` - *type*, type of token.
|
2712
|
+
|
2713
|
+
##### Returns
|
2714
|
+
|
2715
|
+
`Object`:
|
2716
|
+
|
2717
|
+
- `String` - *token*, access token, authentication username and password are separated by a colon.
|
2718
|
+
- `String` - *id*, token ID.
|
2719
|
+
- `String` - *type*, type of token.
|
2720
|
+
- `Object` - *created_at*, time to create token.
|
2721
|
+
|
2722
|
+
##### Example
|
2723
|
+
|
2724
|
+
create access token.
|
2725
|
+
|
2726
|
+
```ruby
|
2727
|
+
bytom_client.access_token.create_access_token(id: 'token001')
|
2728
|
+
|
2729
|
+
# Response data
|
2730
|
+
{
|
2731
|
+
"status" = >"success",
|
2732
|
+
"data" = >{
|
2733
|
+
"id" = >"token1",
|
2734
|
+
"token" = >"token1:f5ed3ac7f67953c2695acb4ed0a1e0b0afca813af8142d00db3c72fe42993701",
|
2735
|
+
"created_at" = >"2019-01-15T19:19:22.391278+08:00"
|
2736
|
+
}
|
2737
|
+
}
|
2738
|
+
```
|
2739
|
+
|
2740
|
+
----
|
2741
|
+
|
2742
|
+
#### `list-access-tokens`
|
2743
|
+
|
2744
|
+
Returns the list of all available access tokens.
|
2745
|
+
|
2746
|
+
##### Parameters
|
2747
|
+
|
2748
|
+
none
|
2749
|
+
|
2750
|
+
##### Returns
|
2751
|
+
|
2752
|
+
- `Array of Object`, access token array.
|
2753
|
+
- `Object`:
|
2754
|
+
- `String` - *token*, access token.
|
2755
|
+
- `String` - *id*, token ID.
|
2756
|
+
- `String` - *type*, type of token.
|
2757
|
+
- `Object` - *created_at*, time to create token.
|
2758
|
+
|
2759
|
+
##### Example
|
2760
|
+
|
2761
|
+
list all the available access tokens.
|
2762
|
+
|
2763
|
+
```ruby
|
2764
|
+
#bytom_client = Bytom::Client.new(base_url: 'http://127.0.0.1:9888')
|
2765
|
+
bytom_client.access_token.list_access_tokens
|
2766
|
+
|
2767
|
+
// Result
|
2768
|
+
{
|
2769
|
+
"status" = >"success",
|
2770
|
+
"data" = >[{
|
2771
|
+
"id" = >"token1",
|
2772
|
+
"token" = >"token1:f5ed3ac7f67953c2695acb4ed0a1e0b0afca813af8142d00db3c72fe42993701",
|
2773
|
+
"created_at" = >"2019-01-15T19:19:22.391278+08:00"
|
2774
|
+
}]
|
2775
|
+
}
|
2776
|
+
```
|
2777
|
+
|
2778
|
+
----
|
2779
|
+
|
2780
|
+
#### `delete-access-token`
|
2781
|
+
|
2782
|
+
Delete existed access token.
|
2783
|
+
|
2784
|
+
##### Parameters
|
2785
|
+
|
2786
|
+
`Object`:
|
2787
|
+
|
2788
|
+
- `String` - *id*, token ID.
|
2789
|
+
|
2790
|
+
##### Returns
|
2791
|
+
|
2792
|
+
none if the access token is deleted successfully.
|
2793
|
+
|
2794
|
+
##### Example
|
2795
|
+
|
2796
|
+
delete access token.
|
2797
|
+
|
2798
|
+
```ruby
|
2799
|
+
|
2800
|
+
bytom_client.access_token.delete_access_token(id: 'token004')
|
2801
|
+
|
2802
|
+
# Response data
|
2803
|
+
```
|
2804
|
+
|
2805
|
+
----
|
2806
|
+
|
2807
|
+
#### `check-access-token`
|
2808
|
+
|
2809
|
+
Check access token is valid.
|
2810
|
+
|
2811
|
+
##### Parameters
|
2812
|
+
|
2813
|
+
`Object`:
|
2814
|
+
|
2815
|
+
- `String` - *id*, token ID.
|
2816
|
+
- `String` - *secret*, secret of token, the second part of the colon division for token.
|
2817
|
+
|
2818
|
+
##### Returns
|
2819
|
+
|
2820
|
+
none if the access token is checked valid.
|
2821
|
+
|
2822
|
+
##### Example
|
2823
|
+
|
2824
|
+
check whether the access token is vaild or not.
|
2825
|
+
|
2826
|
+
```ruby
|
2827
|
+
bytom_client.access_token.check_access_token(
|
2828
|
+
id: 'token001',
|
2829
|
+
secret: 'c12804d862e186bc206c1b80329145cf6d861bab676f81f45254c57a8a289b52'
|
2830
|
+
)
|
2831
|
+
```
|
2832
|
+
|
2833
|
+
----
|
2834
|
+
|
2835
|
+
#### `create-transaction-feed`
|
2836
|
+
|
2837
|
+
Create transaction feed.
|
2838
|
+
|
2839
|
+
##### Parameters
|
2840
|
+
|
2841
|
+
`Object`:
|
2842
|
+
|
2843
|
+
- `String` - *alias*, name of the transaction feed.
|
2844
|
+
- `String` - *filter*, filter of the transaction feed.
|
2845
|
+
|
2846
|
+
##### Returns
|
2847
|
+
|
2848
|
+
none if the transaction feed is created success.
|
2849
|
+
|
2850
|
+
##### Example
|
2851
|
+
|
2852
|
+
```ruby
|
2853
|
+
bytom_client.transactions.create_transaction_feed(
|
2854
|
+
alias_name: 'test1',
|
2855
|
+
filter: "asset_id='0e11c2fa26623b3b1580d2b04a9cebb1ed13e04c18929fc1ac8c11ae62b87db5' AND amount_lower_limit = 50 AND amount_upper_limit = 100"
|
2856
|
+
)
|
2857
|
+
```
|
2858
|
+
|
2859
|
+
----
|
2860
|
+
|
2861
|
+
#### `get-transaction-feed`
|
2862
|
+
|
2863
|
+
Query detail transaction feed by name.
|
2864
|
+
|
2865
|
+
##### Parameters
|
2866
|
+
|
2867
|
+
`Object`:
|
2868
|
+
|
2869
|
+
- `String` - *alias*, name of the transaction feed.
|
2870
|
+
|
2871
|
+
##### Returns
|
2872
|
+
|
2873
|
+
`Object`:
|
2874
|
+
|
2875
|
+
- `String` - *id*, id of the transaction feed.
|
2876
|
+
- `String` - *alias*, name of the transaction feed.
|
2877
|
+
- `String` - *filter*, filter of the transaction feed.
|
2878
|
+
- `Object` - *param*, param of the transaction feed.
|
2879
|
+
- `String` - *assetid*, asset id.
|
2880
|
+
- `Integer` - *lowerlimit*, the lower limit of asset amount.
|
2881
|
+
- `Integer` - *upperlimit*, the upper limit of asset amount.
|
2882
|
+
- `String` - *transtype*, type of transaction.
|
2883
|
+
|
2884
|
+
##### Example
|
2885
|
+
|
2886
|
+
list the available txfeed by alias:
|
2887
|
+
|
2888
|
+
```js
|
2889
|
+
bytom_client.transactions.get_transaction_feed(alias_name: 'test1')
|
2890
|
+
|
2891
|
+
# response data
|
2892
|
+
{
|
2893
|
+
"status" =>"success",
|
2894
|
+
"data" => {
|
2895
|
+
"txfeed" => {
|
2896
|
+
"alias" =>"test1",
|
2897
|
+
"filter" =>"asset_id='0e11c2fa26623b3b1580d2b04a9cebb1ed13e04c18929fc1ac8c11ae62b87db5' AND amount_lower_limit = 50 AND amount_upper_limit = 100",
|
2898
|
+
"param" => {
|
2899
|
+
"assetid" =>"0e11c2fa26623b3b1580d2b04a9cebb1ed13e04c18929fc1ac8c11ae62b87db5",
|
2900
|
+
"lowerlimit" =>50,
|
2901
|
+
"upperlimit" =>100
|
2902
|
+
}
|
2903
|
+
}
|
2904
|
+
}
|
2905
|
+
}
|
2906
|
+
```
|
2907
|
+
|
2908
|
+
----
|
2909
|
+
|
2910
|
+
#### `list-transaction-feeds`
|
2911
|
+
|
2912
|
+
Returns the list of all available transaction feeds.
|
2913
|
+
|
2914
|
+
##### Parameters
|
2915
|
+
|
2916
|
+
none
|
2917
|
+
|
2918
|
+
##### Returns
|
2919
|
+
|
2920
|
+
- `Array of Object`, the transaction feeds.
|
2921
|
+
- `Object`:
|
2922
|
+
- `String` - *id*, id of the transaction feed.
|
2923
|
+
- `String` - *alias*, name of the transaction feed.
|
2924
|
+
- `String` - *filter*, filter of the transaction feed.
|
2925
|
+
- `Object` - *param*, param of the transaction feed.
|
2926
|
+
- `String` - *assetid*, asset id.
|
2927
|
+
- `Integer` - *lowerlimit*, the lower limit of asset amount.
|
2928
|
+
- `Integer` - *upperlimit*, the upper limit of asset amount.
|
2929
|
+
- `String` - *transtype*, type of transaction.
|
2930
|
+
|
2931
|
+
##### Example
|
2932
|
+
|
2933
|
+
list all the available txfeed:
|
2934
|
+
|
2935
|
+
```ruby
|
2936
|
+
bytom_client.transactions.list_transaction_feeds
|
2937
|
+
|
2938
|
+
# response data
|
2939
|
+
{
|
2940
|
+
"status" =>"success",
|
2941
|
+
"data" => [
|
2942
|
+
{
|
2943
|
+
"alias" =>"test1",
|
2944
|
+
"filter" =>"asset_id='0e11c2fa26623b3b1580d2b04a9cebb1ed13e04c18929fc1ac8c11ae62b87db5' AND amount_lower_limit = 50 AND amount_upper_limit = 100",
|
2945
|
+
"param" => {
|
2946
|
+
"assetid" =>"0e11c2fa26623b3b1580d2b04a9cebb1ed13e04c18929fc1ac8c11ae62b87db5",
|
2947
|
+
"lowerlimit" =>50,
|
2948
|
+
"upperlimit" =>100
|
2949
|
+
}
|
2950
|
+
}
|
2951
|
+
]
|
2952
|
+
}
|
2953
|
+
```
|
2954
|
+
|
2955
|
+
----
|
2956
|
+
|
2957
|
+
#### `delete-transaction-feed`
|
2958
|
+
|
2959
|
+
Delete transaction feed by name.
|
2960
|
+
|
2961
|
+
##### Parameters
|
2962
|
+
|
2963
|
+
`Object`:
|
2964
|
+
|
2965
|
+
- `String` - *alias*, name of the transaction feed.
|
2966
|
+
|
2967
|
+
##### Returns
|
2968
|
+
|
2969
|
+
none if the transaction feed is deleted success.
|
2970
|
+
|
2971
|
+
##### Example
|
2972
|
+
|
2973
|
+
```ruby
|
2974
|
+
bytom_client.transactions.delete_transaction_feed(alias_name: 'test1')
|
2975
|
+
```
|
2976
|
+
|
2977
|
+
----
|
2978
|
+
|
2979
|
+
#### `update-transaction-feed`
|
2980
|
+
|
2981
|
+
Update transaction feed.
|
2982
|
+
|
2983
|
+
##### Parameters
|
2984
|
+
|
2985
|
+
`Object`:
|
2986
|
+
|
2987
|
+
- `String` - *alias*, name of the transaction feed.
|
2988
|
+
- `String` - *filter*, filter of the transaction feed.
|
2989
|
+
|
2990
|
+
##### Returns
|
2991
|
+
|
2992
|
+
none if the transaction feed is updated success.
|
2993
|
+
|
2994
|
+
##### Example
|
2995
|
+
|
2996
|
+
deleted when the txfeed exists, and create it with alias and filter:
|
2997
|
+
|
2998
|
+
```ruby
|
2999
|
+
bytom_client.transactions.update_transaction_feed(
|
3000
|
+
alias_name: 'test1',
|
3001
|
+
filter: "asset_id='0e11c2fa26623b3b1580d2b04a9cebb1ed13e04c18929fc1ac8c11ae62b87db5' AND amount_lower_limit = 150 AND amount_upper_limit = 300"
|
3002
|
+
)
|
3003
|
+
```
|
3004
|
+
|
3005
|
+
----
|
3006
|
+
|
3007
|
+
#### `get-unconfirmed-transaction`
|
3008
|
+
|
3009
|
+
Query mempool transaction by transaction ID.
|
3010
|
+
|
3011
|
+
##### Parameters
|
3012
|
+
|
3013
|
+
`Object`:
|
3014
|
+
|
3015
|
+
- `String` - *tx_id*, transaction id, hash of transaction.
|
3016
|
+
|
3017
|
+
##### Returns
|
3018
|
+
|
3019
|
+
`Object`:
|
3020
|
+
|
3021
|
+
- `String` - *id*, transaction id, hash of the transaction.
|
3022
|
+
- `Integer` - *version*, version of transaction.
|
3023
|
+
- `Integer` - *size*, size of transaction.
|
3024
|
+
- `Integer` - *time_range*, the time range of transaction.
|
3025
|
+
- `Boolean` - *status_fail*, whether the state of the request has failed.
|
3026
|
+
- `String` - *mux_id*, the previous transaction mux id(wallet enable can be acquired, this place is empty).
|
3027
|
+
- `Array of Object` - *inputs*, object of inputs for the transaction(input struct please refer to get-transction API description).
|
3028
|
+
- `Array of Object` - *outputs*, object of outputs for the transaction(output struct please refer to get-transction API description).
|
3029
|
+
|
3030
|
+
##### Example
|
3031
|
+
|
3032
|
+
```ruby
|
3033
|
+
bytom_client.transactions.get_unconfirmed_transaction(
|
3034
|
+
tx_id: "b9cfc401cba53c6a873c8df40cf68f474314495f73828c206606d803426c48b9"
|
3035
|
+
)
|
3036
|
+
|
3037
|
+
# Request
|
3038
|
+
curl -X POST get-unconfirmed-transaction -d '{"tx_id": "382090f24fbfc2f737fa7372b9d161a43f00d1c597a7130a56589d1f469d04b5"}'
|
3039
|
+
|
3040
|
+
# Result
|
3041
|
+
{
|
3042
|
+
"id": "382090f24fbfc2f737fa7372b9d161a43f00d1c597a7130a56589d1f469d04b5",
|
3043
|
+
"inputs": [
|
3044
|
+
{
|
3045
|
+
"address": "bm1qqrm7ruecx7yrg9smtwmnmgj3umg9vcukgy5sdj",
|
3046
|
+
"amount": 41250000000,
|
3047
|
+
"asset_definition": {},
|
3048
|
+
"asset_id": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
|
3049
|
+
"control_program": "001400f7e1f338378834161b5bb73da251e6d0566396",
|
3050
|
+
"input_id": "a0c2fa0719bfe1446681537dcf1f8d0f03add093e29d12481eb807e07778d7b3",
|
3051
|
+
"spent_output_id": "161b44e547a6cc68d732eb64fa38031da98211a99319e088cfe632223f9ac6d8",
|
3052
|
+
"type": "spend",
|
3053
|
+
"witness_arguments": [
|
3054
|
+
"cf0e1b217ab92ade8e81fab10f9f307bb5cc1ad947b5629e3f7a760aba722f5044f2ab59ec92fa4264ff5811de4361abb6eabd7e75ffd28a813a98ceff434c01",
|
3055
|
+
"6890a19b21c326059eef211cd8414282a79d3b9203f2592064221fd360e778a7"
|
3056
|
+
]
|
3057
|
+
}
|
3058
|
+
],
|
3059
|
+
"mux_id": "842cd07eed050b547377b5b123f14a5ec0d76933d564f030cf4d5d5c15769645",
|
3060
|
+
"outputs": [
|
3061
|
+
{
|
3062
|
+
"address": "bm1qehxd5cdnepckh5jc72ggn30havd78lsgcqmt7k",
|
3063
|
+
"amount": 21230000000,
|
3064
|
+
"asset_definition": {},
|
3065
|
+
"asset_id": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
|
3066
|
+
"control_program": "0014cdccda61b3c8716bd258f29089c5f7eb1be3fe08",
|
3067
|
+
"id": "a8f21ad24689c290634db85278f56d152efe6fe08bc194e5dee5127ed6d3ebee",
|
3068
|
+
"position": 0,
|
3069
|
+
"type": "control"
|
3070
|
+
},
|
3071
|
+
{
|
3072
|
+
"address": "bm1q2me9gwccnm3ehpnrcr99gcnj730js2zfucms3r",
|
3073
|
+
"amount": 20000000000,
|
3074
|
+
"asset_definition": {},
|
3075
|
+
"asset_id": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
|
3076
|
+
"control_program": "001456f2543b189ee39b8663c0ca546272f45f282849",
|
3077
|
+
"id": "78219e422ea3257aeb32f6d952b5ce5560dab1d6440c9f3aebcdaad2a852d2a8",
|
3078
|
+
"position": 1,
|
3079
|
+
"type": "control"
|
3080
|
+
}
|
3081
|
+
],
|
3082
|
+
"size": 664,
|
3083
|
+
"status_fail": false,
|
3084
|
+
"time_range": 0,
|
3085
|
+
"version": 1
|
3086
|
+
}
|
3087
|
+
```
|
3088
|
+
|
3089
|
+
----
|
3090
|
+
|
3091
|
+
#### `list-unconfirmed-transactions`
|
3092
|
+
|
3093
|
+
Returns the total number of mempool transactions and the list of transaction IDs.
|
3094
|
+
|
3095
|
+
##### Parameters
|
3096
|
+
|
3097
|
+
none
|
3098
|
+
|
3099
|
+
##### Returns
|
3100
|
+
|
3101
|
+
`Object`:
|
3102
|
+
|
3103
|
+
- `Integer` - *total*, version of transaction.
|
3104
|
+
- `Array of Object` - *tx_ids*, list of transaction id.
|
3105
|
+
|
3106
|
+
##### Example
|
3107
|
+
|
3108
|
+
```js
|
3109
|
+
bytom_client.transactions.list_unconfirmed_transactions
|
3110
|
+
```
|
3111
|
+
|
3112
|
+
----
|
3113
|
+
|
3114
|
+
#### `decode-raw-transaction`
|
3115
|
+
|
3116
|
+
Decode a serialized transaction hex string into a JSON object describing the transaction.
|
3117
|
+
|
3118
|
+
##### Parameters
|
3119
|
+
|
3120
|
+
`Object`:
|
3121
|
+
|
3122
|
+
- `String` - *raw_transaction*, hexstring of raw transaction.
|
3123
|
+
|
3124
|
+
##### Returns
|
3125
|
+
|
3126
|
+
`Object`:
|
3127
|
+
|
3128
|
+
- `String` - *tx_id*, transaction ID.
|
3129
|
+
- `Integer` - *version*, version of transaction.
|
3130
|
+
- `String` - *size*, size of transaction.
|
3131
|
+
- `String` - *time_range*, time range of transaction.
|
3132
|
+
- `String` - *fee*, fee for sending transaction.
|
3133
|
+
- `Array of Object` - *inputs*, object of inputs for the transaction(input struct please refer to get-transction API description).
|
3134
|
+
- `Array of Object` - *outputs*, object of outputs for the transaction
|
3135
|
+
(output struct please refer to get-transction API description).
|
3136
|
+
|
3137
|
+
##### Example
|
3138
|
+
|
3139
|
+
```js
|
3140
|
+
bytom_client.transactions.decode_raw_transaction(
|
3141
|
+
raw_transaction: res['data']['raw_transaction'],
|
3142
|
+
)
|
3143
|
+
|
3144
|
+
# response data
|
3145
|
+
{
|
3146
|
+
"status" =>"success",
|
3147
|
+
"data" => {
|
3148
|
+
"tx_id" =>"63ac0ffebbcd577fc95395525f4d1ddc81ca38ed62fe6d2640f0e6bc1bd8f6f3",
|
3149
|
+
"version" =>1,
|
3150
|
+
"size" =>322,
|
3151
|
+
"time_range" =>129279,
|
3152
|
+
"inputs" => [
|
3153
|
+
{
|
3154
|
+
"type" =>"spend",
|
3155
|
+
"asset_id" =>"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
|
3156
|
+
"asset_definition" => {
|
3157
|
+
|
3158
|
+
},
|
3159
|
+
"amount" =>1000000000,
|
3160
|
+
"control_program" =>"0014fdc6aa799423e32d20cea88ae0026bca3ec519a9",
|
3161
|
+
"address" =>"tm1qlhr257v5y03j6gxw4z9wqqnteglv2xdf6jcc02",
|
3162
|
+
"spent_output_id" =>"d49567a31855a8d83ce13e3d2169d753c7d117cb97739744d34a976b1ee6cdae",
|
3163
|
+
"input_id" =>"2ff98451f59d4e9769f589a870ca871e145614ecc0331fef8f50029b799ba3e8",
|
3164
|
+
"witness_arguments" =>nil
|
3165
|
+
},
|
3166
|
+
{
|
3167
|
+
"type" =>"issue",
|
3168
|
+
"asset_id" =>"41b2c7a02e610c9e7117e5b2407573b953b3ebbec90302cf217ecaf134851622",
|
3169
|
+
"asset_definition" => {
|
3170
|
+
|
3171
|
+
},
|
3172
|
+
"amount" =>10000,
|
3173
|
+
"issuance_program" =>"ae204c09d66bfad30f9017ad2283484f3931810bfe7821f75427cb1417bac08b48885151ad",
|
3174
|
+
"input_id" =>"d230e75ef6b01f1b2594252bfd2e72b013ceeb276f27e892f3e84f068a914c66",
|
3175
|
+
"witness_arguments" =>nil
|
3176
|
+
}
|
3177
|
+
],
|
3178
|
+
"outputs" => [
|
3179
|
+
{
|
3180
|
+
"type" =>"control",
|
3181
|
+
"id" =>"d7ffe22616e60bcddc345472c3b9aae651e4c9f980a52adfabc833883fa642d8",
|
3182
|
+
"position" =>0,
|
3183
|
+
"asset_id" =>"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
|
3184
|
+
"asset_definition" => {
|
3185
|
+
|
3186
|
+
},
|
3187
|
+
"amount" =>999999999,
|
3188
|
+
"control_program" =>"00147e420650ad8523f75e26c87e7023dc0c2d14203e",
|
3189
|
+
"address" =>"tm1q0epqv59ds53lwh3xepl8qg7upsk3ggp7mv4a3y"
|
3190
|
+
},
|
3191
|
+
{
|
3192
|
+
"type" =>"control",
|
3193
|
+
"id" =>"becc0f1c070ab1a182c38903a47111e36fe080721db9088d1466e24f32369601",
|
3194
|
+
"position" =>1,
|
3195
|
+
"asset_id" =>"41b2c7a02e610c9e7117e5b2407573b953b3ebbec90302cf217ecaf134851622",
|
3196
|
+
"asset_definition" => {
|
3197
|
+
|
3198
|
+
},
|
3199
|
+
"amount" =>10000,
|
3200
|
+
"control_program" =>"001453d0b795fbc245ec4dfc1a34d22959c455e6e619",
|
3201
|
+
"address" =>"tm1q20gt090mcfz7cn0urg6dy22ec327deseew7vtz"
|
3202
|
+
}
|
3203
|
+
],
|
3204
|
+
"fee" =>1
|
3205
|
+
}
|
3206
|
+
}
|
3207
|
+
```
|
3208
|
+
|
3209
|
+
----
|
3210
|
+
|
3211
|
+
#### `get-block-count`
|
3212
|
+
|
3213
|
+
Returns the current block height for blockchain.
|
3214
|
+
|
3215
|
+
##### Parameters
|
3216
|
+
|
3217
|
+
none
|
3218
|
+
|
3219
|
+
##### Returns
|
3220
|
+
|
3221
|
+
`Object`:
|
3222
|
+
|
3223
|
+
- `Integer` - *block_count*, recent block height of the blockchain.
|
3224
|
+
|
3225
|
+
##### Example
|
3226
|
+
|
3227
|
+
```ruby
|
3228
|
+
bytom_client.block.get_block_count
|
3229
|
+
|
3230
|
+
# response data
|
3231
|
+
{"status"=>"success", "data"=>{"block_count"=>119279}}
|
3232
|
+
```
|
3233
|
+
|
3234
|
+
----
|
3235
|
+
|
3236
|
+
#### `get-block-hash`
|
3237
|
+
|
3238
|
+
Returns the current block hash for blockchain.
|
3239
|
+
|
3240
|
+
##### Parameters
|
3241
|
+
|
3242
|
+
none
|
3243
|
+
|
3244
|
+
##### Returns
|
3245
|
+
|
3246
|
+
`Object`:
|
3247
|
+
|
3248
|
+
- `String` - *block_hash*, recent block hash of the blockchain.
|
3249
|
+
|
3250
|
+
##### Example
|
3251
|
+
|
3252
|
+
```ruby
|
3253
|
+
bytom_client.block.get_block_hash
|
3254
|
+
# response data
|
3255
|
+
{
|
3256
|
+
"status" =>"success",
|
3257
|
+
"data" => {
|
3258
|
+
"block_hash" =>"a9b249236daa0b752ba4e409f89b27d44a4b6838289af917b3fe933520defaf0"
|
3259
|
+
}
|
3260
|
+
}
|
3261
|
+
|
3262
|
+
```
|
3263
|
+
|
3264
|
+
----
|
3265
|
+
|
3266
|
+
#### `get-block`
|
3267
|
+
|
3268
|
+
Returns the detail block by block height or block hash.
|
3269
|
+
|
3270
|
+
##### Parameters
|
3271
|
+
|
3272
|
+
`Object`: block_height | block_hash
|
3273
|
+
|
3274
|
+
optional:
|
3275
|
+
|
3276
|
+
- `String` - *block_hash*, hash of block.
|
3277
|
+
- `Integer` - *block_height*, height of block.
|
3278
|
+
|
3279
|
+
##### Returns
|
3280
|
+
|
3281
|
+
`Object`:
|
3282
|
+
|
3283
|
+
- `String` - *hash*, hash of block.
|
3284
|
+
- `Integer` - *size*, size of block.
|
3285
|
+
- `Integer` - *version*, version of block.
|
3286
|
+
- `Integer` - *height*, height of block.
|
3287
|
+
- `String` - *previous_block_hash*, previous block hash.
|
3288
|
+
- `Integer` - *timestamp*, timestamp of block.
|
3289
|
+
- `Integer` - *nonce*, nonce value.
|
3290
|
+
- `Integer` - *bits*, bits of difficulty.
|
3291
|
+
- `String` - *difficulty*, difficulty value(String type).
|
3292
|
+
- `String` - *transaction_merkle_root*, merkle root of transaction.
|
3293
|
+
- `String` - *transaction_status_hash*, merkle root of transaction status.
|
3294
|
+
- `Array of Object` - *transactions*, transaction object:
|
3295
|
+
- `String` - *id*, transaction id, hash of the transaction.
|
3296
|
+
- `Integer` - *version*, version of transaction.
|
3297
|
+
- `Integer` - *size*, size of transaction.
|
3298
|
+
- `Integer` - *time_range*, the unix timestamp for when the requst was responsed.
|
3299
|
+
- `Boolean` - *status_fail*, whether the state of the request has failed.
|
3300
|
+
- `String` - *mux_id*, the previous transaction mux id(source id of utxo).
|
3301
|
+
- `Array of Object` - *inputs*, object of inputs for the transaction.
|
3302
|
+
- `String` - *type*, the type of input action, available option include: 'spend', 'issue', 'coinbase'.
|
3303
|
+
- `String` - *asset_id*, asset id.
|
3304
|
+
- `String` - *asset_alias*, name of asset.
|
3305
|
+
- `Object` - *asset_definition*, definition of asset(json object).
|
3306
|
+
- `Integer` - *amount*, amount of asset.
|
3307
|
+
- `Object` - *issuance_program*, issuance program, it only exist when type is 'issue'.
|
3308
|
+
- `Object` - *control_program*, control program of account, it only exist when type is 'spend'.
|
3309
|
+
- `String` - *address*, address of account, it only exist when type is 'spend'.
|
3310
|
+
- `String` - *spent_output_id*, the front of outputID to be spent in this input, it only exist when type is 'spend'.
|
3311
|
+
- `String` - *account_id*, account id.
|
3312
|
+
- `String` - *account_alias*, name of account.
|
3313
|
+
- `Object` - *arbitrary*, arbitrary infomation can be set by miner, it only exist when type is 'coinbase'.
|
3314
|
+
- `String` - *input_id*, hash of input action.
|
3315
|
+
- `Array of String` - *witness_arguments*, witness arguments.
|
3316
|
+
- `Array of Object` - *outputs*, object of outputs for the transaction.
|
3317
|
+
- `String` - *type*, the type of output action, available option include: 'retire', 'control'.
|
3318
|
+
- `String` - *id*, outputid related to utxo.
|
3319
|
+
- `Integer` - *position*, position of outputs.
|
3320
|
+
- `String` - *asset_id*, asset id.
|
3321
|
+
- `String` - *asset_alias*, name of asset.
|
3322
|
+
- `Object` - *asset_definition*, definition of asset(json object).
|
3323
|
+
- `Integer` - *amount*, amount of asset.
|
3324
|
+
- `String` - *account_id*, account id.
|
3325
|
+
- `String` - *account_alias*, name of account.
|
3326
|
+
- `Object` - *control_program*, control program of account.
|
3327
|
+
- `String` - *address*, address of account.
|
3328
|
+
|
3329
|
+
##### Example
|
3330
|
+
|
3331
|
+
get specified block information by block_hash or block_height, if both exists, the block result is querying by hash.
|
3332
|
+
|
3333
|
+
```js
|
3334
|
+
|
3335
|
+
bytom_client.block.get_block
|
3336
|
+
|
3337
|
+
bytom_client.block.get_block(block_height: 43)
|
3338
|
+
|
3339
|
+
bytom_client.block.get_block(
|
3340
|
+
block_hash: 'a9b249236daa0b752ba4e409f89b27d44a4b6838289af917b3fe933520defaf0'
|
3341
|
+
)
|
3342
|
+
|
3343
|
+
bytom_client.block.get_block(
|
3344
|
+
block_height: 43,
|
3345
|
+
block_hash: 'a9b249236daa0b752ba4e409f89b27d44a4b6838289af917b3fe933520defaf0'
|
3346
|
+
)
|
3347
|
+
|
3348
|
+
# response data
|
3349
|
+
{
|
3350
|
+
"status" =>"success",
|
3351
|
+
"data" => {
|
3352
|
+
"hash" =>"a9b249236daa0b752ba4e409f89b27d44a4b6838289af917b3fe933520defaf0",
|
3353
|
+
"size" =>416,
|
3354
|
+
"version" =>1,
|
3355
|
+
"height" =>119245,
|
3356
|
+
"previous_block_hash" =>"2c8d50e96d0e305b3624f123cefd9d169af39e88d00660964520cdb76de58bae",
|
3357
|
+
"timestamp" =>1547718202,
|
3358
|
+
"nonce" =>1549238276311745739,
|
3359
|
+
"bits" =>2161727821144505872,
|
3360
|
+
"difficulty" =>"164898",
|
3361
|
+
"transaction_merkle_root" =>"1795c62190871d0090232b8376be80d1b64d70b7d7ea522621e330654a644339",
|
3362
|
+
"transaction_status_hash" =>"c9c377e5192668bc0a367e4a4764f11e7c725ecced1d7b6a492974fab1b6d5bc",
|
3363
|
+
"transactions" => [
|
3364
|
+
{
|
3365
|
+
"id" =>"03283cc7c87a2ba003e8173a76c1d1e7b646e5dfd01bf8e101678388fe30497c",
|
3366
|
+
"version" =>1,
|
3367
|
+
"size" =>82,
|
3368
|
+
"time_range" =>0,
|
3369
|
+
"inputs" => [
|
3370
|
+
{
|
3371
|
+
"type" =>"coinbase",
|
3372
|
+
"asset_id" =>"0000000000000000000000000000000000000000000000000000000000000000",
|
3373
|
+
"asset_definition" => {
|
3374
|
+
|
3375
|
+
},
|
3376
|
+
"amount" =>0,
|
3377
|
+
"arbitrary" =>"00313139323435",
|
3378
|
+
"input_id" =>"c5a0a1aaac554f0ca7de619c2e5c3b994f0cc103c69ff0f7c85069e6d30c5441",
|
3379
|
+
"witness_arguments" =>nil
|
3380
|
+
}
|
3381
|
+
],
|
3382
|
+
"outputs" => [
|
3383
|
+
{
|
3384
|
+
"type" =>"control",
|
3385
|
+
"id" =>"b0d685df2de322d1edcd7070778de23a7feffc4bc24ddb24d1f32593f525f94c",
|
3386
|
+
"position" =>0,
|
3387
|
+
"asset_id" =>"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
|
3388
|
+
"asset_definition" => {
|
3389
|
+
|
3390
|
+
},
|
3391
|
+
"amount" =>41250000000,
|
3392
|
+
"control_program" =>"0014ae14495b8dee5dd129e3c6db33963f112af34a91",
|
3393
|
+
"address" =>"tm1q4c2yjkudaewaz20rcmdn893lzy40xj53z50n4n"
|
3394
|
+
}
|
3395
|
+
],
|
3396
|
+
"status_fail" =>false,
|
3397
|
+
"mux_id" =>"dad789ffcf9164cc479d4eb35f46328fbd9c30cc0f88a13d624e3f3cf47a27f3"
|
3398
|
+
}
|
3399
|
+
]
|
3400
|
+
}
|
3401
|
+
}
|
3402
|
+
```
|
3403
|
+
|
3404
|
+
----
|
3405
|
+
|
3406
|
+
#### `get-block-header`
|
3407
|
+
|
3408
|
+
Returns the detail block header by block height or block hash.
|
3409
|
+
|
3410
|
+
##### Parameters
|
3411
|
+
|
3412
|
+
`Object`: block_height | block_hash
|
3413
|
+
|
3414
|
+
optional:
|
3415
|
+
|
3416
|
+
- `String` - *block_hash*, hash of block.
|
3417
|
+
- `Integer` - *block_height*, height of block.
|
3418
|
+
|
3419
|
+
##### Returns
|
3420
|
+
|
3421
|
+
`Object`:
|
3422
|
+
|
3423
|
+
- `Object` - *block_header*, header of block.
|
3424
|
+
- `Integer` - *reward*, reward.
|
3425
|
+
|
3426
|
+
##### Example
|
3427
|
+
|
3428
|
+
```js
|
3429
|
+
bytom_client.block.get_block_header
|
3430
|
+
|
3431
|
+
bytom_client.block.get_block_header(block_height: 43)
|
3432
|
+
|
3433
|
+
bytom_client.block.get_block_header(
|
3434
|
+
block_hash: 'a9b249236daa0b752ba4e409f89b27d44a4b6838289af917b3fe933520defaf0'
|
3435
|
+
)
|
3436
|
+
|
3437
|
+
bytom_client.block.get_block_header(
|
3438
|
+
block_height: 43,
|
3439
|
+
block_hash: 'a9b249236daa0b752ba4e409f89b27d44a4b6838289af917b3fe933520defaf0'
|
3440
|
+
)
|
3441
|
+
|
3442
|
+
# response data
|
3443
|
+
{
|
3444
|
+
"status" =>"success",
|
3445
|
+
"data" => {
|
3446
|
+
"block_header" =>"0101cda3072c8d50e96d0e305b3624f123cefd9d169af39e88d00660964520cdb76de58baeba9c81e205401795c62190871d0090232b8376be80d1b64d70b7d7ea522621e330654a644339c9c377e5192668bc0a367e4a4764f11e7c725ecced1d7b6a492974fab1b6d5bccb8980e0908080c01590fc9683808080801e",
|
3447
|
+
"reward" =>41250000000
|
3448
|
+
}
|
3449
|
+
}
|
3450
|
+
```
|
3451
|
+
|
3452
|
+
----
|
3453
|
+
|
3454
|
+
#### `get-difficulty`
|
3455
|
+
|
3456
|
+
Returns the block difficulty by block height or block hash.
|
3457
|
+
|
3458
|
+
##### Parameters
|
3459
|
+
|
3460
|
+
`Object`:
|
3461
|
+
|
3462
|
+
optional:
|
3463
|
+
|
3464
|
+
- `String` - *block_hash*, hash of block.
|
3465
|
+
- `Integer` - *block_height*, height of block.
|
3466
|
+
|
3467
|
+
##### Returns
|
3468
|
+
|
3469
|
+
`Object`:
|
3470
|
+
|
3471
|
+
- `Integer` - *bits*, bits of block.
|
3472
|
+
- `String` - *difficulty*, difficulty of block.
|
3473
|
+
- `String` - *hash*, block hash.
|
3474
|
+
- `Integer` - *height*, block height.
|
3475
|
+
|
3476
|
+
##### Example
|
3477
|
+
|
3478
|
+
Get difficulty for specified block hash / height.
|
3479
|
+
|
3480
|
+
```js
|
3481
|
+
bytom_client.block.get_difficulty
|
3482
|
+
|
3483
|
+
bytom_client.block.get_difficulty(block_height: 43)
|
3484
|
+
|
3485
|
+
bytom_client.block.get_difficulty(
|
3486
|
+
block_hash: 'a9b249236daa0b752ba4e409f89b27d44a4b6838289af917b3fe933520defaf0'
|
3487
|
+
)
|
3488
|
+
|
3489
|
+
bytom_client.block.get_difficulty(
|
3490
|
+
block_height: 43,
|
3491
|
+
block_hash: 'a9b249236daa0b752ba4e409f89b27d44a4b6838289af917b3fe933520defaf0'
|
3492
|
+
)
|
3493
|
+
|
3494
|
+
# Response data
|
3495
|
+
{
|
3496
|
+
"status" =>"success",
|
3497
|
+
"data" => {
|
3498
|
+
"hash" =>"a9b249236daa0b752ba4e409f89b27d44a4b6838289af917b3fe933520defaf0",
|
3499
|
+
"height" =>119245,
|
3500
|
+
"bits" =>2161727821144505872,
|
3501
|
+
"difficulty" =>"164898"
|
3502
|
+
}
|
3503
|
+
}
|
3504
|
+
```
|
3505
|
+
|
3506
|
+
----
|
3507
|
+
|
3508
|
+
#### `get-hash-rate`
|
3509
|
+
|
3510
|
+
Returns the block hash rate by block height or block hash, it returns the current block hash rate when request is empty.
|
3511
|
+
|
3512
|
+
##### Parameters
|
3513
|
+
|
3514
|
+
`Object`:
|
3515
|
+
|
3516
|
+
optional:
|
3517
|
+
|
3518
|
+
- `String` - *block_hash*, hash of block.
|
3519
|
+
- `Integer` - *block_height*, height of block.
|
3520
|
+
|
3521
|
+
##### Returns
|
3522
|
+
|
3523
|
+
`Object`:
|
3524
|
+
|
3525
|
+
- `Integer` - *hash_rate*, difficulty of block.
|
3526
|
+
- `String` - *hash*, block hash.
|
3527
|
+
- `Integer` - *height*, block height.
|
3528
|
+
|
3529
|
+
##### Example
|
3530
|
+
|
3531
|
+
Get hash rate for specified block hash / height.
|
3532
|
+
|
3533
|
+
```js
|
3534
|
+
bytom_client.block.get_hash_rate
|
3535
|
+
|
3536
|
+
bytom_client.block.get_hash_rate(block_height: 43)
|
3537
|
+
|
3538
|
+
bytom_client.block.get_hash_rate(
|
3539
|
+
block_hash: 'a9b249236daa0b752ba4e409f89b27d44a4b6838289af917b3fe933520defaf0'
|
3540
|
+
)
|
3541
|
+
|
3542
|
+
bytom_client.block.get_hash_rate(
|
3543
|
+
block_height: 43,
|
3544
|
+
block_hash: 'a9b249236daa0b752ba4e409f89b27d44a4b6838289af917b3fe933520defaf0'
|
3545
|
+
)
|
3546
|
+
|
3547
|
+
# response data
|
3548
|
+
{
|
3549
|
+
"status" =>"success",
|
3550
|
+
"data" => {
|
3551
|
+
"hash" =>"a9b249236daa0b752ba4e409f89b27d44a4b6838289af917b3fe933520defaf0",
|
3552
|
+
"height" =>119245,
|
3553
|
+
"hash_rate" =>975
|
3554
|
+
}
|
3555
|
+
}
|
3556
|
+
```
|
3557
|
+
|
3558
|
+
----
|
3559
|
+
|
3560
|
+
#### `net-info`
|
3561
|
+
|
3562
|
+
Returns the information of current network node.
|
3563
|
+
|
3564
|
+
##### Parameters
|
3565
|
+
|
3566
|
+
none
|
3567
|
+
|
3568
|
+
##### Returns
|
3569
|
+
|
3570
|
+
`Object`:
|
3571
|
+
|
3572
|
+
- `Boolean` - *listening*, whether the node is listening.
|
3573
|
+
- `Boolean` - *syncing*, whether the node is syncing.
|
3574
|
+
- `Boolean` - *mining*, whether the node is mining.
|
3575
|
+
- `Integer` - *peer_count*, current count of connected peers.
|
3576
|
+
- `Integer` - *current_block*, current block height in the node's blockchain.
|
3577
|
+
- `Integer` - *highest_block*, current highest block of the connected peers.
|
3578
|
+
- `String` - *network_id*, network id.
|
3579
|
+
- `Object` - *version_info*, bytomd version information:
|
3580
|
+
* `String` - *version*, current version of the running `bytomd`.
|
3581
|
+
* `uint16` - *update*, whether there exists an update.
|
3582
|
+
+ 0: no update;
|
3583
|
+
+ 1: small update;
|
3584
|
+
+ 2: significant update.
|
3585
|
+
* `String` - *new_version*, the newest version of `bytomd` if there is one.
|
3586
|
+
|
3587
|
+
##### Example
|
3588
|
+
|
3589
|
+
```ruby
|
3590
|
+
bytom_client.core_config.net_info
|
3591
|
+
|
3592
|
+
# response data
|
3593
|
+
{
|
3594
|
+
"status" =>"success",
|
3595
|
+
"data" => {
|
3596
|
+
"listening" =>true,
|
3597
|
+
"syncing" =>false,
|
3598
|
+
"mining" =>false,
|
3599
|
+
"peer_count" =>1,
|
3600
|
+
"current_block" =>119248,
|
3601
|
+
"highest_block" =>119248,
|
3602
|
+
"network_id" =>"wisdom",
|
3603
|
+
"version_info" => {
|
3604
|
+
"version" =>"1.0.7+9e872c03",
|
3605
|
+
"update" =>0,
|
3606
|
+
"new_version" =>"1.0.7+9e872c03"
|
3607
|
+
}
|
3608
|
+
}
|
3609
|
+
}
|
3610
|
+
```
|
3611
|
+
|
3612
|
+
----
|
3613
|
+
|
3614
|
+
#### `is-mining`
|
3615
|
+
|
3616
|
+
Returns the mining status.
|
3617
|
+
|
3618
|
+
##### Parameters
|
3619
|
+
|
3620
|
+
none
|
3621
|
+
|
3622
|
+
##### Returns
|
3623
|
+
|
3624
|
+
`Object`:
|
3625
|
+
|
3626
|
+
- `Boolean` - *is_mining*, whether the node is mining.
|
3627
|
+
|
3628
|
+
##### Example
|
3629
|
+
|
3630
|
+
```ruby
|
3631
|
+
bytom_client.core_config.is_mining
|
3632
|
+
|
3633
|
+
# response data
|
3634
|
+
{
|
3635
|
+
"status" =>"success",
|
3636
|
+
"data" => {
|
3637
|
+
"is_mining" =>false
|
3638
|
+
}
|
3639
|
+
}
|
3640
|
+
```
|
3641
|
+
|
3642
|
+
----
|
3643
|
+
|
3644
|
+
### `set-mining`
|
3645
|
+
|
3646
|
+
Start up node mining.
|
3647
|
+
|
3648
|
+
##### Parameters
|
3649
|
+
|
3650
|
+
`Object`:
|
3651
|
+
|
3652
|
+
- `Boolean` - *is_mining*, whether the node is mining.
|
3653
|
+
|
3654
|
+
##### Example
|
3655
|
+
|
3656
|
+
```js
|
3657
|
+
bytom_client.core_config.set_mining(is_mining:true)
|
3658
|
+
|
3659
|
+
```
|
3660
|
+
|
3661
|
+
----
|
3662
|
+
|
3663
|
+
#### `gas-rate`
|
3664
|
+
|
3665
|
+
Quary gas rate.
|
3666
|
+
|
3667
|
+
##### Parameters
|
3668
|
+
|
3669
|
+
none
|
3670
|
+
|
3671
|
+
##### Returns
|
3672
|
+
|
3673
|
+
`Object`:
|
3674
|
+
|
3675
|
+
- `Integer` - *gas_rate*, gas rate.
|
3676
|
+
|
3677
|
+
##### Example
|
3678
|
+
|
3679
|
+
```js
|
3680
|
+
bytom_client.core_config.gas_rate
|
3681
|
+
|
3682
|
+
# response data
|
3683
|
+
{"status"=>"success", "data"=>{"gas_rate"=>200}}
|
3684
|
+
```
|
3685
|
+
|
3686
|
+
----
|
3687
|
+
|
3688
|
+
#### `verify-message`
|
3689
|
+
|
3690
|
+
Verify a signed message with derived pubkey of the address.
|
3691
|
+
|
3692
|
+
##### Parameters
|
3693
|
+
|
3694
|
+
`Object`:
|
3695
|
+
|
3696
|
+
- `String` - *address*, address for account.
|
3697
|
+
- `String` - *derived_xpub*, derived xpub.
|
3698
|
+
- `String` - *message*, message for signature by derived_xpub.
|
3699
|
+
- `String` - *signature*, signature for message.
|
3700
|
+
|
3701
|
+
##### Returns
|
3702
|
+
|
3703
|
+
`Object`:
|
3704
|
+
|
3705
|
+
- `Boolean` - *result*, verify result.
|
3706
|
+
|
3707
|
+
##### Example
|
3708
|
+
|
3709
|
+
```ruby
|
3710
|
+
|
3711
|
+
bytom_client.message.verify_message(
|
3712
|
+
address: "bm1qx2qgvvjz734ur8x5lpfdtlau74aaa5djs0a5jn",
|
3713
|
+
derived_xpub: "6ff8c3d1321ce39a3c3550f57ba70b67dcbcef821e9b85f6150edb7f2f3f91009e67f3075e6e76ed5f657ee4b1a5f4749b7a8c74c8e7e6a1b0e5918ebd5df4d0",
|
3714
|
+
message: "this is a test message",
|
3715
|
+
signature: "74da3d6572233736e3a439166719244dab57dd0047f8751b1efa2da26eeab251d915c1211dcad77e8b013267b86d96e91ae67ff0be520ef4ec326e911410b609"
|
3716
|
+
)
|
3717
|
+
|
3718
|
+
// Request
|
3719
|
+
curl -X POST http://127.0.0.1:9888/verify-message -d '{"address":"bm1qx2qgvvjz734ur8x5lpfdtlau74aaa5djs0a5jn", "derived_xpub":"6ff8c3d1321ce39a3c3550f57ba70b67dcbcef821e9b85f6150edb7f2f3f91009e67f3075e6e76ed5f657ee4b1a5f4749b7a8c74c8e7e6a1b0e5918ebd5df4d0", "message":"this is a test message", "signature":"74da3d6572233736e3a439166719244dab57dd0047f8751b1efa2da26eeab251d915c1211dcad77e8b013267b86d96e91ae67ff0be520ef4ec326e911410b609"}'
|
3720
|
+
|
3721
|
+
// Result
|
3722
|
+
{
|
3723
|
+
"result": true
|
3724
|
+
}
|
3725
|
+
```
|
3726
|
+
|
3727
|
+
----
|
3728
|
+
|
3729
|
+
#### `compile`
|
3730
|
+
|
3731
|
+
Compile equity contract.
|
3732
|
+
|
3733
|
+
##### Parameters
|
3734
|
+
|
3735
|
+
`Object`:
|
3736
|
+
|
3737
|
+
- `String` - *contract*, content of equity contract.
|
3738
|
+
|
3739
|
+
Optional:
|
3740
|
+
|
3741
|
+
- `Array of Object` - *args*, parameters of contract.
|
3742
|
+
- `Boolean` - *boolean*, boolean parameter.
|
3743
|
+
- `Integer` - *integer*, integer parameter.
|
3744
|
+
- `String` - *string*, string parameter.
|
3745
|
+
|
3746
|
+
##### Returns
|
3747
|
+
|
3748
|
+
`Object`:
|
3749
|
+
|
3750
|
+
- `String` - *name*, contract name.
|
3751
|
+
- `String` - *source*, source content of contract.
|
3752
|
+
- `String` - *program*, generated program by compiling contract.
|
3753
|
+
- `Array of Object` - *params*, parameters of contract.
|
3754
|
+
- `String` - *value*, locked value name of contract.
|
3755
|
+
- `Array of Object` - *clause_info*, clauses of contract.
|
3756
|
+
- `String` - *opcodes*, opcodes of contract.
|
3757
|
+
- `String` - *error*, returned error information for compiling contract.
|
3758
|
+
|
3759
|
+
##### Example
|
3760
|
+
|
3761
|
+
```ruby
|
3762
|
+
bytom_client.other.compile(
|
3763
|
+
contract: "contract LockWithPublicKey(publicKey: PublicKey) locks valueAmount of valueAsset { clause unlockWithSig(sig: Signature) { verify checkTxSig(publicKey, sig) unlock valueAmount of valueAsset } }",
|
3764
|
+
args: [
|
3765
|
+
{
|
3766
|
+
string: "e9108d3ca8049800727f6a3505b3a2710dc579405dde03c250f16d9a7e1e6e78"
|
3767
|
+
}
|
3768
|
+
]
|
3769
|
+
)
|
3770
|
+
|
3771
|
+
# Result
|
3772
|
+
{
|
3773
|
+
"name": "LockWithPublicKey",
|
3774
|
+
"source": "contract LockWithPublicKey(publicKey: PublicKey) locks valueAmount of valueAsset { clause unlockWithSig(sig: Signature) { verify checkTxSig(publicKey, sig) unlock valueAmount of valueAsset } }",
|
3775
|
+
"program": "20e9108d3ca8049800727f6a3505b3a2710dc579405dde03c250f16d9a7e1e6e787403ae7cac00c0",
|
3776
|
+
"params": [
|
3777
|
+
{
|
3778
|
+
"name": "publicKey",
|
3779
|
+
"type": "PublicKey"
|
3780
|
+
}
|
3781
|
+
],
|
3782
|
+
"value": "valueAmount of valueAsset",
|
3783
|
+
"clause_info": [
|
3784
|
+
{
|
3785
|
+
"name": "unlockWithSig",
|
3786
|
+
"params": [
|
3787
|
+
{
|
3788
|
+
"name": "sig",
|
3789
|
+
"type": "Signature"
|
3790
|
+
}
|
3791
|
+
],
|
3792
|
+
"values": [
|
3793
|
+
{
|
3794
|
+
"name": "",
|
3795
|
+
"asset": "valueAsset",
|
3796
|
+
"amount": "valueAmount"
|
3797
|
+
}
|
3798
|
+
]
|
3799
|
+
}
|
3800
|
+
],
|
3801
|
+
"opcodes": "0xe9108d3ca8049800727f6a3505b3a2710dc579405dde03c250f16d9a7e1e6e78 DEPTH 0xae7cac FALSE CHECKPREDICATE",
|
3802
|
+
"error": ""
|
3803
|
+
}
|
3804
|
+
```
|
3805
|
+
|
3806
|
+
|
3807
|
+
|
3808
|
+
----
|
3809
|
+
|
3810
|
+
#### `list-peers`
|
3811
|
+
|
3812
|
+
Returns the list of connected peers.
|
3813
|
+
|
3814
|
+
##### Parameters
|
3815
|
+
|
3816
|
+
none
|
3817
|
+
|
3818
|
+
##### Returns
|
3819
|
+
|
3820
|
+
- `Array of Object`, connected peers.
|
3821
|
+
- `Object`:
|
3822
|
+
- `String` - *peer_id*, peer id.
|
3823
|
+
- `String` - *remote_addr*, the address(IP and port) of connected peer.
|
3824
|
+
- `Integer` - *height*, the current height of connected peer.
|
3825
|
+
- `String` - *ping*, the delay time of connected peer.
|
3826
|
+
- `String` - *duration*, the connected time.
|
3827
|
+
- `Integer` - *total_sent*, total data sent in byte.
|
3828
|
+
- `Integer` - *total_received*, total data received in byte.
|
3829
|
+
- `Integer` - *average_sent_rate*, average data sent rate in byte.
|
3830
|
+
- `Integer` - *average_received_rate*, average data received rate in byte.
|
3831
|
+
- `Integer` - *current_sent_rate*, current data sent rate in byte.
|
3832
|
+
- `Integer` - *current_received_rate*, current data received rate in byte.
|
3833
|
+
|
3834
|
+
##### Example
|
3835
|
+
|
3836
|
+
```js
|
3837
|
+
bytom_client.peer.list_peers
|
3838
|
+
# response data
|
3839
|
+
{
|
3840
|
+
"status" =>"success",
|
3841
|
+
"data" => [
|
3842
|
+
{
|
3843
|
+
"peer_id" =>"3B58D7139B53066F2031FC1F027D2B3423FA4CE01F1FB1CC2DC4003C78413C24",
|
3844
|
+
"remote_addr" =>"52.83.251.197:46656 ", " height"=>119253,
|
3845
|
+
"ping" =>"40ms",
|
3846
|
+
"duration" =>"1h29m55.68s",
|
3847
|
+
"total_sent" =>9400,
|
3848
|
+
"total_received" =>79809,
|
3849
|
+
"average_sent_rate" =>2,
|
3850
|
+
"average_received_rate" =>15,
|
3851
|
+
"current_sent_rate" =>0,
|
3852
|
+
"current_received_rate" =>0
|
3853
|
+
}
|
3854
|
+
]
|
3855
|
+
}
|
3856
|
+
```
|
3857
|
+
|
3858
|
+
----
|
3859
|
+
|
3860
|
+
#### `disconnect-peer`
|
3861
|
+
|
3862
|
+
Disconnect to specified peer.
|
3863
|
+
|
3864
|
+
##### Parameters
|
3865
|
+
|
3866
|
+
`Object`:
|
3867
|
+
|
3868
|
+
- `String` - *peer_id*, peer id.
|
3869
|
+
|
3870
|
+
##### Returns
|
3871
|
+
|
3872
|
+
none if disconnect peer successfully.
|
3873
|
+
|
3874
|
+
##### Example
|
3875
|
+
|
3876
|
+
```js
|
3877
|
+
bytom_client.peer.disconnect_peer(
|
3878
|
+
peer_id: '3B58D7139B53066F2031FC1F027D2B3423FA4CE01F1FB1CC2DC4003C78413C24'
|
3879
|
+
)
|
3880
|
+
|
3881
|
+
```
|
3882
|
+
|
3883
|
+
----
|
3884
|
+
|
3885
|
+
#### `connect-peer`
|
3886
|
+
|
3887
|
+
Connect to specified peer.
|
3888
|
+
|
3889
|
+
##### Parameters
|
3890
|
+
|
3891
|
+
`Object`:
|
3892
|
+
|
3893
|
+
- `String` - *ip*, peer IP address.
|
3894
|
+
- `Integer` - *port*, peer port.
|
3895
|
+
|
3896
|
+
##### Returns
|
3897
|
+
|
3898
|
+
`Object`:
|
3899
|
+
|
3900
|
+
- `String` - *peer_id*, peer id.
|
3901
|
+
- `String` - *remote_addr*, the address(IP and port) of connected peer.
|
3902
|
+
- `Integer` - *height*, the current height of connected peer.
|
3903
|
+
- `Integer` - *delay*, the delay time of connected peer.
|
3904
|
+
|
3905
|
+
##### Example
|
3906
|
+
|
3907
|
+
```js
|
3908
|
+
bytom_client.peer.connect_peer(
|
3909
|
+
ip:"139.198.177.164",
|
3910
|
+
port:46657
|
3911
|
+
)
|
3912
|
+
# Result
|
3913
|
+
{
|
3914
|
+
"peer_id" => "29661E8BB9A8149F01C6594E49EA80C6B18BF247946A7E2E01D8235BBBFC3594",
|
3915
|
+
"remote_addr" => "139.198.177.164:46657",
|
3916
|
+
"height"=> 65941,
|
3917
|
+
"delay" => 0
|
3918
|
+
}
|
3919
|
+
```
|
3920
|
+
|
3921
|
+
----
|
3922
|
+
|
3923
|
+
#### `get-work`
|
3924
|
+
|
3925
|
+
Get the proof of work.
|
3926
|
+
|
3927
|
+
##### Parameters
|
3928
|
+
|
3929
|
+
none
|
3930
|
+
|
3931
|
+
##### Returns
|
3932
|
+
|
3933
|
+
`Object`:
|
3934
|
+
|
3935
|
+
- `Object` - *block_header*, raw block header.
|
3936
|
+
- `String` - *seed*, seed.
|
3937
|
+
|
3938
|
+
##### Example
|
3939
|
+
|
3940
|
+
```js
|
3941
|
+
bytom_client.work.get_work
|
3942
|
+
|
3943
|
+
# response data
|
3944
|
+
{
|
3945
|
+
"status" =>"success",
|
3946
|
+
"data" => {
|
3947
|
+
"block_header" =>"0101d6a3078336f0926cb157d6b43f8acbb62b643eb86d6b12a88bd05a24befbbf7d7578db8faf81e205403968cdf061c37bd620c02f497e847473a8a4669fbbc0bb936bd5c8305d08ff01c9c377e5192668bc0a367e4a4764f11e7c725ecced1d7b6a492974fab1b6d5bc0090fc9683808080801e",
|
3948
|
+
"seed" =>"be00f0b385475ea5578060b76e6bd4186468e797049f673580de3d7855500f21"
|
3949
|
+
}
|
3950
|
+
}
|
3951
|
+
```
|
3952
|
+
|
3953
|
+
----
|
3954
|
+
|
3955
|
+
#### `submit-work`
|
3956
|
+
|
3957
|
+
Submit the proof of work.
|
3958
|
+
|
3959
|
+
##### Parameters
|
3960
|
+
|
3961
|
+
`Object`:
|
3962
|
+
|
3963
|
+
- `Object` - *block_header*, raw block header.
|
3964
|
+
|
3965
|
+
##### Returns
|
3966
|
+
|
3967
|
+
true if success
|
3968
|
+
|
3969
|
+
##### Example
|
3970
|
+
|
3971
|
+
```ruby
|
3972
|
+
bytom_client.work.submit_work(
|
3973
|
+
block_header: "0101d6a3078336f0926cb157d6b43f8acbb62b643eb86d6b12a88bd05a24befbbf7d7578db8faf81e205403968cdf061c37bd620c02f497e847473a8a4669fbbc0bb936bd5c8305d08ff01c9c377e5192668bc0a367e4a4764f11e7c725ecced1d7b6a492974fab1b6d5bc0090fc9683808080801e"
|
3974
|
+
)
|
3975
|
+
// Request
|
3976
|
+
curl -X POST http://127.0.0.1:9888/submit-work -d '{"block_header": "0101d6a3078336f0926cb157d6b43f8acbb62b643eb86d6b12a88bd05a24befbbf7d7578db8faf81e205403968cdf061c37bd620c02f497e847473a8a4669fbbc0bb936bd5c8305d08ff01c9c377e5192668bc0a367e4a4764f11e7c725ecced1d7b6a492974fab1b6d5bc0090fc9683808080801e"}'
|
3977
|
+
|
3978
|
+
// Result
|
3979
|
+
true / error
|
3980
|
+
```
|
3981
|
+
|
3982
|
+
----
|
3983
|
+
|
3984
|
+
#### `get-work-json`
|
3985
|
+
|
3986
|
+
Get the proof of work by json.
|
3987
|
+
|
3988
|
+
##### Parameters
|
3989
|
+
|
3990
|
+
none
|
3991
|
+
|
3992
|
+
##### Returns
|
3993
|
+
|
3994
|
+
`Object`:
|
3995
|
+
|
3996
|
+
- `Object` - *block_header*, Object of block header.
|
3997
|
+
- `Integer` - *version*, version of block.
|
3998
|
+
- `Integer` - *height*, height of block.
|
3999
|
+
- `String` - *previous_block_hash*, previous block hash.
|
4000
|
+
- `Integer` - *timestamp*, timestamp of block.
|
4001
|
+
- `Integer` - *nonce*, nonce value.
|
4002
|
+
- `Integer` - *bits*, bits of difficulty.
|
4003
|
+
- `Object` - *block_commitment*, Object of block commitment.
|
4004
|
+
- `String` - *transaction_merkle_root*, merkle root of transaction.
|
4005
|
+
- `String` - *transaction_status_hash*, merkle root of transaction status.
|
4006
|
+
- `String` - *seed*, seed.
|
4007
|
+
|
4008
|
+
##### Example
|
4009
|
+
|
4010
|
+
```ruby
|
4011
|
+
bytom_client.work.get_work_json
|
4012
|
+
# response data
|
4013
|
+
{
|
4014
|
+
"status" =>"success",
|
4015
|
+
"data" => {
|
4016
|
+
"block_header" => {
|
4017
|
+
"version" =>1,
|
4018
|
+
"height" =>119258,
|
4019
|
+
"previous_block_hash" =>"d459ad431406704cffe9f41d6c5170185da780d64f04fa11f3e11cb5b13c8c68",
|
4020
|
+
"timestamp" =>1547720937,
|
4021
|
+
"nonce" =>0,
|
4022
|
+
"bits" =>2161727821144505872,
|
4023
|
+
"block_commitment" => {
|
4024
|
+
"transaction_merkle_root" =>"874e4cffc9fa1e09bf38c8f8bc27c0791e1644818af511bd2c886f5981f41027",
|
4025
|
+
"transaction_status_hash" =>"c9c377e5192668bc0a367e4a4764f11e7c725ecced1d7b6a492974fab1b6d5bc"
|
4026
|
+
}
|
4027
|
+
},
|
4028
|
+
"seed" =>"be00f0b385475ea5578060b76e6bd4186468e797049f673580de3d7855500f21"
|
4029
|
+
}
|
4030
|
+
}
|
4031
|
+
```
|
4032
|
+
|
4033
|
+
----
|
4034
|
+
|
4035
|
+
#### `submit-work-json`
|
4036
|
+
|
4037
|
+
Submit the proof of work by json.
|
4038
|
+
|
4039
|
+
##### Parameters
|
4040
|
+
|
4041
|
+
`Object`:
|
4042
|
+
|
4043
|
+
- `Object` - *block_header*, Object of block header.
|
4044
|
+
- `Integer` - *version*, version of block.
|
4045
|
+
- `Integer` - *height*, height of block.
|
4046
|
+
- `String` - *previous_block_hash*, previous block hash.
|
4047
|
+
- `Integer` - *timestamp*, timestamp of block.
|
4048
|
+
- `Integer` - *nonce*, nonce value.
|
4049
|
+
- `Integer` - *bits*, bits of difficulty.
|
4050
|
+
- `Object` - *block_commitment*, Object of block commitment.
|
4051
|
+
- `String` - *transaction_merkle_root*, merkle root of transaction.
|
4052
|
+
- `String` - *transaction_status_hash*, merkle root of transaction status.
|
4053
|
+
|
4054
|
+
##### Returns
|
4055
|
+
|
4056
|
+
true if success
|
4057
|
+
|
4058
|
+
##### Example
|
4059
|
+
|
4060
|
+
```ruby
|
4061
|
+
bytom_client.work.submit_work_json(
|
4062
|
+
block_header: {
|
4063
|
+
version: 1,
|
4064
|
+
height: 119258,
|
4065
|
+
previous_block_hash: "d459ad431406704cffe9f41d6c5170185da780d64f04fa11f3e11cb5b13c8c68",
|
4066
|
+
timestamp: 1547720937,
|
4067
|
+
nonce: 0,
|
4068
|
+
bits: 2161727821144505872,
|
4069
|
+
block_commitment: {
|
4070
|
+
transaction_merkle_root: "874e4cffc9fa1e09bf38c8f8bc27c0791e1644818af511bd2c886f5981f41027",
|
4071
|
+
transaction_status_hash: "c9c377e5192668bc0a367e4a4764f11e7c725ecced1d7b6a492974fab1b6d5bc"
|
4072
|
+
}
|
4073
|
+
}
|
4074
|
+
)
|
4075
|
+
|
4076
|
+
# Request
|
4077
|
+
curl -X POST submit-work-json -d '{"block_header":{"version":1,"height":62960,"previous_block_hash":"dabdb926f8635791ac43f5d5fc62a4597e10e140f00aced3af621a77ead4e9fd","timestamp":1533006396,"nonce":0,"bits":2017612633069711400,"block_commitment":{"transaction_merkle_root":"a13fc86af3852ab73e30c3ae30e8cedbe990560a3c0f20dc37c4c14562b94802","transaction_status_hash":"c9c377e5192668bc0a367e4a4764f11e7c725ecced1d7b6a492974fab1b6d5bc"}}}'
|
4078
|
+
|
4079
|
+
# Response data
|
4080
|
+
true / error
|
4081
|
+
```
|