-
Notifications
You must be signed in to change notification settings - Fork 5
/
change_fee.py
56 lines (47 loc) · 2.05 KB
/
change_fee.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
from grapheneapi.grapheneapi import GrapheneAPI
from graphenebase.transactions import getOperationNameForId
from pprint import pprint
from deepdiff import DeepDiff
proposer = "cryptonomex-fabian"
expiration = "2016-03-29T19:25:00"
price_per_kbyte = 0
everythin_flat_fee = 0.1
broadcast = True
class Wallet():
wallet_host = "localhost"
wallet_port = 8092
if __name__ == '__main__':
rpc = GrapheneAPI("localhost", 8092)
obj = rpc.get_object("2.0.0")
current_fees = obj["parameters"]["current_fees"]["parameters"]
old_fees = obj["parameters"]["current_fees"]
scale = obj["parameters"]["current_fees"]["scale"] / 1e4
# General change of parameter
changes = {}
for f in current_fees:
if ("price_per_kbyte" in f[1] and f[1]["price_per_kbyte"] != 0):
print("Changing operation %s[%d]" % (getOperationNameForId(
f[0]), f[0]))
changes[getOperationNameForId(f[0])] = f[1].copy()
changes[getOperationNameForId(f[0])]["price_per_kbyte"] = int(
price_per_kbyte / scale * 1e5)
if ("fee" in f[1] and f[1]["fee"] != 0):
print("Changing operation %s[%d]" % (getOperationNameForId(
f[0]), f[0]))
changes[getOperationNameForId(f[0])] = f[1].copy()
changes[getOperationNameForId(f[0])]["fee"] = int(
everythin_flat_fee / scale * 1e5)
# overwrite / set specific fees
changes["transfer"]["price_per_kbyte"] = int(0)
# changes["account_update"]["price_per_kbyte"] = int( 5 / scale * 1e5)
print("=" * 80)
tx = rpc.propose_fee_change(proposer,
expiration,
changes,
broadcast)
proposed_ops = tx["operations"][0][1]["proposed_ops"][0]
new_fees = proposed_ops["op"][1]["new_parameters"]["current_fees"]
pprint(DeepDiff(old_fees, new_fees))
if not broadcast:
print("=" * 80)
print("Set broadcast to 'True' if the transaction shall be broadcast!")