-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathincrease_per_kb_fee.py
44 lines (35 loc) · 1.54 KB
/
increase_per_kb_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
from grapheneapi.grapheneapi import GrapheneAPI
from graphenebase.transactions import getOperationNameForId
import json
from deepdiff import DeepDiff
proposer = "xeroc"
expiration = "2016-01-21T22:59:59"
price_per_kbyte = 40 # in BTS
broadcast = False
if __name__ == "__main__":
graphene = GrapheneAPI("localhost", 8092)
obj = graphene.getObject("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"] is 20):
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
)
# overwrite / set specific fees
# changes["transfer"]["price_per_kbyte"] = int( 20 / scale * 1e5)
# changes["account_update"]["price_per_kbyte"] = int( 5 / scale * 1e5)
print("=" * 80)
tx = graphene.rpc.propose_fee_change(proposer, expiration, changes, broadcast)
new_fees = tx["operations"][0][1]["proposed_ops"][0]["op"][1]["new_parameters"][
"current_fees"
]
print(json.dumps(DeepDiff(old_fees, new_fees), indent=4))
if not broadcast:
print("=" * 80)
print("Set broadcast to 'True' if the transaction shall be broadcast!")