romanz / electrs

An efficient re-implementation of Electrum Server in Rust
MIT License
1.1k stars 407 forks source link

Bug: Addresses affected by descendant transactions are not notified on transaction replacement #1028

Open craigraw opened 7 months ago

craigraw commented 7 months ago

If you watch https://www.youtube.com/watch?v=pWmgu5eA4y4 to 9m 51s, you will see Sparrow reflects an incorrect state of the wallet. This is caused by the lack of all the correct notifications from Electrs - all addresses affected by the replacement of a transaction (removing it from this wallet) are not notified. The addresses that are not notified relate to child transactions that spend the (now removed) output of the replaced transaction.

I've reproduced the scenario using DEBUG logging in Sparrow, which funded address/0/2 in the Alice wallet with the first transaction, and then spent from /0/2 and /1/0 addresses to create the child transaction to the third (Bob) wallet. On broadcasting the RBF transaction from the first (Evil RBFer) wallet, the Alice wallet was notified of changes to /0/1 and /0/2, but not /1/0.

romanz commented 7 months ago

Many thanks for reporting this issue!

romanz commented 7 months ago

I tried to reproduce the issue on Regtest with Sparrow 1.8.5 (built from source), but it seems to fail to start - with the following exception:

$ ./sparrow --network regtest

> Configure project :
Project : => 'com.sparrowwallet.sparrow' Java module

> Task :run FAILED
Exception in Application start method
Exception in Application stop method
2024-04-20 08:43:29,469 ERROR Exception in thread "main"
java.lang.RuntimeException: Exception in Application start method
        at javafx.graphics@18/com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:901)
        at javafx.graphics@18/com.sun.javafx.application.LauncherImpl.lambda$launchApplication$2(LauncherImpl.java:196)
        at java.base/java.lang.Thread.run(Thread.java:1589)
Caused by: java.lang.IllegalArgumentException: No enum constant com.samourai.wallet.constants.SamouraiNetwork.REGTEST
        at java.base/java.lang.Enum.valueOf(Enum.java:274)
        at com.samourai.extlibj@1.0.6/com.samourai.wallet.constants.SamouraiNetwork.valueOf(SamouraiNetwork.java:11)
        at com.sparrowwallet.sparrow@1.8.5/com.sparrowwallet.sparrow.whirlpool.WhirlpoolServices.getSamouraiNetwork(WhirlpoolServices.java:64)
        at com.sparrowwallet.sparrow@1.8.5/com.sparrowwallet.sparrow.whirlpool.WhirlpoolServices.computeExtLibJConfig(WhirlpoolServices.java:59)
        at com.sparrowwallet.sparrow@1.8.5/com.sparrowwallet.sparrow.whirlpool.WhirlpoolServices.<init>(WhirlpoolServices.java:51)
        at com.sparrowwallet.sparrow@1.8.5/com.sparrowwallet.sparrow.AppServices.<init>(AppServices.java:98)
        at com.sparrowwallet.sparrow@1.8.5/com.sparrowwallet.sparrow.AppServices.initialize(AppServices.java:526)
        at com.sparrowwallet.sparrow@1.8.5/com.sparrowwallet.sparrow.SparrowDesktop.start(SparrowDesktop.java:51)
        at javafx.graphics@18/com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(LauncherImpl.java:847)
        at javafx.graphics@18/com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(PlatformImpl.java:484)
        at javafx.graphics@18/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:457)
        at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
        at javafx.graphics@18/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:456)
        at javafx.graphics@18/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
        at javafx.graphics@18/com.sun.glass.ui.gtk.GtkApplication._runLoop(Native Method)
        at javafx.graphics@18/com.sun.glass.ui.gtk.GtkApplication.lambda$runLoop$11(GtkApplication.java:316)
        ... 1 common frames omitted

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':run'.
> Process 'command '/usr/lib/jvm/java-19-openjdk-amd64/bin/java'' finished with non-zero exit value 1

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.

BUILD FAILED in 1s
12 actionable tasks: 2 executed, 10 up-to-date

@craigraw could you please take a look?

romanz commented 7 months ago

I'll try to reproduce on testnet.

craigraw commented 7 months ago

See https://github.com/sparrowwallet/sparrow/issues/1385. You can simply run latest HEAD to avoid this.