Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Channel "AWAITING_UNILATERAL" since days. Attempted force closing, CPU 100% #2171

Closed
gabridome opened this issue Dec 12, 2018 · 28 comments
Closed

Comments

@gabridome
Copy link
Contributor

gabridome commented Dec 12, 2018

I found one of my channel was in "AWAITING_UNILATERAL" so I waited but days after it was still in that state.

Relevant log with grep peerID:

2018-11-25T13:41:40.283Z lightningd(17827): 03e50492eab4107a773141bb419e107bda3de3d55652e6e1a41225f06a0bbf2d56 chan #10: 0: 10648 satoshi (SEGWIT) 695254bb08add33af6f907960913869c25903c967541b2b8765be96431d2cb59?                                                                               [100/260]
2018-11-25T13:41:40.283Z lightningd(17827): 03e50492eab4107a773141bb419e107bda3de3d55652e6e1a41225f06a0bbf2d56 chan #10: 1: 2005802 satoshi (SEGWIT) bd729c73e2cd2647f5ce6a2ebd24419720486f720124d9e0c66649b0b3d2835d?                                                                                      
2018-11-25T13:41:40.283Z lightningd(17827): 03e50492eab4107a773141bb419e107bda3de3d55652e6e1a41225f06a0bbf2d56 chan #10: 2: 252848 satoshi (SEGWIT) bbe3783d4c7fde8eb6433403fc1c34fa0098e4c738cedeac087243a1655a0b81?                                                                                       
2018-11-25T13:41:40.300Z lightningd(17827): 03e50492eab4107a773141bb419e107bda3de3d55652e6e1a41225f06a0bbf2d56 chan #10: Getting HSM to sign funding tx                                                                                                                                                     
2018-11-25T13:41:40.397Z lightningd(17827): lightning_channeld-03e50492eab4107a773141bb419e107bda3de3d55652e6e1a41225f06a0bbf2d56 chan #10: pid 31244, msgfd 33                                                                                                                                             
2018-11-25T13:41:40.397Z lightningd(17827): 03e50492eab4107a773141bb419e107bda3de3d55652e6e1a41225f06a0bbf2d56 chan #10: Waiting for funding confirmations                                                                                                                                                  
2018-11-25T13:41:41.001Z lightningd(17827): 03e50492eab4107a773141bb419e107bda3de3d55652e6e1a41225f06a0bbf2d56 chan #10: Peer internal error CHANNELD_AWAITING_LOCKIN: Funding broadcast exited with 25: error code: -25?error message:?Missing inputs?                                                     
2018-11-25T13:41:41.001Z lightningd(17827): 03e50492eab4107a773141bb419e107bda3de3d55652e6e1a41225f06a0bbf2d56 chan #10: Peer permanent failure in CHANNELD_AWAITING_LOCKIN: Internal error: Funding broadcast exited with 25: error code: -25?error message:?Missing inputs?                               
2018-11-25T13:41:41.001Z lightningd(17827): lightning_channeld-03e50492eab4107a773141bb419e107bda3de3d55652e6e1a41225f06a0bbf2d56 chan #10: Status closed, but not exited. Killing                                                                                                                          
2018-11-25T13:41:41.013Z lightningd(17827): 03e50492eab4107a773141bb419e107bda3de3d55652e6e1a41225f06a0bbf2d56 chan #10: State changed from CHANNELD_AWAITING_LOCKIN to AWAITING_UNILATERAL                                                                                                                 
2018-11-25T13:42:58.779Z lightning_gossipd(17983): Trying to find a route from 03b49e64e9bce0de005d774c3fbe39dcafd9ce96b6c8ffaaf3a1e111d4f9554e2e to 03e50492eab4107a773141bb419e107bda3de3d55652e6e1a41225f06a0bbf2d56 for 150096 msatoshi                                                                 
2018-11-25T13:42:58.779Z lightningd(17827): pay(0x5599e8874d28): sendpay via route: us -> 551183:2675:1 (151109msat, 590blk) -> 036ac04a69f2ab587fd83c4f2aca255a81f138276fbca344ac3ecfae28d733be56 -> 532217:2079:0 (150109msat, 446blk) -> 02529db69fd2ebd3126fb66fafa234fc3544477a23d509fe93ed229bb0e92e4f
b8 -> 548838:1988:1 (150098msat, 302blk) -> 031d2bbc75802689312220a017c6b51fa246efc59c7aa9355f6f7395038ffb4d6a -> 549057:2281:0 (150097msat, 158blk) -> 02c5371591b640da03f9a645e2ddfa5620d8537388b03ddd524d36766c0f550db0 -> 548930:191:0 (150096msat, 144blk) -> 03e50492eab4107a773141bb419e107bda3de3d55
652e6e1a41225f06a0bbf2d56                                                                                                                                                                                                                  
2018-11-25T13:43:04.954Z lightning_gossipd(17983): Trying to find a route from 03b49e64e9bce0de005d774c3fbe39dcafd9ce96b6c8ffaaf3a1e111d4f9554e2e to 03e50492eab4107a773141bb419e107bda3de3d55652e6e1a41225f06a0bbf2d56 for 150218 msatoshi                                                                 
2018-11-25T13:43:04.955Z lightningd(17827): pay(0x5599e8874d28): sendpay via route: us -> 551183:2675:1 (152234msat, 446blk) -> 036ac04a69f2ab587fd83c4f2aca255a81f138276fbca344ac3ecfae28d733be56 -> 550459:2332:1 (151234msat, 302blk) -> 0390b5d4492dc2f5318e5233ab2cebf6d48914881a33ef6a9c6bcdbb433ad986
d0 -> 550102:1165:0 (150219msat, 158blk) -> 02c5371591b640da03f9a645e2ddfa5620d8537388b03ddd524d36766c0f550db0 -> 548930:191:0 (150218msat, 144blk) -> 03e50492eab4107a773141bb419e107bda3de3d55652e6e1a41225f06a0bbf2d56                                                                                   
2018-11-25T13:43:11.852Z lightning_gossipd(17983): Trying to find a route from 03b49e64e9bce0de005d774c3fbe39dcafd9ce96b6c8ffaaf3a1e111d4f9554e2e to 03e50492eab4107a773141bb419e107bda3de3d55652e6e1a41225f06a0bbf2d56 for 150170 msatoshi
2018-11-25T13:43:11.852Z lightningd(17827): pay(0x5599e8874d28): sendpay via route: us -> 551183:2675:1 (152271msat, 864blk) -> 036ac04a69f2ab587fd83c4f2aca255a81f138276fbca344ac3ecfae28d733be56 -> 544611:1240:1 (151271msat, 720blk) -> 020e56a13babec99abdc2c4afbe34e1e44230d79b234c059fd4ff1e367765fdb
1b -> 541282:1481:0 (150271msat, 576blk) -> 03434a39cd9a537c852fc8fb72454086d726f9111e9f730cef4985c39c11fae944 -> 535271:1925:0 (150171msat, 432blk) -> 03bb88ccc444534da7b5b64b4f7b15e1eccb18e102db0e400d4b9cfe93763aa26d -> 549187:1932:1 (150170msat, 288blk) -> 03295d2e292565743a40bd44da227a820f873087
7bc3dfadebade8785bcf355258 -> 544098:2501:1 (150170msat, 144blk) -> 03e50492eab4107a773141bb419e107bda3de3d55652e6e1a41225f06a0bbf2d56                                   
2018-11-25T13:43:18.520Z lightning_gossipd(17983): Trying to find a route from 03b49e64e9bce0de005d774c3fbe39dcafd9ce96b6c8ffaaf3a1e111d4f9554e2e to 03e50492eab4107a773141bb419e107bda3de3d55652e6e1a41225f06a0bbf2d56 for 150426 msatoshi
2018-11-25T13:43:18.520Z lightningd(17827): pay(0x5599e8874d28): sendpay via route: us -> 551183:2675:1 (152615msat, 474blk) -> 036ac04a69f2ab587fd83c4f2aca255a81f138276fbca344ac3ecfae28d733be56 -> 550180:1827:0 (151615msat, 330blk) -> 03a5927b64b1ea8657d5b770d61a3e2d0554fdb5d568773e0d6a92907913ca21
f6 -> 551184:469:0 (150628msat, 186blk) -> 0217090c397c3e8ced66abb7b8bf6e05cd49adde55766a7d14e2e4a541164b0935 -> 551318:1032:0 (150428msat, 172blk) -> 03f18da23535adee245903c81750745197e3079d3b88b3898981c90a5f2411008c -> 544620:1321:1 (150427msat, 158blk) -> 02c88a0df5e9ea7df582647f79b70b8e441047de3
08fd6b24408b8bd775f2234bd -> 549696:815:1 (150426msat, 144blk) -> 03e50492eab4107a773141bb419e107bda3de3d55652e6e1a41225f06a0bbf2d56 

Today I have tried to force close the channel but the command is stucked and the CPU is 100%.

lightning-cli close 03e50492eab4107a773141bb419e107bda3de3d55652e6e1a41225f06a0bbf2d56 true

I have interrupted the command but it seems like every command (getinfo included) is causing 100% CPU and the freezing of the command itself.

Restarting the service, I was able to collect some more infos:

$ lightning-cli listpeers 03e50492eab4107a773141bb419e107bda3de3d55652e6e1a41225f06a0bbf2d56 debug
{
  "peers": [
    {
      "id": "03e50492eab4107a773141bb419e107bda3de3d55652e6e1a41225f06a0bbf2d56",
      "connected": true,
      "netaddr": [
        "35.172.33.197:9735"
      ],
      "global_features": "",
      "local_features": "82",
      "globalfeatures": "",
      "localfeatures": "82",
      "channels": [
        {
          "state": "AWAITING_UNILATERAL",
          "scratch_txid": "458cd396b558361c2a616d0e2a0c56a50f5c8eacd9ca71e536d016bf3ae6233d",
          "channel_id": "84649e5d4c01a17a4f1612c722df7be59e31cdf39f969a8794d2adcd54b1b731",
          "funding_txid": "31b7b154cdadd294879a969ff3cd319ee57bdf22c712164f7aa1014c5d9e6484",
          "msatoshi_to_us": 1000000000,
          "msatoshi_to_us_min": 1000000000,
          "msatoshi_to_us_max": 1000000000,
          "msatoshi_total": 1000000000,
          "dust_limit_satoshis": 546,
          "max_htlc_value_in_flight_msat": 18446744073709551615,
          "their_channel_reserve_satoshis": 10000,
          "our_channel_reserve_satoshis": 10000,
          "spendable_msatoshi": 990000000,
          "htlc_minimum_msat": 0,
          "their_to_self_delay": 144,
          "our_to_self_delay": 144,
          "max_accepted_htlcs": 483,
          "status": [
            "AWAITING_UNILATERAL:Attempting to reconnect"
          ],
          "in_payments_offered": 0,
          "in_msatoshi_offered": 0,
          "in_payments_fulfilled": 0,
          "in_msatoshi_fulfilled": 0,
          "out_payments_offered": 0,
          "out_msatoshi_offered": 0,
          "out_payments_fulfilled": 0,
          "out_msatoshi_fulfilled": 0,
          "htlcs": [
          ]
        }
      ],
      "log": [
        {
          "type": "DEBUG",
          "time": "5.221303026",
          "source": "03e50492eab4107a773141bb419e107bda3de3d55652e6e1a41225f06a0bbf2d56 chan #10:",
          "log": "Peer has reconnected, state AWAITING_UNILATERAL"
        },
        {
          "type": "DEBUG",
          "time": "5.225104641",
          "source": "lightning_openingd-03e50492eab4107a773141bb419e107bda3de3d55652e6e1a41225f06a0bbf2d56 chan #11:",
          "log": "pid 15044, msgfd 25"
        },
        {
          "type": "DEBUG",
          "time": "5.293310285",
          "source": "lightning_openingd-03e50492eab4107a773141bb419e107bda3de3d55652e6e1a41225f06a0bbf2d56 chan #11:",
          "log": "peer_out WIRE_ERROR"
        },
        {
          "type": "DEBUG",
          "time": "5.294715801",
          "source": "lightning_openingd-03e50492eab4107a773141bb419e107bda3de3d55652e6e1a41225f06a0bbf2d56 chan #11:",
          "log": "Handed peer, entering loop"
        }
      ]
    }
  ]
}

getinfo output

not possible (due to 100%CPU issue) but running tags/v0.6.2

EDIT: restarting the service:

lightning-cli getinfo
{
  "id": "03b49e64e9bce0de005d774c3fbe39dcafd9ce96b6c8ffaaf3a1e111d4f9554e2e",
  "address": [
    {
      "type": "torv2",
      "address": "byy4lqhaaley7e7k.onion",
      "port": 9735
    }
  ],
  "binding": [
    {
      "type": "ipv4",
      "address": "127.0.0.1",
      "port": 9731
    },
    {
      "type": "ipv4",
      "address": "10.2.206.180",
      "port": 9731
    }
  ],
  "version": "v0.6.2-modded",
  "blockheight": 553513,
  "network": "bitcoin",
  "msatoshi_fees_collected": 0
}
@SimonVrouwe
Copy link
Collaborator

The funding tx 31b7b154cdadd294879a969ff3cd319ee57bdf22c712164f7aa1014c5d9e6484 never got broadcasted, not sure why, do you perhaps have the raw tx somewhere in the logfile (grep on txid) to check its inputs?

2018-11-25T13:41:41.001Z lightningd(17827): 03e50492eab4107a773141bb419e107bda3de3d55652e6e1a41225f06a0bbf2d56 chan #10: Peer internal error CHANNELD_AWAITING_LOCKIN: Funding broadcast exited with 25: error code: -25?error message:?Missing inputs?                                                     
2018-11-25T13:41:41.001Z lightningd(17827): 03e50492eab4107a773141bb419e107bda3de3d55652e6e1a41225f06a0bbf2d56 chan #10: Peer permanent failure in CHANNELD_AWAITING_LOCKIN: Internal error: Funding broadcast exited with 25: error code: -25?error message:?Missing inputs?                               
2018-11-25T13:41:41.001Z lightningd(17827): lightning_channeld-03e50492eab4107a773141bb419e107bda3de3d55652e6e1a41225f06a0bbf2d56 chan #10: Status closed, but not exited. Killing                                                                                                                          
2018-11-25T13:41:41.013Z lightningd(17827): 03e50492eab4107a773141bb419e107bda3de3d55652e6e1a41225f06a0bbf2d56 chan #10: State changed from CHANNELD_AWAITING_LOCKIN to AWAITING_UNILATERAL 

@gabridome
Copy link
Contributor Author

Yeah. Exactly. I will look into the log files and report.

@gabridome
Copy link
Contributor Author

These are some lines of the log in which also appears the opening tx with some error.

2018-11-25T13:40:24.152Z lightning_connectd(17963): Connected out for 03e50492eab4107a773141bb419e107bda3de3d55652e6e1a41225f06a0bbf2d56
2018-11-25T13:40:24.307Z lightning_hsmd(17953): Client: Received message 1 from client
2018-11-25T13:40:24.354Z lightning_connectd(17963): Connect OUT to 03e50492eab4107a773141bb419e107bda3de3d55652e6e1a41225f06a0bbf2d56
2018-11-25T13:40:24.354Z lightning_connectd(17963): peer_out WIRE_INIT
2018-11-25T13:40:24.415Z lightning_connectd(17963): peer_in WIRE_INIT
2018-11-25T13:40:24.415Z lightning_connectd(17963): UPDATE WIRE_CONNECT_PEER_CONNECTED
2018-11-25T13:40:24.415Z lightning_connectd(17963): UPDATE WIRE_CONNECT_PEER_CONNECTED
2018-11-25T13:40:24.440Z lightningd(17827): lightning_openingd-03e50492eab4107a773141bb419e107bda3de3d55652e6e1a41225f06a0bbf2d56 chan #9: pid 27843, msgfd 28
2018-11-25T13:40:24.441Z lightning_hsmd(17953): Client: Received message 10 from client
2018-11-25T13:40:24.441Z lightning_hsmd(17953): Client: Received message 9 from client
2018-11-25T13:40:24.442Z lightning_hsmd(17953): new_client: 9
2018-11-25T13:40:24.543Z lightning_hsmd(17953): Client: Received message 18 from client
2018-11-25T13:40:24.544Z lightningd(17827): lightning_openingd-03e50492eab4107a773141bb419e107bda3de3d55652e6e1a41225f06a0bbf2d56 chan #9: Handed peer, entering loop
...
2018-11-25T13:40:36.473Z lightningd(17827): lightning_openingd-03e50492eab4107a773141bb419e107bda3de3d55652e6e1a41225f06a0bbf2d56 chan #9: peer_out WIRE_OPEN_CHANNEL
2018-11-25T13:40:36.584Z lightningd(17827): lightning_openingd-03e50492eab4107a773141bb419e107bda3de3d55652e6e1a41225f06a0bbf2d56 chan #9: peer_in WIRE_ERROR
2018-11-25T13:40:36.584Z lightningd(17827): lightning_openingd-03e50492eab4107a773141bb419e107bda3de3d55652e6e1a41225f06a0bbf2d56 chan #9: UPDATE WIRE_OPENING_FUNDER_FAILED
2018-11-25T13:40:36.835Z lightningd(17827): lightning_openingd-03e50492eab4107a773141bb419e107bda3de3d55652e6e1a41225f06a0bbf2d56 chan #9: aborted opening negotiaion: They sent error channel f8ada37a036b74ca2142e0ddd46b04b9e71642c563a78727ae5209ffcd1f0fb0: chan size of 0.005 BTC is below min chan size of 0.01 BTC
2018-11-25T13:40:36.835Z lightningd(17827): lightning_openingd-03e50492eab4107a773141bb419e107bda3de3d55652e6e1a41225f06a0bbf2d56 chan #9: UPDATE WIRE_OPENING_FUNDER_FAILED
2018-11-25T13:40:36.835Z lightningd(17827): lightning_openingd-03e50492eab4107a773141bb419e107bda3de3d55652e6e1a41225f06a0bbf2d56 chan #9: Unexpected FUNDER_FAILED 1774546865792073656e74206572726f72206368616e6e656c20663861646133376130333662373463613231343265306464643436623034623965373136343263353633613738373237616535323039666663643166306662303a206368616e2073697a65206f6620302e303035204254432069732062656c6f77206d696e206368616e2073697a65206f6620302e30312042544300
2018-11-25T13:40:36.835Z lightningd(17827): lightning_openingd-03e50492eab4107a773141bb419e107bda3de3d55652e6e1a41225f06a0bbf2d56 chan #9: Status closed, but not exited. Killing
2018-11-25T13:40:36.836Z lightningd(17827): 03e50492eab4107a773141bb419e107bda3de3d55652e6e1a41225f06a0bbf2d56 chan #9: Owning subdaemon lightning_openingd died (9)
2018-11-25T13:41:33.485Z lightning_connectd(17963): Connected out for 03e50492eab4107a773141bb419e107bda3de3d55652e6e1a41225f06a0bbf2d56
2018-11-25T13:41:33.593Z lightning_hsmd(17953): Client: Received message 1 from client
2018-11-25T13:41:33.593Z lightning_connectd(17963): Connect OUT to 03e50492eab4107a773141bb419e107bda3de3d55652e6e1a41225f06a0bbf2d56
2018-11-25T13:41:33.593Z lightning_connectd(17963): peer_out WIRE_INIT
2018-11-25T13:41:33.701Z lightning_connectd(17963): peer_in WIRE_INIT
2018-11-25T13:41:33.701Z lightning_connectd(17963): UPDATE WIRE_CONNECT_PEER_CONNECTED
2018-11-25T13:41:33.701Z lightning_connectd(17963): UPDATE WIRE_CONNECT_PEER_CONNECTED
2018-11-25T13:41:33.707Z lightningd(17827): lightning_openingd-03e50492eab4107a773141bb419e107bda3de3d55652e6e1a41225f06a0bbf2d56 chan #10: pid 30932, msgfd 28
2018-11-25T13:41:33.708Z lightning_hsmd(17953): Client: Received message 10 from client
2018-11-25T13:41:33.708Z lightning_hsmd(17953): Client: Received message 9 from client
2018-11-25T13:41:33.708Z lightning_hsmd(17953): new_client: 10
2018-11-25T13:41:33.778Z lightning_hsmd(17953): Client: Received message 18 from client
2018-11-25T13:41:33.778Z lightningd(17827): lightning_openingd-03e50492eab4107a773141bb419e107bda3de3d55652e6e1a41225f06a0bbf2d56 chan #10: Handed peer, entering loop
...
2018-11-25T13:41:37.079Z lightningd(17827): lightning_openingd-03e50492eab4107a773141bb419e107bda3de3d55652e6e1a41225f06a0bbf2d56 chan #10: peer_out WIRE_OPEN_CHANNEL
...
2018-11-25T13:41:40.100Z lightningd(17827): lightning_openingd-03e50492eab4107a773141bb419e107bda3de3d55652e6e1a41225f06a0bbf2d56 chan #10: peer_in WIRE_ACCEPT_CHANNEL
2018-11-25T13:41:40.106Z lightning_hsmd(17953): Client: Received message 19 from client
2018-11-25T13:41:40.106Z lightningd(17827): lightning_openingd-03e50492eab4107a773141bb419e107bda3de3d55652e6e1a41225f06a0bbf2d56 chan #10: signature 3045022100a64caac5165dded5dbc1f399e577890fa73be9588ae952fd332c2cc8a86b0fe202206b01a293b5815492e950c0a21766d451154c8dfd60916a40d66f6aa0cdb8f55b on tx 020000000184649e5d4c01a17a4f1612c722df7be59e31cdf39f969a8794d2adcd54b1b73100000000006634fd800109340f00000000001600145a6ff5a765192ff243a9564545c6da6c2b9740141c4b8c20 using key 03b53566ed0cf217575c53a3613c79b619f533214671cb302c248771ca973e1a9f
2018-11-25T13:41:40.107Z lightningd(17827): lightning_openingd-03e50492eab4107a773141bb419e107bda3de3d55652e6e1a41225f06a0bbf2d56 chan #10: peer_out WIRE_FUNDING_CREATED
2018-11-25T13:41:40.220Z lightningd(17827): lightning_openingd-03e50492eab4107a773141bb419e107bda3de3d55652e6e1a41225f06a0bbf2d56 chan #10: peer_in WIRE_FUNDING_SIGNED
2018-11-25T13:41:40.225Z lightningd(17827): lightning_openingd-03e50492eab4107a773141bb419e107bda3de3d55652e6e1a41225f06a0bbf2d56 chan #10: UPDATE WIRE_OPENING_FUNDER_REPLY
2018-11-25T13:41:40.225Z lightningd(17827): lightning_openingd-03e50492eab4107a773141bb419e107bda3de3d55652e6e1a41225f06a0bbf2d56 chan #10: UPDATE WIRE_OPENING_FUNDER_REPLY
2018-11-25T13:41:40.226Z lightningd(17827): 02681f2ac1d70b2dac7e4092d0a13315a3f2c7b4396fd4d7dae2b014c418b04912
2018-11-25T13:41:40.283Z lightningd(17827): 03e50492eab4107a773141bb419e107bda3de3d55652e6e1a41225f06a0bbf2d56 chan #10: Funding tx has 3 inputs, 2 outputs:
2018-11-25T13:41:40.283Z lightningd(17827): 03e50492eab4107a773141bb419e107bda3de3d55652e6e1a41225f06a0bbf2d56 chan #10: 0: 10648 satoshi (SEGWIT) 695254bb08add33af6f907960913869c25903c967541b2b8765be96431d2cb59?
2018-11-25T13:41:40.283Z lightningd(17827): 03e50492eab4107a773141bb419e107bda3de3d55652e6e1a41225f06a0bbf2d56 chan #10: 1: 2005802 satoshi (SEGWIT) bd729c73e2cd2647f5ce6a2ebd24419720486f720124d9e0c66649b0b3d2835d?
2018-11-25T13:41:40.283Z lightningd(17827): 03e50492eab4107a773141bb419e107bda3de3d55652e6e1a41225f06a0bbf2d56 chan #10: 2: 252848 satoshi (SEGWIT) bbe3783d4c7fde8eb6433403fc1c34fa0098e4c738cedeac087243a1655a0b81?
2018-11-25T13:41:40.300Z lightningd(17827): 03e50492eab4107a773141bb419e107bda3de3d55652e6e1a41225f06a0bbf2d56 chan #10: Getting HSM to sign funding tx
2018-11-25T13:41:40.383Z lightningd(17827): Owning output 1 1263492 (SEGWIT) txid 31b7b154cdadd294879a969ff3cd319ee57bdf22c712164f7aa1014c5d9e6484
2018-11-25T13:41:40.383Z lightningd(17827): 	 (tx 31b7b154cdadd294879a969ff3cd319ee57bdf22c712164f7aa1014c5d9e6484)
2018-11-25T13:41:40.384Z lightningd(17827): sendrawtransaction: 0200000000010359cbd23164e95b76b8b24175963c90259c8613099607f9f63ad3ad08bb5452690000000000ffffffff5d83d2b3b04966c6e0d92401726f4820974124bd2e6acef54726cde2739c72bd0100000000ffffffff810b5a65a1437208acdece38c7e49800fa341cfc033443b68ede7f4c3d78e3bb0100000000ffffffff0240420f00000000002200204238a90686f895419ba0e06c92bb98d4b8e05c2367c9c0b5cd782350264930358447130000000000160014fd4d9475bf001a617ba5d2f043ef8f7f07f8aabd02483045022100fb216e85efcfed190454e396a7a313a7cae901621dc1000692bca612935db43102202b3ed0b849d92134d1bcdac1ac39a48dbc448856e253fefba48f58e8012d78bc0121026ab13371ae3f4dc57b75da60768241594fb22c932bd49ab8357c91fa1a38a69902483045022100b044ec8f3fbf07371fef1c2e5b5c8291ca6c36bf94cfa2ef6b55cdb5619bd3a40220758d13faeaa7c5f40a61f02e504f30f19eece0f8359dd0e131bcefe885393f410121031057172c7552e90746f26e215f84326950a53c8656b8d9a72f1837f37aadbdcf02483045022100bb899a7aa42ac1ebf78b7246fbf97ecc9bcecc10e34aeef5af9637cec5f78ec00220762f6949ca9d3f240670c4a1be1632ab5ecfe2f43b87175f3e0ef74e38efd87f012102a85510a09391b9f07c50233040b8979695266955223790dca2cbc3041db1af4d00000000
2018-11-25T13:41:40.397Z lightningd(17827): lightning_channeld-03e50492eab4107a773141bb419e107bda3de3d55652e6e1a41225f06a0bbf2d56 chan #10: pid 31244, msgfd 33
2018-11-25T13:41:40.397Z lightningd(17827): 03e50492eab4107a773141bb419e107bda3de3d55652e6e1a41225f06a0bbf2d56 chan #10: Waiting for funding confirmations
2018-11-25T13:41:41.001Z lightning_hsmd(17953): Client: Received message 4 from client
2018-11-25T13:41:41.001Z lightningd(17827): sendrawtx exit 25, gave error code: -25?error message:?Missing inputs?
2018-11-25T13:41:41.001Z lightningd(17827): 03e50492eab4107a773141bb419e107bda3de3d55652e6e1a41225f06a0bbf2d56 chan #10: Peer internal error CHANNELD_AWAITING_LOCKIN: Funding broadcast exited with 25: error code: -25?error message:?Missing inputs?
2018-11-25T13:41:41.001Z lightningd(17827): 03e50492eab4107a773141bb419e107bda3de3d55652e6e1a41225f06a0bbf2d56 chan #10: Peer permanent failure in CHANNELD_AWAITING_LOCKIN: Internal error: Funding broadcast exited with 25: error code: -25?error message:?Missing inputs?
2018-11-25T13:41:41.001Z lightningd(17827): lightning_channeld-03e50492eab4107a773141bb419e107bda3de3d55652e6e1a41225f06a0bbf2d56 chan #10: Status closed, but not exited. Killing
2018-11-25T13:41:41.001Z lightningd(17827): 	 (tx 458cd396b558361c2a616d0e2a0c56a50f5c8eacd9ca71e536d016bf3ae6233d)
2018-11-25T13:41:41.004Z lightningd(17827): sendrawtransaction: 0200000000010184649e5d4c01a17a4f1612c722df7be59e31cdf39f969a8794d2adcd54b1b73100000000006634fd800109340f00000000002200201e63c6e9637505f940b2a5e39c4c308ec8ba1f4f28199a63862ed37e7e5233ba040048304502210088fd46fc30c58cc8dd514a14cf91f49c82ef119c6f0dbd10d6487dd00126090902200fedecca629a8a28a4c903266cccf77f94510e80e595f8f2a388d56d097ca54501483045022100b4f18b388328ca04284a5589128d4c23ba83de975c168d2f1925bdf827ab84be0220647a3917355adaf5c6679c1510d7a5be7b0f3ff1c72a3df67e82328ca08ec37e0147522102288bb6bfaa2994da79e7ca38326cb0f3a03bb7287e3cdc6f709c332ea2e5bb222103b53566ed0cf217575c53a3613c79b619f533214671cb302c248771ca973e1a9f52ae1c4b8c20
2018-11-25T13:41:41.013Z lightningd(17827): 03e50492eab4107a773141bb419e107bda3de3d55652e6e1a41225f06a0bbf2d56 chan #10: State changed from CHANNELD_AWAITING_LOCKIN to AWAITING_UNILATERAL
2018-11-25T13:41:41.404Z lightning_hsmd(17953): Client: Received message 9 from client
2018-11-25T13:41:41.404Z lightningd(17827): sendrawtx exit 25, gave error code: -25?error message:?Missing inputs?
2018-11-25T13:41:41.404Z lightning_hsmd(17953): new_client: 10
2018-11-25T13:41:41.405Z lightning_hsmd(17953): Client: Received message 5 from client
2018-11-25T13:41:52.858Z lightning_gossipd(17983): Received channel_update for channel 529283:198:1(1) now ACTIVE was DISABLED (from subdaemon)
2018-11-25T13:42:05.206Z lightningd(17827): ... feerate estimate for slow hit floor 253
20

@SimonVrouwe
Copy link
Collaborator

The 2nd input (txid bd729c73e2cd2647f5ce6a2ebd24419720486f720124d9e0c66649b0b3d2835d) of the funding tx is missing, i.e. it doesn't exist on the blockchain at all ... that is weird.

2018-11-25T13:41:40.283Z lightningd(17827): 03e50492eab4107a773141bb419e107bda3de3d55652e6e1a41225f06a0bbf2d56 chan #10: Funding tx has 3 inputs, 2 outputs:
2018-11-25T13:41:40.283Z lightningd(17827): 03e50492eab4107a773141bb419e107bda3de3d55652e6e1a41225f06a0bbf2d56 chan #10: 0: 10648 satoshi (SEGWIT) 695254bb08add33af6f907960913869c25903c967541b2b8765be96431d2cb59?
2018-11-25T13:41:40.283Z lightningd(17827): 03e50492eab4107a773141bb419e107bda3de3d55652e6e1a41225f06a0bbf2d56 chan #10: 1: 2005802 satoshi (SEGWIT) bd729c73e2cd2647f5ce6a2ebd24419720486f720124d9e0c66649b0b3d2835d?
2018-11-25T13:41:40.283Z lightningd(17827): 03e50492eab4107a773141bb419e107bda3de3d55652e6e1a41225f06a0bbf2d56 chan #10: 2: 252848 satoshi (SEGWIT) bbe3783d4c7fde8eb6433403fc1c34fa0098e4c738cedeac087243a1655a0b81?

The software version says it has been modified, anything related to the wallet or coin selection perhaps?
"version": "v0.6.2-modded"

@gabridome
Copy link
Contributor Author

mmh. Honestly I don't know.
What I normally do is:

  1. to look for a stable version (in this case v0.6.2)
  2. git checkout -b v0.6.2 tags/v0.6.2
  3. make clean
  4. sudo make install

These steps could lead to a modded version?

Months ago I built a version to use dev-forget-channel #1996 and was v0.6.1-modded
(I don't know why that was "modded" either).

This is the last line of git log;

commit 608b1a236b19564765355790667c9843c19d84a9 (HEAD -> v0.6.2, tag: v0.6.2)
Author: Rusty Russell <[email protected]>
Date:   Fri Oct 26 11:26:21 2018 +1030

    CHANGELOG.md: v0.6.2
    
    Signed-off-by: Rusty Russell <[email protected]>

@SimonVrouwe
Copy link
Collaborator

SimonVrouwe commented Dec 20, 2018

Admittedly I am not an git expert, but git status shows which files are modified. Also using make distclean cleans more thoroughly and running ./configure again may also help.

If you have sqlite3 available, maybe you can try folowing command in a terminal in your ./lightning directory:

sqlite3 -header -line lightningd.sqlite3 'SELECT * FROM outputs WHERE hex(prev_out_tx)="BD729C73E2CD2647F5CE6A2EBD24419720486F720124D9E0C66649B0B3D2835D"'

EDIT: Best to shut down c-lightning before query the db, or make a copy of lightningd.sqlite3 and work on that.

To see what the database says about any outputs from that txid, its status should be any of these:

	output_state_available= 0,
	output_state_reserved = 1,
	output_state_spent = 2,

@gabridome
Copy link
Contributor Author

$ sqlite3 -header -line lightningd.sqlite3 'SELECT * FROM outputs WHERE hex(prev_out_tx)="BD729C73E2CD2647F5CE6A2EBD24419720486F720124D9E0C66649B0B3D2835D"'
Error: no such table: outputs

@mmvphil
Copy link

mmvphil commented Dec 25, 2018

I have similar issues awaiting forever.. looks like i lost a couple hundred usd on my LN node.. server was down for 8 days when i got it repaired and put it up.. i cant close channels. and have no outputs :(

@gabridome
Copy link
Contributor Author

gabridome commented Dec 25, 2018

Also:

sqlite> .database
main: /home/bitcoin/lightningd.sqlite3
sqlite> .tables
sqlite> 

Sorry to be a noob about sqlite3 but it seems like I can't see the database.
The file is 12M and I assume is not empty.

@SimonVrouwe
Copy link
Collaborator

SimonVrouwe commented Dec 27, 2018

Hmmm ... strange, are you sure you opened the correct database file? The default location is .lightning/lightningd.sqlite3 in your home directory (or use lightning-cli listconfig to show the "lightning-dir" entry).

EDIT: txid's in the database are stored in internal-byte-order (not RPC-byte-order as shown by bitcoin-cli and lightning-cli etc.), so had to reverse that ... sorry

Then from within that directory try:

sqlite3 -header -line lightningd.sqlite3 'SELECT * FROM outputs WHERE hex(prev_out_tx)="5D83D2B3B04966C6E0D92401726F4820974124BD2E6ACEF54726CDE2739C72BD"'

if that still doesn't show anything, then the other (#0) input of the funding-tx should definitely show up:

sqlite3 -header -line lightningd.sqlite3 'SELECT * FROM outputs WHERE hex(prev_out_tx)="59CBD23164E95B76B8B24175963C90259C8613099607F9F63AD3AD08BB545269"'

Note that the txid's in the query need to be all uppercase, at least on my system.

@gabridome
Copy link
Contributor Author

$ lightning-cli listconfigs

{...

  "lightning-dir": "/home/bitcoin/.lightning",

...

}

cd .lightning



:~/.lightning$ sqlite3 -header -line lightningd.sqlite3 'SELECT * FROM outputs WHERE hex(prev_out_tx)="BD729C

73E2CD2647F5CE6A2EBD24419720486F720124D9E0C66649B0B3D2835D"'

:~/.lightning$ sqlite3 -header -line lightningd.sqlite3 'SELECT * FROM outputs WHERE hex(prev_out_tx)="695254BB08ADD33AF6F907960913869C25903C967541B2B8765BE96431D2CB59"'

:~/.lightning$ 

@SimonVrouwe
Copy link
Collaborator

Sorry if it wasn't clear in my previous post, but the byte-order of the txid's in the SQL query need to be reversed, for example BD729C73E2CD2647F5CE6A2EBD24419720486F720124D9E0C66649B0B3D2835D then becomes
5D83D2B3B04966C6E0D92401726F4820974124BD2E6ACEF54726CDE2739C72BD

My previous post shows the correct command.

@gabridome
Copy link
Contributor Author

gabridome commented Dec 28, 2018

Bingo!

sqlite3 -header -line lightningd.sqlite3 'SELECT * FROM outputs WHERE hex(prev_out_tx)="5D83D2B3B04966C6E0D92401726F4820974124BD2E6ACEF54726CDE2739C72BD"'
        prev_out_tx = ]?ҳ?If???$roH ?A$?.j??G&??s?r?
     prev_out_index = 1
              value = 2005802
               type = 5
             status = 2
           keyindex = 15
         channel_id = 
            peer_id = 
   commitment_point = 
confirmation_height = 
       spend_height = 

$ sqlite3 -header -line lightningd.sqlite3 'SELECT * FROM outputs WHERE hex(prev_out_tx)="59CBD23164E95B76B8B24175963C90259C8613099607F9F63AD3AD08BB545269"'
        prev_out_tx = Y??1d?[v??Au?<?%??	???:?TRi
     prev_out_index = 0
              value = 10648
               type = 5
             status = 2
           keyindex = 5
         channel_id = 
            peer_id = 
   commitment_point = 
confirmation_height = 540020
       spend_height = 

@SimonVrouwe
Copy link
Collaborator

Thank you for reporting this.

Clearly the database does not reflect the reality of the blockchain, i.e. both outputs have status = 2 which indicates they are spent, but one of them (txid bd729c73e2cd2647f5ce6a2ebd24419720486f720124d9e0c66649b0b3d2835d) doesn't even exist on the blockchain and the other (txid 695254bb08add33af6f907960913869c25903c967541b2b8765be96431d2cb59 0) is actually unspent.

I have no idea how that happened, but if your clightning source directory is still in the same state as during build, could you try there a git status and git diff to see what file changes caused your version to show as "version": "v0.6.2-modded"?

I am a bit hesitant to recommend a dev-rescan-outputs, perhaps @cdecker or @ZmnSCPxj can advice?

@gabridome
Copy link
Contributor Author

OTOH if you guys think it doesn't worth to investigate further due to the "modded" nature of my tree
(I have no idea why I'm in a modded version) I could forget the transactions.

@SimonVrouwe
Copy link
Collaborator

SimonVrouwe commented Dec 30, 2018

I just learned that status field in the db actually reflects the wallet's internal state, the fields confirmation_height and spend_height reflect the state of the blockchain, so the db makes sense.

However unconfirmed change_outputs from a funding tx can be selected as inputs for the next funding tx (for a new channel). This works fine as long as the first funding tx is broadcasted (accepted in mempool), but if for some reason the first funding tx was not broadcasted (maybe due to bitcoind failure or crash?) then it won't work. I think that is what may have happened.

So somewhere up the chain of our outputs, a funding tx was not properly broadcasted. It would be interesting to find out why, so maybe a:

grep 'bd729c73e2cd2647f5ce6a2ebd24419720486f720124d9e0c66649b0b3d2835d'

in the logfile to find the corresponding channel_id that created that tx and subsequent grep <channel_id> can tell us more why it failed broadcasting that tx.

Please don't broadcast or post the original failed tx before we know more why it failed.

@SimonVrouwe
Copy link
Collaborator

Likely cause of the -modded version name is that, when doing git checkout <branch>, the submodules in directory external/ are not automatically checked out at the right commit.
As a result, git status then shows something like:

modified:   external/libwally-core (new commits)

Instead, use git checkout --recurse-submodules <branch>

@gabridome
Copy link
Contributor Author

So somewhere up the chain of our outputs, a funding tx was not properly broadcasted. It would be interesting to find out why, so maybe a:

grep 'bd729c73e2cd2647f5ce6a2ebd24419720486f720124d9e0c66649b0b3d2835d'
in the logfile to find the corresponding channel_id that created that tx and subsequent grep <channel_id> can tell us more why it failed broadcasting that tx.

$ grep -C 10 'bd729c73e2cd2647f5ce6a2ebd24419720486f720124d9e0c66649b0b3d2835d' .lightning/lightning.log
2018-11-25T13:41:40.100Z lightningd(17827): lightning_openingd-03e50492eab4107a773141bb419e107bda3de3d55652e6e1a41225f06a0bbf2d56 chan #10: peer_in WIRE_ACCEPT_CHANNEL
2018-11-25T13:41:40.106Z lightning_hsmd(17953): Client: Received message 19 from client
2018-11-25T13:41:40.106Z lightningd(17827): lightning_openingd-03e50492eab4107a773141bb419e107bda3de3d55652e6e1a41225f06a0bbf2d56 chan #10: signature 3045022100a64caac5165dded5dbc1f399e577890fa73be9588ae952fd332c2cc8a86b0fe202206b01a293b5815492e950c0a21766d451154c8dfd60916a40d66f6aa0cdb8f55b on tx 020000000184649e5d4c01a17a4f1612c722df7be59e31cdf39f969a8794d2adcd54b1b73100000000006634fd800109340f00000000001600145a6ff5a765192ff243a9564545c6da6c2b9740141c4b8c20 using key 03b53566ed0cf217575c53a3613c79b619f533214671cb302c248771ca973e1a9f
2018-11-25T13:41:40.107Z lightningd(17827): lightning_openingd-03e50492eab4107a773141bb419e107bda3de3d55652e6e1a41225f06a0bbf2d56 chan #10: peer_out WIRE_FUNDING_CREATED
2018-11-25T13:41:40.220Z lightningd(17827): lightning_openingd-03e50492eab4107a773141bb419e107bda3de3d55652e6e1a41225f06a0bbf2d56 chan #10: peer_in WIRE_FUNDING_SIGNED
2018-11-25T13:41:40.225Z lightningd(17827): lightning_openingd-03e50492eab4107a773141bb419e107bda3de3d55652e6e1a41225f06a0bbf2d56 chan #10: UPDATE WIRE_OPENING_FUNDER_REPLY
2018-11-25T13:41:40.225Z lightningd(17827): lightning_openingd-03e50492eab4107a773141bb419e107bda3de3d55652e6e1a41225f06a0bbf2d56 chan #10: UPDATE WIRE_OPENING_FUNDER_REPLY
2018-11-25T13:41:40.226Z lightningd(17827): 02681f2ac1d70b2dac7e4092d0a13315a3f2c7b4396fd4d7dae2b014c418b04912
2018-11-25T13:41:40.283Z lightningd(17827): 03e50492eab4107a773141bb419e107bda3de3d55652e6e1a41225f06a0bbf2d56 chan #10: Funding tx has 3 inputs, 2 outputs:
2018-11-25T13:41:40.283Z lightningd(17827): 03e50492eab4107a773141bb419e107bda3de3d55652e6e1a41225f06a0bbf2d56 chan #10: 0: 10648 satoshi (SEGWIT) 695254bb08add33af6f907960913869c25903c967541b2b8765be96431d2cb59?
2018-11-25T13:41:40.283Z lightningd(17827): 03e50492eab4107a773141bb419e107bda3de3d55652e6e1a41225f06a0bbf2d56 chan #10: 1: 2005802 satoshi (SEGWIT) bd729c73e2cd2647f5ce6a2ebd24419720486f720124d9e0c66649b0b3d2835d?
2018-11-25T13:41:40.283Z lightningd(17827): 03e50492eab4107a773141bb419e107bda3de3d55652e6e1a41225f06a0bbf2d56 chan #10: 2: 252848 satoshi (SEGWIT) bbe3783d4c7fde8eb6433403fc1c34fa0098e4c738cedeac087243a1655a0b81?
2018-11-25T13:41:40.300Z lightningd(17827): 03e50492eab4107a773141bb419e107bda3de3d55652e6e1a41225f06a0bbf2d56 chan #10: Getting HSM to sign funding tx
2018-11-25T13:41:40.383Z lightningd(17827): Owning output 1 1263492 (SEGWIT) txid 31b7b154cdadd294879a969ff3cd319ee57bdf22c712164f7aa1014c5d9e6484
2018-11-25T13:41:40.383Z lightningd(17827): 	 (tx 31b7b154cdadd294879a969ff3cd319ee57bdf22c712164f7aa1014c5d9e6484)
2018-11-25T13:41:40.384Z lightningd(17827): sendrawtransaction: 0200000000010359cbd23164e95b76b8b24175963c90259c8613099607f9f63ad3ad08bb5452690000000000ffffffff5d83d2b3b04966c6e0d92401726f4820974124bd2e6acef54726cde2739c72bd0100000000ffffffff810b5a65a1437208acdece38c7e49800fa341cfc033443b68ede7f4c3d78e3bb0100000000ffffffff0240420f00000000002200204238a90686f895419ba0e06c92bb98d4b8e05c2367c9c0b5cd782350264930358447130000000000160014fd4d9475bf001a617ba5d2f043ef8f7f07f8aabd02483045022100fb216e85efcfed190454e396a7a313a7cae901621dc1000692bca612935db43102202b3ed0b849d92134d1bcdac1ac39a48dbc448856e253fefba48f58e8012d78bc0121026ab13371ae3f4dc57b75da60768241594fb22c932bd49ab8357c91fa1a38a69902483045022100b044ec8f3fbf07371fef1c2e5b5c8291ca6c36bf94cfa2ef6b55cdb5619bd3a40220758d13faeaa7c5f40a61f02e504f30f19eece0f8359dd0e131bcefe885393f410121031057172c7552e90746f26e215f84326950a53c8656b8d9a72f1837f37aadbdcf02483045022100bb899a7aa42ac1ebf78b7246fbf97ecc9bcecc10e34aeef5af9637cec5f78ec00220762f6949ca9d3f240670c4a1be1632ab5ecfe2f43b87175f3e0ef74e38efd87f012102a85510a09391b9f07c50233040b8979695266955223790dca2cbc3041db1af4d00000000
2018-11-25T13:41:40.397Z lightningd(17827): lightning_channeld-03e50492eab4107a773141bb419e107bda3de3d55652e6e1a41225f06a0bbf2d56 chan #10: pid 31244, msgfd 33
2018-11-25T13:41:40.397Z lightningd(17827): 03e50492eab4107a773141bb419e107bda3de3d55652e6e1a41225f06a0bbf2d56 chan #10: Waiting for funding confirmations
2018-11-25T13:41:41.001Z lightning_hsmd(17953): Client: Received message 4 from client
2018-11-25T13:41:41.001Z lightningd(17827): sendrawtx exit 25, gave error code: -25?error message:?Missing inputs?
2018-11-25T13:41:41.001Z lightningd(17827): 03e50492eab4107a773141bb419e107bda3de3d55652e6e1a41225f06a0bbf2d56 chan #10: Peer internal error CHANNELD_AWAITING_LOCKIN: Funding broadcast exited with 25: error code: -25?error message:?Missing inputs?
$ 

"chan #10" doesn't seem to me the channel ID. Do I have to grepit?

@cdecker
Copy link
Member

cdecker commented Jan 6, 2019

I was able to get some of my channels unstuck by re-broadcasting the funding transaction the other day, and then using dev-rescan-outputs.

sqlite3 $HOME/.lightning/lightningd.sqlite3 "SELECT hex(rawtx) FROM transactions WHERE blockheight is null;"

That'll give you a list of transactions that we broadcast but where not yet confirmed. We can then take those transactions and identify the funding transaction (complicated a bit by the fact that we store the txid in non-reversed order). So if the funding txid ends in ABCDEF we need to go look for a transaction with ID EFCDAB in the database:

sqlite3 $HOME/.lightning/lightningd.sqlite3 "SELECT hex(id), hex(rawtx) FROM transactions WHERE HEX(ID) LIKE 'EFCDAB%';"

You can then take the rawtx and re-broadcast it either with one of the pushtx gateways, or your own bitcoind:

bitcoin-cli sendrawtransaction [rawtxhexstring]

You might also want to first check that it is the transaction you were expecting using decoderawtransaction, but it should always be safe to broadcast these transactions since they were broadcast in the past. If all goes well you should see the channels slowly progressing through the stages of confirming the channel on-chain and then closing them.

@gabridome
Copy link
Contributor Author

gabridome commented Jan 8, 2019

Thank you Christian:
The first command gave me a series of transactions. Among them I found two corresponding with my two stuck channels (I didn't mention but there's an other one).

$ sqlite3 $HOME/.lightning/lightningd.sqlite3 "SELECT hex(rawtx) FROM transactions WHERE blockheight is null;"
02000000000101811547CB76F89A46D94F64B005FE00FA6794BA2BE4991502E8B141A0E3FF43AE0000000000F0B00D8001AF9C070000000000220020741D2DAA925DF46C5328E182B16C57202EAACA45F2111E081F61D417C544AD0E04004830450221008EC6BE23DA4E71266C5674E6FF2A2D2040AD5A1BD536460FF627D89168490B46022022E4C2EC4419F14D413669AA6FE73817FEAB6A417C91E9D505DE00359D6B383301483045022100A8A1E9377567FD87EDE73E69255D40E0391341FFB92E3DD9C94166F80DD3FB0602206F9CFADCC90F3365DE3858E986DBD375DDC5AECEF3EDD400DCD8834BEC784D8B014752210260B08151EE7E6C5C9B763041EC1B6BAF0ACF64EF294570FDA7C6384CF31811A42103EE1FFE5A9418E71ACB6F0FDEC75740DB6499FA442C8798D1BA6888EA4A25768952AE8FA09920
02000000000101811547CB76F89A46D94F64B005FE00FA6794BA2BE4991502E8B141A0E3FF43AE0100000000FFFFFFFF0240420F0000000000220020DEA54D927FB81D93B92EBCFB71A8D8142AA6F899AAD626238FF9864C7A5B5AB92A9B1E0000000000160014E82FE6BFBFE37341984E7D05C47C1FC252C81D9902483045022100932E315CBBB57E6E1005ADD5090CAFF020B130BEC78D8F1A1862BFC84EEDF83002205AA0870288110A7C88DE407023EC0A1BEE9FFC206E8304D887846C244C32418801210208BB5E08EC349768A59E39CBEE43C6DE7B0ED227D845E86AE191DBC5450E735D00000000
020000000001015D83D2B3B04966C6E0D92401726F4820974124BD2E6ACEF54726CDE2739C72BD0000000000D07F2D8001D5400F00000000002200206CB1D7CA15F71833C784C84B2C6F0AE0188669D9276918FEFE5D80FE6D2015B3040047304402205CCCE54D90A1008E82BF170994549FD72A9AACC8CD09C624CB101A65834229C30220025A6B4A354DA3DCB7CDDFD0FD083AB77DB4C1DF1279B8E758D1C8E6411C342801483045022100AD3F76FE2ADB97EDD53010F4AA55311EF22CE62628378EE7C4042C4EB8BFF9C902203747D784B62220CAD89410200FF087653C6E5250C6F3C1A60EC6396814EBF9F40147522103230A9E50F62C6252F290714311BEE93ED782D98E2F9CB8D836C179EE796200212103AFA2C32B92A86FC8A1F43164FF06CF77C9C88A5E936BC3594AB7E4B60A4297CB52AE68B7D020
>>>>> 0200000000010359CBD23164E95B76B8B24175963C90259C8613099607F9F63AD3AD08BB5452690000000000FFFFFFFF5D83D2B3B04966C6E0D92401726F4820974124BD2E6ACEF54726CDE2739C72BD0100000000FFFFFFFF810B5A65A1437208ACDECE38C7E49800FA341CFC033443B68EDE7F4C3D78E3BB0100000000FFFFFFFF0240420F00000000002200204238A90686F895419BA0E06C92BB98D4B8E05C2367C9C0B5CD782350264930358447130000000000160014FD4D9475BF001A617BA5D2F043EF8F7F07F8AABD02483045022100FB216E85EFCFED190454E396A7A313A7CAE901621DC1000692BCA612935DB43102202B3ED0B849D92134D1BCDAC1AC39A48DBC448856E253FEFBA48F58E8012D78BC0121026AB13371AE3F4DC57B75DA60768241594FB22C932BD49AB8357C91FA1A38A69902483045022100B044EC8F3FBF07371FEF1C2E5B5C8291CA6C36BF94CFA2EF6B55CDB5619BD3A40220758D13FAEAA7C5F40A61F02E504F30F19EECE0F8359DD0E131BCEFE885393F410121031057172C7552E90746F26E215F84326950A53C8656B8D9A72F1837F37AADBDCF02483045022100BB899A7AA42AC1EBF78B7246FBF97ECC9BCECC10E34AEEF5AF9637CEC5F78EC00220762F6949CA9D3F240670C4A1BE1632AB5ECFE2F43B87175F3E0EF74E38EFD87F012102A85510A09391B9F07C50233040B8979695266955223790DCA2CBC3041DB1AF4D00000000
0200000000010184649E5D4C01A17A4F1612C722DF7BE59E31CDF39F969A8794D2ADCD54B1B73100000000006634FD800109340F00000000002200201E63C6E9637505F940B2A5E39C4C308EC8BA1F4F28199A63862ED37E7E5233BA040048304502210088FD46FC30C58CC8DD514A14CF91F49C82EF119C6F0DBD10D6487DD00126090902200FEDECCA629A8A28A4C903266CCCF77F94510E80E595F8F2A388D56D097CA54501483045022100B4F18B388328CA04284A5589128D4C23BA83DE975C168D2F1925BDF827AB84BE0220647A3917355ADAF5C6679C1510D7A5BE7B0F3FF1C72A3DF67E82328CA08EC37E0147522102288BB6BFAA2994DA79E7CA38326CB0F3A03BB7287E3CDC6F709C332EA2E5BB222103B53566ED0CF217575C53A3613C79B619F533214671CB302C248771CA973E1A9F52AE1C4B8C20
>>>> 0200000000010365DB2F5CC06BB812F515192489378A6552043D4218E94DCE10F52B3D585565050000000000FFFFFFFF84649E5D4C01A17A4F1612C722DF7BE59E31CDF39F969A8794D2ADCD54B1B7310100000000FFFFFFFF8F3491DF5F84DA018E3B55A97DE8BBFDE155F52B9FCBB1A7385F4E2FCC1177A20000000000FFFFFFFF0239990C00000000001600146BEF4E5AC91D4387C36ACD5D97C3138F2F84811A40420F00000000002200204299B2B8924C6302C53CB88EDA06792EF768543B80065F9CD9BDA133C38974FB0247304402207F162EF93B30E45CA6DB9114654B87D9435EC5DFAB3724E9E37497AD7B5B60DE02200276836996934F29BDC3CDB9F2716FA00BFB367E4A4D0DD0F68E8C11B4F9632801210375C82CCAA17364A221AA80AAB0B7EA90D6EFA83CDD31EE879870762274ABD51E02483045022100D3A97F2C422D19C9F7A4C872F446077A12BB4E747BC5099AB4013E08D5B2A05202207FB41D344B3A298C7CDE03457E819D3819452A18DEF6A510731225E4E1C04756012102A44ED73C4DB072D4D9AEBEBC2D38FD2128BE21F8C4B98CED8F2D9609EC83D3420247304402202BAA4DC48B5D56FDB80F387D33310C6E569A5B00085514BD7FE3D5D6A91225BC02206FCFF4D6B3BC1A7EDA64B23C497D47FDCDE751529794B19020EE7DA6D2C17E35012103B58265EB0833FC5996348803CCE9C8A7864CFC18EB6360E4A2426289A60056CF00000000
02000000000101F298A6BA2635E0F090F896E9F310A6CD63E7F97E45C1CACEE877A747CA2166E00100000000F91B2A8001B63A0F0000000000220020AE4A7C124558938DAF2E4220066DF4F9371BA3083C2D7637A8E51C36A9C2EF810400483045022100F064214BBC1FC721C0953FD0AF3EAFA4131E163473B758393D7AA731E26C41E802201E8E9A01C8DBDE516BB833CBC13C7A9C6AE52BB0BB3C18AFE66ACF5F2B16E8E101483045022100B24A62B05D25F6974661F9237D7F80075D05F3281782C41A70CF0C840124AAD302201130566F996E2846294C7E177F53A0E32AFD62239E02252B823E725A4809289F0147522102475A45B0BE82711643595CAC26B275401F7FABC8F146B8B8DAD1F5AD9E6BA50121024C9DB1B7B1ECD5500DA693BE9BD805BD33DEAEB52E3BE6FE23ECB3484A1F569152AE1F370420

The transaction id of the two are:

  • 84649e5d4c0
  • f298a6ba26

If I look for them with the second query you gave me they give me bak the raw funding transaction which have no inputs:

sqlite3 $HOME/.lightning/lightningd.sqlite3 "SELECT hex(id), hex(rawtx) FROM transactions WHERE HEX(ID) LIKE '84649e5d%';"
84649E5D4C01A17A4F1612C722DF7BE59E31CDF39F969A8794D2ADCD54B1B731|0200000000010359CBD23164E95B76B8B24175963C90259C8613099607F9F63AD3AD08BB5452690000000000FFFFFFFF5D83D2B3B04966C6E0D92401726F4820974124BD2E6ACEF54726CDE2739C72BD0100000000FFFFFFFF810B5A65A1437208ACDECE38C7E49800FA341CFC033443B68EDE7F4C3D78E3BB0100000000FFFFFFFF0240420F00000000002200204238A90686F895419BA0E06C92BB98D4B8E05C2367C9C0B5CD782350264930358447130000000000160014FD4D9475BF001A617BA5D2F043EF8F7F07F8AABD02483045022100FB216E85EFCFED190454E396A7A313A7CAE901621DC1000692BCA612935DB43102202B3ED0B849D92134D1BCDAC1AC39A48DBC448856E253FEFBA48F58E8012D78BC0121026AB13371AE3F4DC57B75DA60768241594FB22C932BD49AB8357C91FA1A38A69902483045022100B044EC8F3FBF07371FEF1C2E5B5C8291CA6C36BF94CFA2EF6B55CDB5619BD3A40220758D13FAEAA7C5F40A61F02E504F30F19EECE0F8359DD0E131BCEFE885393F410121031057172C7552E90746F26E215F84326950A53C8656B8D9A72F1837F37AADBDCF02483045022100BB899A7AA42AC1EBF78B7246FBF97ECC9BCECC10E34AEEF5AF9637CEC5F78EC00220762F6949CA9D3F240670C4A1BE1632AB5ECFE2F43B87175F3E0EF74E38EFD87F012102A85510A09391B9F07C50233040B8979695266955223790DCA2CBC3041DB1AF4D00000000

bitcoin-cli sendrawtransaction 0200000000010359CBD23164E95B76B8B24175963C90259C8613099607F9F63AD3AD08BB5452690000000000FFFFFFFF5D83D2B3B04966C6E0D92401726F4820974124BD2E6ACEF54726CDE2739C72BD0100000000FFFFFFFF810B5A65A1437208ACDECE38C7E49800FA341CFC033443B68EDE7F4C3D78E3BB0100000000FFFFFFFF0240420F00000000002200204238A90686F895419BA0E06C92BB98D4B8E05C2367C9C0B5CD782350264930358447130000000000160014FD4D9475BF001A617BA5D2F043EF8F7F07F8AABD02483045022100FB216E85EFCFED190454E396A7A313A7CAE901621DC1000692BCA612935DB43102202B3ED0B849D92134D1BCDAC1AC39A48DBC448856E253FEFBA48F58E8012D78BC0121026AB13371AE3F4DC57B75DA60768241594FB22C932BD49AB8357C91FA1A38A69902483045022100B044EC8F3FBF07371FEF1C2E5B5C8291CA6C36BF94CFA2EF6B55CDB5619BD3A40220758D13FAEAA7C5F40A61F02E504F30F19EECE0F8359DD0E131BCEFE885393F410121031057172C7552E90746F26E215F84326950A53C8656B8D9A72F1837F37AADBDCF02483045022100BB899A7AA42AC1EBF78B7246FBF97ECC9BCECC10E34AEEF5AF9637CEC5F78EC00220762F6949CA9D3F240670C4A1BE1632AB5ECFE2F43B87175F3E0EF74E38EFD87F012102A85510A09391B9F07C50233040B8979695266955223790DCA2CBC3041DB1AF4D00000000
error code: -25
error message:
Missing inputs

I'm probably missing something but if the raw funding transaction had no input (see above), if I rebroadcast it still haven't.
I haven't a clue why two transactions have been prepared lacking inputs.
Decoding the first:

$ bitcoin-cli decoderawtransaction 0200000000010359CBD23164E95B76B8B24175963C90259C8613099607F9F63AD3AD08BB5452690000000000FFFFFFFF5D83D2B3B04966C6E0D92401726F4820974124BD2E6ACEF54726CDE2739C72BD0100000000FFFFFFFF810B5A65A1437208ACDECE38C7E49800FA341CFC033443B68EDE7F4C3D78E3BB0100000000FFFFFFFF0240420F00000000002200204238A90686F895419BA0E06C92BB98D4B8E05C2367C9C0B5CD782350264930358447130000000000160014FD4D9475BF001A617BA5D2F043EF8F7F07F8AABD02483045022100FB216E85EFCFED190454E396A7A313A7CAE901621DC1000692BCA612935DB43102202B3ED0B849D92134D1BCDAC1AC39A48DBC448856E253FEFBA48F58E8012D78BC0121026AB13371AE3F4DC57B75DA60768241594FB22C932BD49AB8357C91FA1A38A69902483045022100B044EC8F3FBF07371FEF1C2E5B5C8291CA6C36BF94CFA2EF6B55CDB5619BD3A40220758D13FAEAA7C5F40A61F02E504F30F19EECE0F8359DD0E131BCEFE885393F410121031057172C7552E90746F26E215F84326950A53C8656B8D9A72F1837F37AADBDCF02483045022100BB899A7AA42AC1EBF78B7246FBF97ECC9BCECC10E34AEEF5AF9637CEC5F78EC00220762F6949CA9D3F240670C4A1BE1632AB5ECFE2F43B87175F3E0EF74E38EFD87F012102A85510A09391B9F07C50233040B8979695266955223790DCA2CBC3041DB1AF4D00000000
{
  "txid": "31b7b154cdadd294879a969ff3cd319ee57bdf22c712164f7aa1014c5d9e6484",
  "hash": "6325d73cbbf8d0cb7f54f922ea1906a5e3813c3298dc75764b87c05366750e37",
  "version": 2,
  "size": 533,
  "vsize": 289,
  "weight": 1154,
  "locktime": 0,
  "vin": [
    {
      "txid": "695254bb08add33af6f907960913869c25903c967541b2b8765be96431d2cb59",
      "vout": 0,
      "scriptSig": {
        "asm": "",
        "hex": ""
      },
      "txinwitness": [
        "3045022100fb216e85efcfed190454e396a7a313a7cae901621dc1000692bca612935db43102202b3ed0b849d92134d1bcdac1ac39a48dbc448856e253fefba48f58e8012d78bc01",
        "026ab13371ae3f4dc57b75da60768241594fb22c932bd49ab8357c91fa1a38a699"
      ],
      "sequence": 4294967295
    },
    {
      "txid": "bd729c73e2cd2647f5ce6a2ebd24419720486f720124d9e0c66649b0b3d2835d",
      "vout": 1,
      "scriptSig": {
        "asm": "",
        "hex": ""
      },
      "txinwitness": [
        "3045022100b044ec8f3fbf07371fef1c2e5b5c8291ca6c36bf94cfa2ef6b55cdb5619bd3a40220758d13faeaa7c5f40a61f02e504f30f19eece0f8359dd0e131bcefe885393f4101",
        "031057172c7552e90746f26e215f84326950a53c8656b8d9a72f1837f37aadbdcf"
      ],
      "sequence": 4294967295
    },
    {
      "txid": "bbe3783d4c7fde8eb6433403fc1c34fa0098e4c738cedeac087243a1655a0b81",
      "vout": 1,
      "scriptSig": {
        "asm": "",
        "hex": ""
      },
      "txinwitness": [
        "3045022100bb899a7aa42ac1ebf78b7246fbf97ecc9bcecc10e34aeef5af9637cec5f78ec00220762f6949ca9d3f240670c4a1be1632ab5ecfe2f43b87175f3e0ef74e38efd87f01",
        "02a85510a09391b9f07c50233040b8979695266955223790dca2cbc3041db1af4d"
      ],
      "sequence": 4294967295
    }
  ],
  "vout": [
    {
      "value": 0.01000000,
      "n": 0,
      "scriptPubKey": {
        "asm": "0 4238a90686f895419ba0e06c92bb98d4b8e05c2367c9c0b5cd78235026493035",
        "hex": "00204238a90686f895419ba0e06c92bb98d4b8e05c2367c9c0b5cd78235026493035",
        "reqSigs": 1,
        "type": "witness_v0_scripthash",
        "addresses": [
          "bc1qggu2jp5xlz25rxaqupkf9wuc6juwqhprvlyupdwd0q34qfjfxq6sdmfrcs"
        ]
      }
    },
    {
      "value": 0.01263492,
      "n": 1,
      "scriptPubKey": {
        "asm": "0 fd4d9475bf001a617ba5d2f043ef8f7f07f8aabd",
        "hex": "0014fd4d9475bf001a617ba5d2f043ef8f7f07f8aabd",
        "reqSigs": 1,
        "type": "witness_v0_keyhash",
        "addresses": [
          "bc1ql4xegadlqqdxz7a96tcy8mu00url324ar5e5uc"
        ]
      }
    }
  ]
}

EDIT: it turns out that 1 input of the first transaction and 1 of the second funding transaction belonged to two NON broadcast transactions. I did broadcast them (NOW). Waiting... Stay tuned. :)

@gabridome
Copy link
Contributor Author

Ok. The txs are all confirmed.
The situation has evolved a lot but I don't know what to do now:

$ lightning-cli listpeers 03e50492eab4107a773141bb419e107bda3de3d55652e6e1a41225f06a0bbf2d56 debug
{
  "peers": [
    {
      "id": "03e50492eab4107a773141bb419e107bda3de3d55652e6e1a41225f06a0bbf2d56", 
      "connected": true, 
      "netaddr": [
        "35.172.33.197:9735"
      ], 
      "global_features": "", 
      "local_features": "82", 
      "globalfeatures": "", 
      "localfeatures": "82", 
      "channels": [
        {
          "state": "AWAITING_UNILATERAL", 
          "scratch_txid": "458cd396b558361c2a616d0e2a0c56a50f5c8eacd9ca71e536d016bf3ae6233d", 
          "short_channel_id": "557612:1111:0", 
          "channel_id": "84649e5d4c01a17a4f1612c722df7be59e31cdf39f969a8794d2adcd54b1b731", 
          "funding_txid": "31b7b154cdadd294879a969ff3cd319ee57bdf22c712164f7aa1014c5d9e6484", 
          "msatoshi_to_us": 1000000000, 
          "msatoshi_to_us_min": 1000000000, 
          "msatoshi_to_us_max": 1000000000, 
          "msatoshi_total": 1000000000, 
          "dust_limit_satoshis": 546, 
          "max_htlc_value_in_flight_msat": 18446744073709551615, 
          "their_channel_reserve_satoshis": 10000, 
          "our_channel_reserve_satoshis": 10000, 
          "spendable_msatoshi": 990000000, 
          "htlc_minimum_msat": 0, 
          "their_to_self_delay": 144, 
          "our_to_self_delay": 144, 
          "max_accepted_htlcs": 483, 
          "status": [
            "AWAITING_UNILATERAL:Attempting to reconnect"
          ], 
          "in_payments_offered": 0, 
          "in_msatoshi_offered": 0, 
          "in_payments_fulfilled": 0, 
          "in_msatoshi_fulfilled": 0, 
          "out_payments_offered": 0, 
          "out_msatoshi_offered": 0, 
          "out_payments_fulfilled": 0, 
          "out_msatoshi_fulfilled": 0, 
          "htlcs": [
          ]
        }
      ], 
      "log": [
        {
          "type": "DEBUG", 
          "time": "5.767420071", 
          "source": "03e50492eab4107a773141bb419e107bda3de3d55652e6e1a41225f06a0bbf2d56 chan #10:", 
          "log": "Peer has reconnected, state AWAITING_UNILATERAL"
        }, 
        {
          "type": "DEBUG", 
          "time": "5.771518900", 
          "source": "lightning_openingd-03e50492eab4107a773141bb419e107bda3de3d55652e6e1a41225f06a0bbf2d56 chan #15:", 
          "log": "pid 21320, msgfd 26"
        }, 
        {
          "type": "DEBUG", 
          "time": "6.160912433", 
          "source": "lightning_openingd-03e50492eab4107a773141bb419e107bda3de3d55652e6e1a41225f06a0bbf2d56 chan #15:", 
          "log": "peer_out WIRE_ERROR"
        }, 
        {
          "type": "DEBUG", 
          "time": "6.163901874", 
          "source": "lightning_openingd-03e50492eab4107a773141bb419e107bda3de3d55652e6e1a41225f06a0bbf2d56 chan #15:", 
          "log": "Handed peer, entering loop"
        }, 
        {
          "type": "DEBUG", 
          "time": "559859.573185626", 
          "source": "lightning_openingd-03e50492eab4107a773141bb419e107bda3de3d55652e6e1a41225f06a0bbf2d56 chan #15:", 
          "log": "Failed reading header: Success"
        }, 
        {
          "type": "INFO", 
          "time": "559859.573358970", 
          "source": "lightning_openingd-03e50492eab4107a773141bb419e107bda3de3d55652e6e1a41225f06a0bbf2d56 chan #15:", 
          "log": "Peer connection lost"
        }, 
        {
          "type": "DEBUG", 
          "time": "559859.573429251", 
          "source": "lightning_openingd-03e50492eab4107a773141bb419e107bda3de3d55652e6e1a41225f06a0bbf2d56 chan #15:", 
          "log": "Status closed, but not exited. Killing"
        }, 
        {
          "type": "INFO", 
          "time": "559859.587588209", 
          "source": "03e50492eab4107a773141bb419e107bda3de3d55652e6e1a41225f06a0bbf2d56 chan #15:", 
          "log": "Owning subdaemon lightning_openingd died (62208)"
        }, 
        {
          "type": "DEBUG", 
          "time": "1299915.425206142", 
          "source": "03e50492eab4107a773141bb419e107bda3de3d55652e6e1a41225f06a0bbf2d56 chan #10:", 
          "log": "Got depth change 0->1 for 31b7b154cdadd294879a969ff3cd319ee57bdf22c712164f7aa1014c5d9e6484"
        }, 
        {
          "type": "DEBUG", 
          "time": "1299915.425304358", 
          "source": "03e50492eab4107a773141bb419e107bda3de3d55652e6e1a41225f06a0bbf2d56 chan #10:", 
          "log": "Funding tx 31b7b154cdadd294879a969ff3cd319ee57bdf22c712164f7aa1014c5d9e6484 depth 1 of 3"
        }, 
        {
          "type": "DEBUG", 
          "time": "1300518.505823598", 
          "source": "03e50492eab4107a773141bb419e107bda3de3d55652e6e1a41225f06a0bbf2d56 chan #10:", 
          "log": "Got depth change 1->2 for 31b7b154cdadd294879a969ff3cd319ee57bdf22c712164f7aa1014c5d9e6484"
        }, 
        {
          "type": "DEBUG", 
          "time": "1300518.505922978", 
          "source": "03e50492eab4107a773141bb419e107bda3de3d55652e6e1a41225f06a0bbf2d56 chan #10:", 
          "log": "Funding tx 31b7b154cdadd294879a969ff3cd319ee57bdf22c712164f7aa1014c5d9e6484 depth 2 of 3"
        }, 
        {
          "type": "DEBUG", 
          "time": "1300881.698069472", 
          "source": "03e50492eab4107a773141bb419e107bda3de3d55652e6e1a41225f06a0bbf2d56 chan #10:", 
          "log": "Got depth change 2->3 for 31b7b154cdadd294879a969ff3cd319ee57bdf22c712164f7aa1014c5d9e6484"
        }, 
        {
          "type": "DEBUG", 
          "time": "1300881.698129517", 
          "source": "03e50492eab4107a773141bb419e107bda3de3d55652e6e1a41225f06a0bbf2d56 chan #10:", 
          "log": "Funding tx 31b7b154cdadd294879a969ff3cd319ee57bdf22c712164f7aa1014c5d9e6484 depth 3 of 3"
        }, 
        {
          "type": "DEBUG", 
          "time": "1300881.698895686", 
          "source": "03e50492eab4107a773141bb419e107bda3de3d55652e6e1a41225f06a0bbf2d56 chan #10:", 
          "log": "Funding tx confirmed, but peer in state AWAITING_UNILATERAL"
        }, 
        {
          "type": "DEBUG", 
          "time": "1302807.712281442", 
          "source": "03e50492eab4107a773141bb419e107bda3de3d55652e6e1a41225f06a0bbf2d56 chan #10:", 
          "log": "Got depth change 3->4 for 31b7b154cdadd294879a969ff3cd319ee57bdf22c712164f7aa1014c5d9e6484"
        }, 
        {
          "type": "DEBUG", 
          "time": "1302807.712332331", 
          "source": "03e50492eab4107a773141bb419e107bda3de3d55652e6e1a41225f06a0bbf2d56 chan #10:", 
          "log": "Funding tx 31b7b154cdadd294879a969ff3cd319ee57bdf22c712164f7aa1014c5d9e6484 depth 4 of 3"
        }, 
        {
          "type": "DEBUG", 
          "time": "1302807.712374942", 
          "source": "03e50492eab4107a773141bb419e107bda3de3d55652e6e1a41225f06a0bbf2d56 chan #10:", 
          "log": "Funding tx confirmed, but peer in state AWAITING_UNILATERAL"
        }, 
        {
          "type": "DEBUG", 
          "time": "1302839.184858552", 
          "source": "03e50492eab4107a773141bb419e107bda3de3d55652e6e1a41225f06a0bbf2d56 chan #10:", 
          "log": "Got depth change 4->5 for 31b7b154cdadd294879a969ff3cd319ee57bdf22c712164f7aa1014c5d9e6484"
        }, 
        {
          "type": "DEBUG", 
          "time": "1302839.184911086", 
          "source": "03e50492eab4107a773141bb419e107bda3de3d55652e6e1a41225f06a0bbf2d56 chan #10:", 
          "log": "Funding tx 31b7b154cdadd294879a969ff3cd319ee57bdf22c712164f7aa1014c5d9e6484 depth 5 of 3"
        }, 
        {
          "type": "DEBUG", 
          "time": "1302839.184954152", 
          "source": "03e50492eab4107a773141bb419e107bda3de3d55652e6e1a41225f06a0bbf2d56 chan #10:", 
          "log": "Funding tx confirmed, but peer in state AWAITING_UNILATERAL"
        }, 
        {
          "type": "DEBUG", 
          "time": "1303624.209511839", 
          "source": "03e50492eab4107a773141bb419e107bda3de3d55652e6e1a41225f06a0bbf2d56 chan #10:", 
          "log": "Got depth change 5->6 for 31b7b154cdadd294879a969ff3cd319ee57bdf22c712164f7aa1014c5d9e6484"
        }, 
        {
          "type": "DEBUG", 
          "time": "1303624.209573876", 
          "source": "03e50492eab4107a773141bb419e107bda3de3d55652e6e1a41225f06a0bbf2d56 chan #10:", 
          "log": "Funding tx 31b7b154cdadd294879a969ff3cd319ee57bdf22c712164f7aa1014c5d9e6484 depth 6 of 3"
        }, 
        {
          "type": "DEBUG", 
          "time": "1303624.209618070", 
          "source": "03e50492eab4107a773141bb419e107bda3de3d55652e6e1a41225f06a0bbf2d56 chan #10:", 
          "log": "Funding tx confirmed, but peer in state AWAITING_UNILATERAL"
        }, 
        {
          "type": "DEBUG", 
          "time": "1309647.114857804", 
          "source": "03e50492eab4107a773141bb419e107bda3de3d55652e6e1a41225f06a0bbf2d56 chan #10:", 
          "log": "Peer has reconnected, state AWAITING_UNILATERAL"
        }, 
        {
          "type": "DEBUG", 
          "time": "1309647.173793999", 
          "source": "lightning_openingd-03e50492eab4107a773141bb419e107bda3de3d55652e6e1a41225f06a0bbf2d56 chan #17:", 
          "log": "pid 24011, msgfd 26"
        }, 
        {
          "type": "DEBUG", 
          "time": "1309647.312509371", 
          "source": "lightning_openingd-03e50492eab4107a773141bb419e107bda3de3d55652e6e1a41225f06a0bbf2d56 chan #17:", 
          "log": "peer_out WIRE_ERROR"
        }, 
        {
          "type": "DEBUG", 
          "time": "1309647.313416532", 
          "source": "lightning_openingd-03e50492eab4107a773141bb419e107bda3de3d55652e6e1a41225f06a0bbf2d56 chan #17:", 
          "log": "Handed peer, entering loop"
        }
      ]
    }
  ]
}

@gabridome
Copy link
Contributor Author

gabridome commented Jan 9, 2019

Update: I have tried to rebroadcast all the transaction I had in result of the query and now the situation is:

          "status": [
            "ONCHAIN:Tracking our own unilateral close",
            "ONCHAIN:2 outputs unresolved: in 119 blocks will spend DELAYED_OUTPUT_TO_US (458cd396b558361c2a616d0e2a0c56a50f5c8eacd9ca71e536d016bf3ae6233d:0) using OUR_DELAYED_RETURN_TO_WALLET"
          ],

I have still three transactions not broadcasted, using the first query. The first and the second ones use inputs already spent by other transactions and the third is already on the blockchain.
What I should do?
Do I need to investigate further or this is simply dirt left after an old accident?

$ sqlite3  $HOME/.lightning/lightningd.sqlite3 "SELECT lower(hex(id)),hex(rawtx) FROM transactions WHERE blockheight is null;"
1447166448bfa5585b928dca9409155b855330ceaa321a7049f96e0388df52fd|02000000000101811547CB76F89A46D94F64B005FE00FA6794BA2BE4991502E8B141A0E3FF43AE0000000000F0B00D8001AF9C070000000000220020741D2DAA925DF46C5328E182B16C57202EAACA45F2111E081F61D417C544AD0E04004830450221008EC6BE23DA4E71266C5674E6FF2A2D2040AD5A1BD536460FF627D89168490B46022022E4C2EC4419F14D413669AA6FE73817FEAB6A417C91E9D505DE00359D6B383301483045022100A8A1E9377567FD87EDE73E69255D40E0391341FFB92E3DD9C94166F80DD3FB0602206F9CFADCC90F3365DE3858E986DBD375DDC5AECEF3EDD400DCD8834BEC784D8B014752210260B08151EE7E6C5C9B763041EC1B6BAF0ACF64EF294570FDA7C6384CF31811A42103EE1FFE5A9418E71ACB6F0FDEC75740DB6499FA442C8798D1BA6888EA4A25768952AE8FA09920
5d83d2b3b04966c6e0d92401726f4820974124bd2e6acef54726cde2739c72bd|02000000000101811547CB76F89A46D94F64B005FE00FA6794BA2BE4991502E8B141A0E3FF43AE0100000000FFFFFFFF0240420F0000000000220020DEA54D927FB81D93B92EBCFB71A8D8142AA6F899AAD626238FF9864C7A5B5AB92A9B1E0000000000160014E82FE6BFBFE37341984E7D05C47C1FC252C81D9902483045022100932E315CBBB57E6E1005ADD5090CAFF020B130BEC78D8F1A1862BFC84EEDF83002205AA0870288110A7C88DE407023EC0A1BEE9FFC206E8304D887846C244C32418801210208BB5E08EC349768A59E39CBEE43C6DE7B0ED227D845E86AE191DBC5450E735D00000000
045d3daf9dce26de269a067ef0f07a40acae36b1fbb2f044550837bec6c8f783|020000000001015D83D2B3B04966C6E0D92401726F4820974124BD2E6ACEF54726CDE2739C72BD0000000000D07F2D8001D5400F00000000002200206CB1D7CA15F71833C784C84B2C6F0AE0188669D9276918FEFE5D80FE6D2015B3040047304402205CCCE54D90A1008E82BF170994549FD72A9AACC8CD09C624CB101A65834229C30220025A6B4A354DA3DCB7CDDFD0FD083AB77DB4C1DF1279B8E758D1C8E6411C342801483045022100AD3F76FE2ADB97EDD53010F4AA55311EF22CE62628378EE7C4042C4EB8BFF9C902203747D784B62220CAD89410200FF087653C6E5250C6F3C1A60EC6396814EBF9F40147522103230A9E50F62C6252F290714311BEE93ED782D98E2F9CB8D836C179EE796200212103AFA2C32B92A86FC8A1F43164FF06CF77C9C88A5E936BC3594AB7E4B60A4297CB52AE68B7D020

@gabridome
Copy link
Contributor Author

The situation seems to be resolved:

          "status": [
            "ONCHAIN:Tracking our own unilateral close",
            "ONCHAIN:All outputs resolved: waiting 97 more blocks before forgetting channel"

I would like thank you @SimonVrouwe and @Snyke for the precious help.
Two question remain unsolved:

  • How I ended up trying to broadcast no funded transactions
  • What to do with the three non broadcast transactions above
    apart from that I would agree in closing the issue if we don't need further investigate the issue.
    Lessons learned so far:
  1. stop the daemon if you want to copy .lightning/lightningd.sqlite3to investigate or query the database directly but be very careful not to update it
  2. when a transaction is not broadcast, it remains in the database with weight set to null. Very useful query @Snyke.

@SimonVrouwe

Note that the txid's in the query need to be all uppercase, at least on my system.
For your queries containing uppercase "Hex"s you can convert them into lowercase using lower(hex()).

@SimonVrouwe
Copy link
Collaborator

@gabridome thanks for the tip. I think the most likely cause for a stuck tx is when, for whatever reason, a dependent (parent) tx was not broadcast, i.e. not accepted in mempool. c-lightning relies heavily on bitcoind doing its job.

in code below wallet_extract_owned_outputs adds the change_output to the wallet db with status available, but when broadcast_tx fails it does not reverse that.

/* Extract the change output and add it to the DB */
wallet_extract_owned_outputs(ld->wallet, fundingtx, NULL, &change_satoshi);
/* Make sure we recognize our change output by its scriptpubkey in
* future. This assumes that we have only two outputs, may not be true
* if we add support for multifundchannel */
if (tal_count(fundingtx->output) == 2)
txfilter_add_scriptpubkey(ld->owned_txfilter, fundingtx->output[!funding_outnum].script);
/* Send it out and watch for confirms. */
broadcast_tx(ld->topology, channel, fundingtx, funding_broadcast_failed);

For example when you call fundchannel and make bitcoin-cli fail the sendrawtransaction call, c-lightning's wallet still thinks the change_output is available and will use it for subsequent tx etc.

In my opinion this should be improved, but it appears not so simple because bitcoin-cli calls from c-lightning are asynchronous.

@gabridome
Copy link
Contributor Author

gabridome commented Jan 11, 2019

For example when you call fundchannel and make bitcoin-cli fail the sendrawtransaction call, c-lightning's wallet still thinks the change_output is available and will use it for subsequent tx etc.

So, if I understand correctly, if c-lightning was aware of the failure would consider all the inputs as unspent output for subsequent transactions.

Instead it considers the change_output of the failed transaction as available and this is why subsequent transactions, using those change_outputs fail as well.

It seems like something like a "rollback" function is needed in this case, given the negative outcome of sendrawtransaction is available of course.

@SimonVrouwe
Copy link
Collaborator

SimonVrouwe commented Jan 11, 2019

It seems like something like a "rollback" function is needed in this case, given the negative outcome of sendrawtransaction is available of course.

Have been thinking about this also, not sure what is the right approach. I think once the funding_tx has been created it is out-there and valid, and from there probably safest is to push through. However I am working on a bit of a hack that puts outputs (in db) dependent on funding_tx, into an intermediate state, so they are not selected for subsequent tx's, until broadcast successful. Will make PR if any useful.

@gabridome
Copy link
Contributor Author

gabridome commented Jan 11, 2019

until broadcast successful.

Or until confirmation? before confirmation a new output shouldn't be considered spendable IMVHO.

It seems a problem also normal wallets have: when change output are to be considered spendable and what to do in the meanwhile?

SimonVrouwe added a commit to SimonVrouwe/lightning that referenced this issue Jan 17, 2019
- result 'fundchannel' command now depends on successful or failed broadcast of the funding tx
- failure returns error code FUNDING_BROADCAST_FAIL
- failure still fails the channel into -> AWAITING_UNILATERAL

This gives the user a more explicit warning of broadcast failure, so it (hopefully) doesn't
try to broadcast new tx's that depend on its change_outputs, see issue ElementsProject#2171

openingd/opening_funder_finished: broadcast_tx callback function now handles both
success and failure

pytest: mock_sendrawtransaction now returns error _number_, the jsonrpc's command_fail
needs a _number_ instead of 'error'

jsonrpc: added error code FUNDING_BROADCAST_FAIL

improved some comments
SimonVrouwe added a commit to SimonVrouwe/lightning that referenced this issue Jan 18, 2019
- result 'fundchannel' command now depends on successful or failed broadcast of the funding tx
- failure returns error code FUNDING_BROADCAST_FAIL
- don't fail the channel when broadcast failed, but keep in `CHANNELD_AWAITING_LOCKIN`
- user could then manually rebroadcast tx and keep the channel

This gives the user a more explicit warning of broadcast failure, so it (hopefully) doesn't
try to broadcast new tx's that depend on its change_outputs, see issue ElementsProject#2171

openingd/opening_funder_finished: broadcast_tx callback function now handles both
success and failure

pytest: mock_sendrawtransaction now returns error _number_, the jsonrpc's command_fail
needs a _number_ instead of 'error'

jsonrpc: added error code FUNDING_BROADCAST_FAIL

improved some comments
rustyrussell pushed a commit to SimonVrouwe/lightning that referenced this issue Jan 23, 2019
- result 'fundchannel' command now depends on successful or failed broadcast of the funding tx
- failure returns error code FUNDING_BROADCAST_FAIL
- don't fail the channel when broadcast failed, but keep in `CHANNELD_AWAITING_LOCKIN`
- user could then manually rebroadcast tx and keep the channel

This gives the user a more explicit warning of broadcast failure, so it (hopefully) doesn't
try to broadcast new tx's that depend on its change_outputs, see issue ElementsProject#2171

openingd/opening_funder_finished: broadcast_tx callback function now handles both
success and failure

jsonrpc: added error code FUNDING_BROADCAST_FAIL
rustyrussell pushed a commit to SimonVrouwe/lightning that referenced this issue Jan 24, 2019
- result 'fundchannel' command now depends on successful or failed broadcast of the funding tx
- failure returns error code FUNDING_BROADCAST_FAIL
- don't fail the channel when broadcast failed, but keep in `CHANNELD_AWAITING_LOCKIN`
- user could then manually rebroadcast tx and keep the channel

This gives the user a more explicit warning of broadcast failure, so it (hopefully) doesn't
try to broadcast new tx's that depend on its change_outputs, see issue ElementsProject#2171

openingd/opening_funder_finished: broadcast_tx callback function now handles both
success and failure

jsonrpc: added error code FUNDING_BROADCAST_FAIL
SimonVrouwe added a commit to SimonVrouwe/lightning that referenced this issue Jan 26, 2019
- result fundchannel command now depends on successful or failed broadcast of the funding tx
- failure returns error code FUNDING_BROADCAST_FAIL
- don't fail the channel when broadcast failed, but keep in CHANNELD_AWAITING_LOCKIN
- after fixing the initial broadcast failure, the user could manually rebroadcast the tx and
  keep the channel

openingd/opening_funder_finished:
- broadcast_tx callback function now handles both success and failure

jsonrpc: added error code FUNDING_BROADCAST_FAIL
manpage: added error code returned by fundchannel command

This makes the user more aware of broadcast failure, so it hopefully doesn't
try to broadcast new tx's that depend on its change_outputs. Some users have reported (see
issue ElementsProject#2171) a whole sequence of fundings failing, because each funding was using the change
output of the previous one, which would not confirm.
SimonVrouwe added a commit to SimonVrouwe/lightning that referenced this issue Jan 26, 2019
- result fundchannel command now depends on successful or failed broadcast of the funding tx
- failure returns error code FUNDING_BROADCAST_FAIL
- don't fail the channel when broadcast failed, but keep in CHANNELD_AWAITING_LOCKIN
- after fixing the initial broadcast failure, the user could manually rebroadcast the tx and
  keep the channel

openingd/opening_funder_finished:
- broadcast_tx callback function now handles both success and failure

jsonrpc: added error code FUNDING_BROADCAST_FAIL
manpage: added error code returned by fundchannel command

This makes the user more aware of broadcast failure, so it hopefully doesn't
try to broadcast new tx's that depend on its change_outputs. Some users have reported (see
issue ElementsProject#2171) a whole sequence of fundings failing, because each funding was using the change
output of the previous one, which would not confirm.
rustyrussell pushed a commit that referenced this issue Jan 29, 2019
- result fundchannel command now depends on successful or failed broadcast of the funding tx
- failure returns error code FUNDING_BROADCAST_FAIL
- don't fail the channel when broadcast failed, but keep in CHANNELD_AWAITING_LOCKIN
- after fixing the initial broadcast failure, the user could manually rebroadcast the tx and
  keep the channel

openingd/opening_funder_finished:
- broadcast_tx callback function now handles both success and failure

jsonrpc: added error code FUNDING_BROADCAST_FAIL
manpage: added error code returned by fundchannel command

This makes the user more aware of broadcast failure, so it hopefully doesn't
try to broadcast new tx's that depend on its change_outputs. Some users have reported (see
issue #2171) a whole sequence of fundings failing, because each funding was using the change
output of the previous one, which would not confirm.
@sd4096
Copy link

sd4096 commented Feb 27, 2020

Hi, I'm a noob but wanted to note that I have needed to reference this thread a couple times. Once with a channel stuck at "AWAITING_UNILATERAL" for days and again this morning with a channel stuck at "CHANNELD_AWAITING_LOCKIN" for days.

In both cases, rebroadcasting the transaction through bitcoin_cli with the rawtx did the trick. My bitcoin node connects via tor proxy and I also use NordVPN. Maybe I missed something and this config is not recommended with c-lightning? Otherwise, I just wanted to state things for the record...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants