lightning: save key derivation point

This commit is contained in:
Janus 2018-03-20 13:08:55 +01:00 committed by ThomasV
parent 6ab8badb61
commit 311c53ef1d

View file

@ -688,6 +688,7 @@ class LightningWorker:
async def run(self, netAndWalLock):
global WALLET, NETWORK
global CONFIG
global globalIdx
wasAlreadyUpToDate = False
@ -696,6 +697,9 @@ class LightningWorker:
NETWORK = self.network()
CONFIG = self.config()
globalIdx = WALLET.storage.get("lightning_global_key_index", 0)
if globalIdx != 0: print("initial lightning global key index", globalIdx)
writer = None
print("OPENING CONNECTION")
try:
@ -846,7 +850,7 @@ def DerivePrivKey(json):
msg = json_format.MessageToJson(m)
return msg
globalIdx = 0
globalIdx = None
def DeriveNextKey(json):
global globalIdx
@ -864,6 +868,8 @@ def DeriveNextKey(json):
m.keyDescriptor.pubKey = pubkFromECKEY(fetchPrivKey(None, 9000, globalIdx))
globalIdx += 1
WALLET.storage.put("lightning_global_key_index", globalIdx)
WALLET.storage.write()
msg = json_format.MessageToJson(m)
return msg