Skip to content

Commit

Permalink
mit neuen Checkpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
stallingerl committed Feb 15, 2022
1 parent 0ef04fb commit f4bc3b2
Show file tree
Hide file tree
Showing 2 changed files with 183 additions and 0 deletions.
116 changes: 116 additions & 0 deletions electrum/checkpoints.json
Original file line number Diff line number Diff line change
Expand Up @@ -334,5 +334,121 @@
[
"cbb9daae26a894c148b1e110bc99608c96b98d3adeae1dedfcecefc188f473fc",
1376401675055452882801399232352887291412068830154469192761344
],
[
"ecd732a52807c08eeef292a8f9f356fdf4b1dba82f9c61df4e362b3f60de62d9",
1252502475567527500380843591901839094534861009604169324036096
],
[
"3870b5d191d5dcc0a57892a507890644ddf171074a0a3b848006542164ff3ee3",
1290165085979847584963858328441085093031475142270953531113472
],
[
"25a0c2aa87b36a6933d8093297f0a9052e49367607a37bbed8eb940e38aa14cb",
2156135406248017133934126199766964604037283295521485979910144
],
[
"b628dbfa6078dd70e952ecdf9cf22b581443d156a9b5494cd4c0e894c85535c9",
3282188609747618412834105861764577387213394902676041921200128
],
[
"16254802a9208384ad6d14872a6fb9f3f53de000c63b9c50720607f1fe27d4b4",
3457358980050752972899898360355966328137751259298116384325632
],
[
"ef50f040af42c371b0f8879f0031c73bfcde5cc5a5aa1c9762c7731ae3353a44",
3558797924891747888212354066777099593619842839273693379559424
],
[
"7f58210fc71b139a1840225af342dccc588461620892e0f91a047e923dc3f1e4",
3491343601164994924222853064030051584593680418071659946180608
],
[
"10f6a173bef95eaf2c6a99a759d51c7a6c46ba76cbb129299a463d690dc24e80",
3876674279960314018768475840536725325722776182953504877314048
],
[
"59a3838ecad4fcb96e19af16c3cf80440b2439bdddeb9d5711593632c6e9b165",
3199556450184129685591423790060632716032672489207902091870208
],
[
"64d4a3104af70cfa9769948b96dedc0609e6a6e7cf01be747b1439cd95acf73d",
3277799542518578507143767555878818901711510833830108084568064
],
[
"176f738aee696ede0e37e1ee254d314ea63680dab176587d7650c4a83d5b80f0",
3193769747021820089262262671686113148555328130282536810053632
],
[
"ad0b8c73330fad25202751d8b0a69f992ec0063117c90cd77752b6393f20b630",
5453035973187948079808472192992184959413418093770490481999872
],
[
"afad578ad7a8069f53558f69eef2cb6b603c70a622241ca67559afd3ac4a7d92",
4602807447115552941191261262329193424341741628783027994755072
],
[
"09e2ef643dd7891b88e085b0d0742b4e18aa2a0ae07fc19944b5aa82dab0c4df",
4920610242398157509082181835431515941603861272984974679605248
],
[
"772a2a9d33e9c2ce5df05ba3b350affbc86f6e9b1cb72cfbd363540790aa1d29",
3076589007985050763596750024602091907139104862043889853267968
],
[
"4fce71628644216368f0ace6edabf564a2b5c42271a99d8d27a4aada2ab969b8",
3275273989867231522305192999978075192176907151756749508182016
],
[
"ec723c7032a3a08410024d780e434b2f36db49ca073c1ef0bdd6cdb14cbca6a1",
3340595079801099169003859183663329970819472288100703367331840
],
[
"c1c26ab1595711eae1d8a15c892f855f46a0a34f8559e6e7e0706439b842d216",
3319679580659361517864984463436782551081443736561141564833792
],
[
"dd4f1c82ffefb524d50e05f8e6b2ad968cf2349c07c8284527318fa03e1e6242",
3609529657276572272979448786763883428834357579174459345993728
],
[
"c7f6e39943882dad86fb50a5f19477b2fa625f56da65cf83d1686d2d1ecfc522",
3225474014771253597963980154983798744946032605242271171870720
],
[
"81966091c96f29b2a90f36794dd58988afd2e73c20a9da23fa2ab707609340f5",
3380292844291689153990773805054631579911932106321747398098944
],
[
"f179e054deb45a3229cd70b7b08fbf76c9704e2cb4433fc599a795c090be509a",
3527436936143468338614908853213495666486268961877328144629760
],
[
"5c8e81c634cb6b5e5342360e3d95ed1e395ffde20ef3293f693760ee49dd2ff1",
3545213884417512649371865678728439253016246335694657929871360
],
[
"7fbc61f3e58fc8c73894298b0b99d55ca01d468149306aaee78eb0a152a95b7c",
3005947093533296750781863660038571255011015463467714527363072
],
[
"c04e1e4678e004e59ffcae35f032ac56fe4d31ad763cbbc6fd2ddd9cb659df67",
3645426832825814853597634707527852271151442924372488043364352
],
[
"3d03b26e316bd6ab44b5e8f2ca284e000d1dceb36b9620b333e0da005a734057",
3539696900470395449481775629430698139955218874854796962037760
],
[
"826b3f5d7f7b3861e5f2c8fa123528e742d871e4754d4f464c5e1efc3f5ccb96",
2816751324040157575884375569454702684438180406399415737122816
],
[
"289efb3348ddf271f075f85046cbf8e86f6060dab2ef62d8ac6178a4bb64a2e7",
2520893864902752536445146525781172594685481106427138235432960
],
[
"5d30cd30da5549742005d12fecbb5150919af2e42aeb047fac00019df9ec0370",
1684568138377092741550962519348488664527593842756125387128832
]
]
67 changes: 67 additions & 0 deletions electrum/get_checkpoints_array.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#!/usr/bin/env python
from json import loads, dumps
from sys import exit, argv
import base64
import urllib.request, urllib.error, urllib.parse


# From electrum.
def bits_to_target(bits):
bitsN = (bits >> 24) & 0xff
if not (bitsN >= 0x03 and bitsN <= 0x1f):
raise BaseException("First part of bits should be in [0x03, 0x1e]")
bitsBase = bits & 0xffffff
if not (bitsBase >= 0x8000 and bitsBase <= 0x7fffff):
raise BaseException("Second part of bits should be in [0x8000, 0x7fffff]")
return bitsBase << (8 * (bitsN-3))

def rpc(method, params):
data = {
"jsonrpc": "1.0",
"id":"1",
"method": method,
"params": params
}

data_json = dumps(data)
username = "admin"
password = "changeMe"
port = 8339
if len(argv) > 3:
port = argv[3]
url = "http://127.0.0.1:{}/".format(port)
req = urllib.request.Request(url, data_json.encode("utf-8"), {'content-type': 'application/json'})

base64string = base64.encodestring(('%s:%s' % (username, password)).encode()).decode().replace('\n', '')
req.add_header("Authorization", "Basic %s" % base64string)

response_stream = urllib.request.urlopen(req)
json_response = response_stream.read()

return loads(json_response)

# Electrum checkpoints are blocks 2015, 2015 + 2016, 2015 + 2016*2, ...
i = 2015
INTERVAL = 2016

checkpoints = []
block_count = int(rpc('getblockcount', [])['result'])
print(('Blocks: {}'.format(block_count)))
while True:
h = rpc('getblockhash', [i])['result']
block = rpc('getblock', [h])['result']
bits = "0x" + block['bits']
print(bits)

checkpoints.append([
block['hash'],
bits_to_target(int(bits, 16))
])

i += INTERVAL
if i > block_count:
print('Done.')
break

with open('checkpoints_output.json', 'w+') as f:
f.write(dumps(checkpoints, indent=4, separators=(',', ':')))

0 comments on commit f4bc3b2

Please sign in to comment.