1
0

ln: add test_lnwatcher

This commit is contained in:
Janus
2019-01-23 15:10:11 +01:00
committed by ThomasV
parent 129099797a
commit 8fc1779b0d
10 changed files with 237 additions and 10 deletions

View File

@@ -72,9 +72,9 @@ class LNWorker(PrintError):
self.network = network
self.channel_db = self.network.channel_db
self.lock = threading.RLock()
self.config = network.config
self.ln_keystore = self._read_ln_keystore()
self.node_keypair = generate_keypair(self.ln_keystore, LnKeyFamily.NODE_KEY, 0)
self.config = network.config
self.peers = {} # type: Dict[bytes, Peer] # pubkey -> Peer
self.invoices = wallet.storage.get('lightning_invoices', {}) # type: Dict[str, Tuple[str,str]] # RHASH -> (preimage, invoice)
self.channels = {} # type: Dict[bytes, Channel]
@@ -209,9 +209,13 @@ class LNWorker(PrintError):
def _read_ln_keystore(self) -> BIP32_KeyStore:
xprv = self.wallet.storage.get('lightning_privkey2')
if xprv is None:
# TODO derive this deterministically from wallet.keystore at keystore generation time
# probably along a hardened path ( lnd-equivalent would be m/1017'/coinType'/ )
seed = os.urandom(32)
if not self.config.debug_lightning:
# TODO derive this deterministically from wallet.keystore at keystore generation time
# probably along a hardened path ( lnd-equivalent would be m/1017'/coinType'/ )
seed = os.urandom(32)
else:
# dangerous deterministic secret for testing
seed = sha256(self.config.electrum_path())
xprv, xpub = bip32_root(seed, xtype='standard')
self.wallet.storage.put('lightning_privkey2', xprv)
self.wallet.storage.write()