lightning: do not catch BaseException unnecessarily, fix clearSubscribers, detect passworded wallet correctly
This commit is contained in:
@@ -619,7 +619,7 @@ class LightningRPC:
|
|||||||
resolvedMethod = getattr(client, qitem.methodName)
|
resolvedMethod = getattr(client, qitem.methodName)
|
||||||
try:
|
try:
|
||||||
result = resolvedMethod(lightningSessionKey, *argumentStrings)
|
result = resolvedMethod(lightningSessionKey, *argumentStrings)
|
||||||
except BaseException as e:
|
except Exception as e:
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
for i in self.subscribers: applyMethodName(i)(e)
|
for i in self.subscribers: applyMethodName(i)(e)
|
||||||
raise
|
raise
|
||||||
@@ -629,7 +629,7 @@ class LightningRPC:
|
|||||||
assert result["stderr"] == "" and result["returncode"] == 0, "LightningRPC detected error: " + result["stderr"]
|
assert result["stderr"] == "" and result["returncode"] == 0, "LightningRPC detected error: " + result["stderr"]
|
||||||
toprint = json.loads(result["stdout"])
|
toprint = json.loads(result["stdout"])
|
||||||
for i in self.subscribers: applyMethodName(i)(toprint)
|
for i in self.subscribers: applyMethodName(i)(toprint)
|
||||||
except BaseException as e:
|
except Exception as e:
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
for i in self.subscribers: applyMethodName(i)(e)
|
for i in self.subscribers: applyMethodName(i)(e)
|
||||||
if self.console:
|
if self.console:
|
||||||
@@ -639,7 +639,7 @@ class LightningRPC:
|
|||||||
self.console = console
|
self.console = console
|
||||||
def subscribe(self, notifyFunction):
|
def subscribe(self, notifyFunction):
|
||||||
self.subscribers.append(notifyFunction)
|
self.subscribers.append(notifyFunction)
|
||||||
def clearSubscribers():
|
def clearSubscribers(self):
|
||||||
self.subscribers = []
|
self.subscribers = []
|
||||||
|
|
||||||
def lightningCall(rpc, methodName):
|
def lightningCall(rpc, methodName):
|
||||||
@@ -670,9 +670,9 @@ class LightningWorker:
|
|||||||
assert hasattr(ks, "xprv"), "Wallet must have xprv, can't be e.g. imported"
|
assert hasattr(ks, "xprv"), "Wallet must have xprv, can't be e.g. imported"
|
||||||
try:
|
try:
|
||||||
xprv = ks.get_master_private_key(None)
|
xprv = ks.get_master_private_key(None)
|
||||||
|
xprv, xpub = bitcoin.bip32_private_derivation(xprv, "m/", "m/152/152/152/152")
|
||||||
except:
|
except:
|
||||||
raise BaseException("Could not get master private key, is the wallet password protected?")
|
raise Exception("Could not get master private key, is the wallet password protected?")
|
||||||
xprv, xpub = bitcoin.bip32_private_derivation(xprv, "m/", "m/152/152/152/152")
|
|
||||||
tupl = bitcoin.deserialize_xprv(xprv)
|
tupl = bitcoin.deserialize_xprv(xprv)
|
||||||
privKey = tupl[-1]
|
privKey = tupl[-1]
|
||||||
assert type(privKey) is type(bytes([]))
|
assert type(privKey) is type(bytes([]))
|
||||||
@@ -774,7 +774,7 @@ async def readReqAndReply(obj, writer, netAndWalLock):
|
|||||||
netAndWalLock.release()
|
netAndWalLock.release()
|
||||||
found = True
|
found = True
|
||||||
break
|
break
|
||||||
except BaseException as e:
|
except Exception as e:
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
print("exception while calling method", obj["method"])
|
print("exception while calling method", obj["method"])
|
||||||
writer.write(json.dumps({"id":obj["id"],"error": {"code": -32002, "message": traceback.format_exc()}}).encode("ascii") + b"\n")
|
writer.write(json.dumps({"id":obj["id"],"error": {"code": -32002, "message": traceback.format_exc()}}).encode("ascii") + b"\n")
|
||||||
|
|||||||
Reference in New Issue
Block a user