> **One last disclaimer:**
-**the code we are about to go over is in no way intended to be used as an example of a robust solution.**
+**The code we are about to go over is in no way intended to be used as an example of a robust solution.**
**We wouldn't be responsible for the consequences of using this tool.**
-**please check this python code carefully and use it later.**
+**Please check this python code carefully and use it later.**
-Requirements: Python 3.x, with requests package
+## Preparation
-Dependencies:
+- Requirements: Python 3.x, with requests package
+
+- Dependencies:
```
pip install requests
```
-Usage:
+## Usage:
+
+
```
./bytomd init --chain_id mainnet
```
```
If you don't know how to run bytomd please check this [wiki](https://github.com/Bytom/bytom/wiki/Build-and-Install)
-Options:
+- Options:
+
+
```
$ python btmspanner.py utxomerger -h
usage: btmspanner.py [-h] [-o URL] [-a ACCOUNT_ALIAS] [-p PASSWORD]
```
-Example:
+## Example
+
+
+**eg.01:**
+
+ ```
+$ python btmspanner.py utxomerger -l
+ ```
+ this example can list all utxos at localhost.
+
+**eg.02:**
+
+ ```
+$ python btmspanner.py utxomerger -o http://127.0.0.1:9888 -l
+ ```
+ this example can list all utxos at host http://127.0.0.1:9888.
+
+**eg.03:**
+
```
$ 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
```
-Result:
+**Result:**
+
```
$ 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
0. 412.50000000 BTM fac1fa4776c43e2159683c6ce7ffdd64734be2bd982d997b59fa8198c6af4d1c (mature)
def main():
options = parser.parse_args()
+
+ if options.only_list:
+ data, ret = UnspentOutputs.list_UTXO(connection=Connection(options.url))
+ if ret == 1:
+ for i, utxo in enumerate(data):
+ print('{:4}. {:13.8f} BTM {}{}'.format(i, utxo['amount'] / 1e8, utxo['id'], ' (mature)'))
+ if i >= 99:
+ print('...')
+ print('...')
+ print('only print 100 utxos.')
+ break
+ print("total size of available utxos is {}".format(len(data)))
+ elif ret == -1:
+ print("failed error is {}".format(data))
+ else:
+ print(data)
+
+ return
+
utxo_total = []
utxolist = list_utxo(options.url, options.account_alias, options.min_amount, options.max_amount)
for i, utxo in enumerate(utxolist):
print('{:4}. {:13.8f} BTM {}{}'.format(i, utxo['amount'] / 1e8, utxo['id'], ' (mature)'))
+ if i >= 99:
+ print('...')
+ print('...')
+ print('only print 100 utxos.')
+ break
+
+ for i, utxo in enumerate(utxolist):
if i >= options.merge_list * options.for_loop:
break
utxo_total.append(utxo)
- print("total size of available utxos is {}".format(len(utxolist)))
-
- if options.only_list:
- return
+ print("total size of available utxos is {}\n".format(len(utxolist)))
print('To merge {} UTXOs with {:13.8f} BTM totally.\n'.format(len(utxo_total),
sum(utxo['amount'] for utxo in utxo_total) / 1e8))