Commit c5ebd77
fix: deduplicate multi-wallet BDK events and correct onchain payment direction
When a transaction touches multiple address-type wallets, each wallet
independently emits a BdkWalletEvent, causing duplicate onchain events
per sync cycle. Add per-type HashSet deduplication in process_wallet_events
so each txid produces at most one event of each type per sync.
Also fix PaymentDetails::update to apply direction corrections as secondary
wallets sync. When the primary wallet sees only a change output it records
the payment as Inbound; once secondary wallets reveal the spent inputs the
direction must update to Outbound. Add a never-downgrade guard so a
change-only wallet syncing before an input-holding wallet cannot transiently
flip a correct Outbound back to Inbound.
Add unit tests for the direction logic and integration tests covering event
deduplication, direction correction, send_all direction, secondary wallet
receives, and reorg deduplication.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>1 parent f0b58a3 commit c5ebd77
3 files changed
Lines changed: 381 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
227 | 227 | | |
228 | 228 | | |
229 | 229 | | |
| 230 | + | |
| 231 | + | |
230 | 232 | | |
231 | 233 | | |
232 | 234 | | |
| |||
235 | 237 | | |
236 | 238 | | |
237 | 239 | | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
238 | 247 | | |
239 | 248 | | |
240 | 249 | | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
241 | 253 | | |
242 | 254 | | |
243 | 255 | | |
| |||
270 | 282 | | |
271 | 283 | | |
272 | 284 | | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
273 | 288 | | |
274 | 289 | | |
275 | 290 | | |
| |||
283 | 298 | | |
284 | 299 | | |
285 | 300 | | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
286 | 304 | | |
287 | 305 | | |
288 | 306 | | |
| |||
321 | 339 | | |
322 | 340 | | |
323 | 341 | | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
324 | 345 | | |
325 | 346 | | |
326 | 347 | | |
| |||
336 | 357 | | |
337 | 358 | | |
338 | 359 | | |
339 | | - | |
| 360 | + | |
340 | 361 | | |
341 | 362 | | |
342 | 363 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
293 | 293 | | |
294 | 294 | | |
295 | 295 | | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
296 | 306 | | |
297 | 307 | | |
298 | 308 | | |
| |||
619 | 629 | | |
620 | 630 | | |
621 | 631 | | |
| 632 | + | |
622 | 633 | | |
623 | 634 | | |
624 | 635 | | |
| |||
790 | 801 | | |
791 | 802 | | |
792 | 803 | | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
| 823 | + | |
| 824 | + | |
| 825 | + | |
| 826 | + | |
| 827 | + | |
| 828 | + | |
| 829 | + | |
| 830 | + | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
| 836 | + | |
| 837 | + | |
| 838 | + | |
| 839 | + | |
| 840 | + | |
| 841 | + | |
| 842 | + | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
| 848 | + | |
| 849 | + | |
| 850 | + | |
| 851 | + | |
| 852 | + | |
| 853 | + | |
| 854 | + | |
| 855 | + | |
| 856 | + | |
| 857 | + | |
| 858 | + | |
| 859 | + | |
| 860 | + | |
| 861 | + | |
| 862 | + | |
| 863 | + | |
| 864 | + | |
793 | 865 | | |
0 commit comments