]> Untitled Git - bitcoindevkit.org/commitdiff
Don't create wallet instance in a try/catch block
authorDaniela Brozzoni <danielabrozzoni@protonmail.com>
Wed, 14 Sep 2022 13:21:52 +0000 (15:21 +0200)
committerDaniela Brozzoni <danielabrozzoni@protonmail.com>
Thu, 6 Oct 2022 11:22:11 +0000 (12:22 +0100)
Before, failing to create the wallet instance wouldn't report
the error back to the caller, which would usually go on
and call methods on inst, casuing null pointer exceptions.
You can try this by entering the current playground and inserting
a descriptor with a mismatched checksum: the error would be logged
in the console, but a weird error would be presented to the user.

playground/src/index.js

index de18abb3257f5c24f11ef098e972fbb9d182b483..d0d3642b097ac2f7c2f85417b2f63c502e75d21f 100644 (file)
@@ -15,16 +15,12 @@ async function startWallet(desc, change_desc) {
     let historyIndex = 0;
 
     let inst = null;
-    try {
-        let args = ["_", "-d", desc];
-        if (change_desc) {
-            args.push("-c");
-            args.push(change_desc);
-        }
-        inst = await new WasmWallet("testnet", args);
-    } catch (e) {
-        console.error(e);
+    let args = ["_", "-d", desc];
+    if (change_desc) {
+        args.push("-c");
+        args.push(change_desc);
     }
+    inst = await new WasmWallet("testnet", args);
 
     const run = (command) => {
         if (command == "clear") {