• R/O
  • HTTP
  • SSH
  • HTTPS

bytom-spanner: 提交

Python based Bytom wallet tools


Commit MetaInfo

修訂6f0296b1aa220c8f4de56d7f04ca7f8abb039377 (tree)
時間2018-06-28 16:58:31
作者successli <successli@outl...>
Commitersuccessli

Log Message

docs(utxomeger/README.md): add some details to doc.

Change Summary

差異

--- a/utxomerger/README.md
+++ b/utxomerger/README.md
@@ -3,21 +3,25 @@
33
44 > **One last disclaimer:**
55
6-**the code we are about to go over is in no way intended to be used as an example of a robust solution.**
6+**The code we are about to go over is in no way intended to be used as an example of a robust solution.**
77
88 **We wouldn't be responsible for the consequences of using this tool.**
99
10-**please check this python code carefully and use it later.**
10+**Please check this python code carefully and use it later.**
1111
1212
13-Requirements: Python 3.x, with requests package
13+## Preparation
1414
15-Dependencies:
15+- Requirements: Python 3.x, with requests package
16+
17+- Dependencies:
1618 ```
1719 pip install requests
1820 ```
1921
20-Usage:
22+## Usage:
23+
24+
2125 ```
2226 ./bytomd init --chain_id mainnet
2327 ```
@@ -27,7 +31,9 @@ Usage:
2731 ```
2832 If you don't know how to run bytomd please check this [wiki](https://github.com/Bytom/bytom/wiki/Build-and-Install)
2933
30-Options:
34+- Options:
35+
36+
3137 ```
3238 $ python btmspanner.py utxomerger -h
3339 usage: btmspanner.py [-h] [-o URL] [-a ACCOUNT_ALIAS] [-p PASSWORD]
@@ -56,12 +62,31 @@ optional arguments:
5662
5763 ```
5864
59-Example:
65+## Example
66+
67+
68+**eg.01:**
69+
70+ ```
71+$ python btmspanner.py utxomerger -l
72+ ```
73+ this example can list all utxos at localhost.
74+
75+**eg.02:**
76+
77+ ```
78+$ python btmspanner.py utxomerger -o http://127.0.0.1:9888 -l
79+ ```
80+ this example can list all utxos at host http://127.0.0.1:9888.
81+
82+**eg.03:**
83+
6084 ```
6185 $ python btmspanner.py utxomerger -o http://127.0.0.1:9888 -a your_account_alias -p your_password -x 41250000000 -s 0 -m 20 -f 3 -y
6286 ```
6387
64-Result:
88+**Result:**
89+
6590 ```
6691 $ python btmspanner.py utxomerger -o http://52.83.158.112:9888 -a btmpool_test -p btmpool -x 41250000000 -s 0 -m 20 -f 3 -y
6792 0. 412.50000000 BTM fac1fa4776c43e2159683c6ce7ffdd64734be2bd982d997b59fa8198c6af4d1c (mature)
--- a/utxomerger/merge_utxo.py
+++ b/utxomerger/merge_utxo.py
@@ -85,19 +85,42 @@ def send_tx(connection, utxo_list, to_address, password):
8585
8686 def main():
8787 options = parser.parse_args()
88+
89+ if options.only_list:
90+ data, ret = UnspentOutputs.list_UTXO(connection=Connection(options.url))
91+ if ret == 1:
92+ for i, utxo in enumerate(data):
93+ print('{:4}. {:13.8f} BTM {}{}'.format(i, utxo['amount'] / 1e8, utxo['id'], ' (mature)'))
94+ if i >= 99:
95+ print('...')
96+ print('...')
97+ print('only print 100 utxos.')
98+ break
99+ print("total size of available utxos is {}".format(len(data)))
100+ elif ret == -1:
101+ print("failed error is {}".format(data))
102+ else:
103+ print(data)
104+
105+ return
106+
88107 utxo_total = []
89108 utxolist = list_utxo(options.url, options.account_alias, options.min_amount, options.max_amount)
90109
91110 for i, utxo in enumerate(utxolist):
92111 print('{:4}. {:13.8f} BTM {}{}'.format(i, utxo['amount'] / 1e8, utxo['id'], ' (mature)'))
112+ if i >= 99:
113+ print('...')
114+ print('...')
115+ print('only print 100 utxos.')
116+ break
117+
118+ for i, utxo in enumerate(utxolist):
93119 if i >= options.merge_list * options.for_loop:
94120 break
95121 utxo_total.append(utxo)
96122
97- print("total size of available utxos is {}".format(len(utxolist)))
98-
99- if options.only_list:
100- return
123+ print("total size of available utxos is {}\n".format(len(utxolist)))
101124
102125 print('To merge {} UTXOs with {:13.8f} BTM totally.\n'.format(len(utxo_total),
103126 sum(utxo['amount'] for utxo in utxo_total) / 1e8))
Show on old repository browser