* fix(build transaction): build transaction function add time range and use unconfirmed utxo support
* docs(btmsender): update btmsender document
-a account wallet account id
-p password wallet account password
-c count transaction output count
+ -u use unconfirmed UTXO build transaction
+ -t time_range the transaction will not be submitted into block after this height
```
See more details in btm-sender [README.md](https://github.com/Bytom/btm-spanner/blob/master/btmsender/README.md) file.
## utxo-merger
-a account wallet account id
-p password wallet account password
-c count transaction output count
+ -u use unconfirmed UTXO build transaction
+ -t time_range the transaction will not be submitted into block after this height
```
Example:
```
- btmspanner.py btmsender -i btmsender/btm.txt -a 0F0BV1OLG0A04 -p 123456 -c 1000
+ btmspanner.py btmsender -i btmsender/btm.txt -a 0F0BV1OLG0A04 -p 123456 -c 1000 -u -t 96310
```
Transaction txt file format:
-bm1qqn5mrdcaz00d0rvqd0zuuh6z4u4a860qfquwys,265024793
-bm1qufvnqamhyjwl2c58n0t4ej27kr0xzpm4r94578,296430573
-bm1qyenrv6thy5pl2jhz08xqj7ukg3kcyn2j3mfc7n,266596998
-bm1qkkwln4xwgxfl4j838ykudecqehxes6szxmy4fl,366249088
-bm1qhsk20pnxu2yudxrucmx5pccltgew3z0e3wfqv4,225333795
\ No newline at end of file
+sm1qkg026fh7g0v0fang53xscsz6wjc4q8prfanc7s,5000000000
+sm1q96zhtsnqxtnn7ydgkyslsgc8hntccu8yyue4yv,5500000000
+sm1q8fs0625xe6x0k060cluwxtqj7n7q5ju76krchd,3500000000
\ No newline at end of file
def sender():
- path, account_id, password, output_count = validation.validate_input()
- transaction.handle_input(path, account_id, password, output_count)
+ path, account_id, password, output_count, use_unconfirmed, time_range = validation.validate_input()
+ transaction.handle_input(path, account_id, password, output_count, use_unconfirmed, time_range)
max_output_count = 1500
-def handle_input(_path, _account_id, _password, _output_count):
+def handle_input(_path, _account_id, _password, _output_count, _use_unconfirmed, _time_range):
if _output_count <= 0:
_output_count = max_output_count
lines = list()
if len(lines) < _output_count:
lines.append(line)
else:
- handle_transaction(lines, _path, _account_id, _password)
+ handle_transaction(lines, _path, _account_id, _password, _use_unconfirmed, _time_range)
lines.clear()
lines.append(line)
if len(lines) > 0:
- handle_transaction(lines, _path, _account_id, _password)
+ handle_transaction(lines, _path, _account_id, _password, _use_unconfirmed, _time_range)
print('Transactions are completed.Please check completed.txt')
-def handle_transaction(lines, _path, _account_id, _password):
- data = build_transaction(lines, _account_id)
+def handle_transaction(lines, _path, _account_id, _password, _use_unconfirmed, _time_range):
+ data = build_transaction(lines, _account_id, _use_unconfirmed, _time_range)
data = sign_transaction(_password, data)
if data['sign_complete']:
data = submit_transaction(data)
# parameter lines: max_output line list
-def build_transaction(_lines, _account_id):
+def build_transaction(_lines, _account_id, _use_unconfirmed, _time_range):
amount_sum = 0
action_list = list()
for line in _lines:
address_dict = get_address_dict(amount, address)
action_list.append(address_dict)
amount_sum += miner_fee
- spend_dict = get_spend_dict(_account_id, int(amount_sum))
+ spend_dict = get_spend_dict(_account_id, int(amount_sum), _use_unconfirmed)
action_list.insert(0, spend_dict)
parameter = {'base_transaction': None, 'actions': action_list, 'ttl': 0}
+ if _time_range != 0:
+ parameter.update(time_range=_time_range)
return httprequest.post('build-transaction', parameter)
# spend_account action
-def get_spend_dict(_account_id, _amount_sum):
+def get_spend_dict(_account_id, _amount_sum, _use_unconfirmed):
return {'account_id': _account_id,
'amount': _amount_sum,
'asset_id': 'ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff',
- 'type': 'spend_account'}
+ 'type': 'spend_account',
+ 'use_unconfirmed': _use_unconfirmed}
parser.add_argument('-a', required=True, help='wallet account id')
parser.add_argument('-p', required=True, help='wallet account password')
parser.add_argument('-c', type=int, default=0, help='transaction max output count')
+ parser.add_argument('-u', action='store_true', help='use unconfirmed UTXO build transaction')
+ parser.add_argument('-t', type=int, default=0,
+ help='the transaction will not be submitted into block after this height')
args = parser.parse_args()
- return args.i, args.a, args.p, args.c
+ return args.i, args.a, args.p, args.c, args.u, args.t
def validate_input():
- input_path, account_id, password, output_count = get_input()
+ input_path, account_id, password, output_count, use_unconfirmed, time_range = get_input()
# relative path
file_path = os.path.abspath('.') + os.path.sep + input_path
if not os.path.exists(file_path):
'\nTotal amount is %.2f BTM(without gas).Send BTM or not?(y/n)' % (total_amount / pow(10, 8)))
if input() != 'y':
sys.exit(0)
- return file_path, account_id, password, output_count
+ return file_path, account_id, password, output_count, use_unconfirmed, time_range