diff --git a/defs/.gitignore b/defs/.gitignore index e42d9910a..a6c57f5fb 100644 --- a/defs/.gitignore +++ b/defs/.gitignore @@ -1 +1 @@ -coins.json +*.json diff --git a/defs/coins/combine.py b/defs/coins/combine.py index 0d0b79dcb..cdd08b775 100755 --- a/defs/coins/combine.py +++ b/defs/coins/combine.py @@ -3,6 +3,8 @@ import json import glob import re +from hashlib import sha256 +import ed25519 def check_type(val, types, nullable=False, empty=False, regex=None, choice=None): @@ -78,18 +80,36 @@ def validate_coin(coin): assert not bc.endswith('/') +def serialize(coin): + # TODO: replace with protobuf serialization + return json.dumps(coin).encode() + + +def sign(data): + h = sha256(data).digest() + sign_key = ed25519.SigningKey(b'A' * 32) + return sign_key.sign(h) + + def process_json(fn): print(fn, end=' ... ') j = json.load(open(fn)) validate_coin(j) + ser = serialize(j) + sig = sign(ser) + definition = (sig + ser).hex() print('OK') - return j + return j, definition coins = {} +defs = {} for fn in glob.glob('*.json'): - c = process_json(fn) + c, d = process_json(fn) n = c['coin_name'] coins[n] = c + defs[n] = d + json.dump(coins, open('../coins.json', 'w'), indent=4, sort_keys=True) +json.dump(defs, open('../coindefs.json', 'w'), indent=4, sort_keys=True) diff --git a/defs/coins/schema.proto b/defs/coins/schema.proto index 88d13f9b8..912e45f8e 100644 --- a/defs/coins/schema.proto +++ b/defs/coins/schema.proto @@ -22,8 +22,8 @@ message CoinDef { optional uint32 fork_id = 20; optional bool force_bip143 = 21; optional uint64 dust_limit = 22; - optional uint32 blocktime_seconds = 23; - optional string address_prefix = 24; - optional uint32 min_address_length = 25; - optional uint32 max_address_length = 26; + optional string address_prefix = 23; + optional uint32 min_address_length = 24; + optional uint32 max_address_length = 25; + optional bytes icon = 26; }