ElementsProject / lightning

Core Lightning — Lightning Network implementation focusing on spec compliance and performance
Other
2.83k stars 899 forks source link

`sendpay_success` sometimes not called on plugin? #3232

Closed fiatjaf closed 5 years ago

fiatjaf commented 5 years ago

Issue and Steps to Reproduce

I'm running lightningd with many plugins. One of them, webbook, is getting all notifications correctly.

At the same time I'm developing/testing a new one that should be getting the sendpay_success notification, but isn't. Or maybe I'm crazy.

I know for sure it was getting these notifications all the time when I was fixing bugs somewhere else while testing it on my real node. However, when it was time for me to fix bugs happening at the sendpay_success handler I inserted a bunch of log statements there and couldn't see any logs! The method wasn't being called anymore.

This is out of the scope of this reposutory, but for this new plugin I'm using the same plugin framework webhook uses but I even tried to insert log statements at lower-level handlers like here and couldn't get any sendpay_success logs happening there.

Also, connect notifications seem to be coming in well. Also the same code is being used to handle htlc_accept hook calls and these are always called and handled by the plugin.

For these reasons I started to think there could be an error at the plugin notification dispatching code from lightningd. So I've inserted a log_info statement at https://github.com/ElementsProject/lightning/blob/61383408a45960bf7fd045fc420c95478de699c0/lightningd/plugin.c#L1116 and expected for the worse.

For my surprise, when I recompiled and run again I got the log printed correctly and the notification handler was called at my plugin.

I then removed the log line, recompiled and tried again: again sendpay_success wasn't called at my plugin.

Please disconsider if this is too dumb.

getinfo output

{                                                                                                                     
  "id": "02bed1812d3824f7cc4ccd38da5d66a29fcfec146fe95e26cd2e0d3f930d653a8d",                                         
  "alias": "etleneum.com",                                                                                            
  "color": "c2f1bb",                                                                                                  
  "num_peers": 10,                                                                                                    
  "num_pending_channels": 0,                                                                                          
  "num_active_channels": 9,                                                                                           
  "num_inactive_channels": 0,                                                                                         
  "address": [                                                                                                        
    {                                                                                                                 
      "type": "ipv4",                                                                                                 
      "address": "172.81.178.38",                                                                                     
      "port": 9736                                                                                                    
    }                                                                                                                 
  ],                                                                                                                  
  "binding": [                                                                                                        
    {                                                                                                                 
      "type": "ipv4",                                                                                                 
      "address": "0.0.0.0",                                                                                           
      "port": 9736                                                                                                    
    },                                                                                                                
    {                                                                                                                 
      "type": "ipv6",                                                                                                 
      "address": "::",
      "port": 9735
    }
  ],
  "version": "v0.7.2.1-572-gf657146",
  "blockheight": 601848,
  "network": "bitcoin",
  "msatoshi_fees_collected": 1377,
  "fees_collected_msat": "1377msat"
}
fiatjaf commented 5 years ago

It's being called now all the time. I was probably drunk when I opened this.