Skip to content

Locked funds due to funding a channel with a transaction with the wrong txid from a P2SH wallet #4416

Closed
@openoms

Description

I have attempted to fund a channel from an external P2SH wallet
When converting the PSBT to a rawtxn the txid has changed.
The transaction broadcasted sent the the right amount to the right address, but the txid was not which was passed to fundchannel_complete.
Unfortunately the transaction has confirmed quickly so now I need to find a way to recover it.
The channel peer is Fulmo - running c-lightning also.

To help to reproduce:
Funding start:

$  lightning-cli fundchannel_start 024a8228d764091fce2ed67e1a7404f83e38ea3c7cb42030a2789e73cf3b341365 1980400 11000 false
{
   "funding_address": "bc1qa8guuljuzsc9auqcz7vrr8lw33yy6kmyglw0f9lg33cevqmaffdq73fr5g",
   "scriptpubkey": "0020e9d1ce7e5c14305ef0181798319fee8c484d5b6447dcf497e88c7196037d4a5a"
}

The created PSBT contained the scriptpubkey:

 $ bitcoin-cli decodepsbt cHNidP8BAH4CAAAAATw1PfctMJUkgKsP/VfeXUxlYhVXfY+gAlCnqMckpVeRCgAAAAD9////AvA3HgAAAAAAIgAg6dHOflwUMF7wGBeYMZ/ujEhNW2RH3PSX6IxxlgN9SloNIgAAAAAAABepFA41rP1bo8mRlr1cMVhvdrqtMvPDhwAAAAAAAQEgmGEeAAAAAAAXqRTHgyH9vJ7ddERhGKjlKEIzO5e4LIcBBxcWABS6jjPeDE6pIVIj1Bkv+PT4yY77WwEIawJHMEQCICe+xIBosXGLOmRGoGjAEreWp5dC5X+z68R7nTg39bU6AiA5nk2KfNAGSUcfXvQ1n2Apoh5DTNU3fyxqfOn1r0QEYwEhAg8+YjtGpHWRsm5RDsJ74oEA9kET1YA4Hy6edCuLeISJAAABABYAFC5Ia9dmOF9kLpuWncBloSz9QQHuIgIC22vnu7hmpD2662fwkEw2lOyXlos3cYYbqKbEhcGUW5cMR52s0gEAAAAnAAAAAA== | grep 0020e9d1ce7e5c14305ef0181798319fee8c484d5b6447dcf497e88c7196037d4a5a
          "hex": "0020e9d1ce7e5c14305ef0181798319fee8c484d5b6447dcf497e88c7196037d4a5a",

And the txid ( Specter Desktop showed also: 408abf9ae8e2228266ea30985fa3bb47ee5e9fb964263bf2bb4166226bb33ea3):

$ bitcoin-cli decodepsbt cHNidP8BAH4CAAAAATw1PfctMJUkgKsP/VfeXUxlYhVXfY+gAlCnqMckpVeRCgAAAAD9////AvA3HgAAAAAAIgAg6dHOflwUMF7wGBeYMZ/ujEhNW2RH3PSX6IxxlgN9SloNIgAAAAAAABepFA41rP1bo8mRlr1cMVhvdrqtMvPDhwAAAAAAAQEgmGEeAAAAAAAXqRTHgyH9vJ7ddERhGKjlKEIzO5e4LIcBBxcWABS6jjPeDE6pIVIj1Bkv+PT4yY77WwEIawJHMEQCICe+xIBosXGLOmRGoGjAEreWp5dC5X+z68R7nTg39bU6AiA5nk2KfNAGSUcfXvQ1n2Apoh5DTNU3fyxqfOn1r0QEYwEhAg8+YjtGpHWRsm5RDsJ74oEA9kET1YA4Hy6edCuLeISJAAABABYAFC5Ia9dmOF9kLpuWncBloSz9QQHuIgIC22vnu7hmpD2662fwkEw2lOyXlos3cYYbqKbEhcGUW5cMR52s0gEAAAAnAAAAAA== | grep txid
    "txid": "408abf9ae8e2228266ea30985fa3bb47ee5e9fb964263bf2bb4166226bb33ea3",
        "txid": "9157a524c7a8a75002a08f7d571562654c5dde57fd0fab802495302df73d353c",

TXID Confirmed in Specter Desktop
image

Passed the txid to fundchannel_complete:

$ lightning-cli fundchannel_complete 024a8228d764091fce2ed67e1a7404f83e38ea3c7cb42030a2789e73cf3b341365 408abf9ae8e2228266ea30985fa3bb47ee5e9fb964263bf2bb4166226bb33ea3 0
{
   "channel_id": "a33eb36b226641bbf23b2664b99f5eee47bba35f9830ea668222e2e89abf8a40",
   "commitments_secured": true
}

Now the issue was that imported the PSBT to Electrum to broadcast and did not realize that it shows a changed TXID (but the funding address and amount remained the same):
image

The raw transaction broadcasted:

020000000001013c353df72d30952480ab0ffd57de5d4c656215577d8fa00250a7a8c724a557910a00000017160014ba8e33de0c4ea9215223d4192ff8f4f8c98efb5bfdffffff02f0371e0000000000220020e9d1ce7e5c14305ef0181798319fee8c484d5b6447dcf497e88c7196037d4a5a0d2200000000000017a9140e35acfd5ba3c99196bd5c31586f76baad32f3c38702473044022027bec48068b1718b3a6446a068c012b796a79742e57fb3ebc47b9d3837f5b53a0220399e4d8a7cd00649471f5ef4359f6029a21e434cd5377f2c6a7ce9f5af4404630121020f3e623b46a47591b26e510ec27be28100f64113d580381f2e9e742b8b78848900000000

The actual confirmed transaction: https://blockstream.info/search?q=f74459ad229f47edb0835925c4211f51bac2a879bd466173f02b43a9fdce38ae

As discussed with on the developer meeting with @rustyrussell :

  • When the accident already happened a (dev) tool to extract the funding pubkeys and sign the manually constructed transaction could help to recover the funds although the cooperation of the channel peer is needed.
  • There were problems identified before when funding from P2SH wallets - could there be checks in place to avoid a similar thing happen in the future? Possibly even an externally built transaction could be broadcasted by c-lightning so it it could make the last checks.

Thank you for your time spent on looking into this.

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions