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

PSBT funding flow failed with bitcoin core #6372

Closed
antonilol opened this issue Mar 26, 2022 · 7 comments · Fixed by btcsuite/btcd#1834 or #6383
Closed

PSBT funding flow failed with bitcoin core #6372

antonilol opened this issue Mar 26, 2022 · 7 comments · Fixed by btcsuite/btcd#1834 or #6383
Milestone

Comments

@antonilol
Copy link
Contributor

Background

Describe your issue here.

i have opened channel in the past with PSBTs without any issues, but now suddenly they all fail to decode bitcoin core's PSBTs

Your environment

  • version of lnd
    lnd version 0.14.2-beta commit=v0.14.2-beta
  • which operating system (uname -a on *Nix)
    Linux myhostname 5.16.16-arch1-1 #1 SMP PREEMPT Mon, 21 Mar 2022 22:59:40 +0000 x86_64 GNU/Linux
  • version of btcd, bitcoind, or other backend
    bitcoin core v22
  • any other relevant environment details

Steps to reproduce

Tell us how to reproduce this issue. Please provide stacktraces and links to code in question.

  • open a channel with --psbt and try again until the funding address is tb1qpqgwtdeucepnk6uyvf8m4lucjhuwxuz5jp3nj3w3sdntfqqxh5kq0qaare (can take a long time)
  • enter the PSBT
cHNidP8BAH0CAAAAAaQl9KM/kKI7s1m5D/UycQ4AjL7dYaml6MxcZglDpwTFAAAAAAD/////AlDDAAAAAAAAIgAgCBDltzzGQztrhGJPuv+YlfjjcFSQYzlF0YNmtIAGvSwc3QYAAAAAABYAFCVJi6wJVEds0vtpK9hNtGee00hQAAAAAAABAH0CAAAAAQj8IZFQwNTznC6ssGmcDwV0YICrV+0Cj/aBryXr3M7sAAAAAAAAAAAAAiChBwAAAAAAIgAgH+x7DN1dSldA+HB6Na9hfj2ne/2tdzG7Hp6VzvN+ESLG9JAAAAAAABYAFGduL1Zn3RHbebXbECBU7NW6MbvGAAAAAAEBKyChBwAAAAAAIgAgH+x7DN1dSldA+HB6Na9hfj2ne/2tdzG7Hp6VzvN+ESIBBUdSIQJv6Ss6AjUV3+o5J12LH9+pAoKvyEWbT5nCmzBc79QZKiEDyF2K0TDPPeZZ+JjSQkO1nBYLETSLAXnuK/UqePZ5BaNSriIGAm/pKzoCNRXf6jknXYsf36kCgq/IRZtPmcKbMFzv1BkqBIHLcnciBgPIXYrRMM895ln4mNJCQ7WcFgsRNIsBee4r9Sp49nkFowRz0uMvAAEBR1IhAs2AeM8AUjlE6k3xuv7qZa9PjjyIgCYcz0I/qLaVph7zIQLo/lHOFsWTZ8MsDrXiGofcQvjgQInrBCVf85k/UWq8sFKuIgICzYB4zwBSOUTqTfG6/uplr0+OPIiAJhzPQj+otpWmHvMEmWZdZSICAuj+Uc4WxZNnwywOteIah9xC+OBAiesEJV/zmT9RarywBErACVgAIgIC8iHgmMn+11jFUcjqRCpjwQ6+6KNvDXcPo3jOd/oec4wQaBC1DgAAAIABAACAmQAAgAA=

Expected behaviour

Tell us what should happen

normal channel open flow as usual

Actual behaviour

Tell us what happens instead

Error received: got error from server: rpc error: code = Unknown desc = user canceled funding
[lncli] verifying PSBT by lnd failed: rpc error: code = Unknown desc = error parsing psbt: Invalid PSBT serialization format

additional notes

i think it is related to #4400, but it is a PSBT generated by Bitcoin Core, which sets the standard

decoded:

$ bitcoin-cli -testnet decodepsbt cHNidP8BAH0CAAAAAaQl9KM/kKI7s1m5D/UycQ4AjL7dYaml6MxcZglDpwTFAAAAAAD/////AlDDAAAAAAAAIgAgCBDltzzGQztrhGJPuv+YlfjjcFSQYzlF0YNmtIAGvSwc3QYAAAAAABYAFCVJi6wJVEds0vtpK9hNtGee00hQAAAAAAABAH0CAAAAAQj8IZFQwNTznC6ssGmcDwV0YICrV+0Cj/aBryXr3M7sAAAAAAAAAAAAAiChBwAAAAAAIgAgH+x7DN1dSldA+HB6Na9hfj2ne/2tdzG7Hp6VzvN+ESLG9JAAAAAAABYAFGduL1Zn3RHbebXbECBU7NW6MbvGAAAAAAEBKyChBwAAAAAAIgAgH+x7DN1dSldA+HB6Na9hfj2ne/2tdzG7Hp6VzvN+ESIBBUdSIQJv6Ss6AjUV3+o5J12LH9+pAoKvyEWbT5nCmzBc79QZKiEDyF2K0TDPPeZZ+JjSQkO1nBYLETSLAXnuK/UqePZ5BaNSriIGAm/pKzoCNRXf6jknXYsf36kCgq/IRZtPmcKbMFzv1BkqBIHLcnciBgPIXYrRMM895ln4mNJCQ7WcFgsRNIsBee4r9Sp49nkFowRz0uMvAAEBR1IhAs2AeM8AUjlE6k3xuv7qZa9PjjyIgCYcz0I/qLaVph7zIQLo/lHOFsWTZ8MsDrXiGofcQvjgQInrBCVf85k/UWq8sFKuIgICzYB4zwBSOUTqTfG6/uplr0+OPIiAJhzPQj+otpWmHvMEmWZdZSICAuj+Uc4WxZNnwywOteIah9xC+OBAiesEJV/zmT9RarywBErACVgAIgIC8iHgmMn+11jFUcjqRCpjwQ6+6KNvDXcPo3jOd/oec4wQaBC1DgAAAIABAACAmQAAgAA=
{
  "tx": {
    "txid": "3ef825a7f9acf19244a687e5a0bf8821ea2c28241423842e3b4c234cb3203512",
    "hash": "3ef825a7f9acf19244a687e5a0bf8821ea2c28241423842e3b4c234cb3203512",
    "version": 2,
    "size": 125,
    "vsize": 125,
    "weight": 500,
    "locktime": 0,
    "vin": [
      {
        "txid": "c504a74309665ccce8a5a961ddbe8c000e7132f50fb959b33ba2903fa3f425a4",
        "vout": 0,
        "scriptSig": {
          "asm": "",
          "hex": ""
        },
        "sequence": 4294967295
      }
    ],
    "vout": [
      {
        "value": 0.00050000,
        "n": 0,
        "scriptPubKey": {
          "asm": "0 0810e5b73cc6433b6b84624fbaff9895f8e3705490633945d18366b48006bd2c",
          "hex": "00200810e5b73cc6433b6b84624fbaff9895f8e3705490633945d18366b48006bd2c",
          "address": "tb1qpqgwtdeucepnk6uyvf8m4lucjhuwxuz5jp3nj3w3sdntfqqxh5kq0qaare",
          "type": "witness_v0_scripthash"
        }
      },
      {
        "value": 0.00449820,
        "n": 1,
        "scriptPubKey": {
          "asm": "0 25498bac0954476cd2fb692bd84db4679ed34850",
          "hex": "001425498bac0954476cd2fb692bd84db4679ed34850",
          "address": "tb1qy4ychtqf23rke5hmdy4asnd5v70dxjzs9cxszu",
          "type": "witness_v0_keyhash"
        }
      }
    ]
  },
  "unknown": {
  },
  "inputs": [
    {
      "witness_utxo": {
        "amount": 0.00500000,
        "scriptPubKey": {
          "asm": "0 1fec7b0cdd5d4a5740f8707a35af617e3da77bfdad7731bb1e9e95cef37e1122",
          "hex": "00201fec7b0cdd5d4a5740f8707a35af617e3da77bfdad7731bb1e9e95cef37e1122",
          "type": "witness_v0_scripthash",
          "address": "tb1qrlk8krxat499ws8cwparttmp0c76w7la44mnrwc7n62uaum7zy3qqpzu66"
        }
      },
      "non_witness_utxo": {
        "txid": "c504a74309665ccce8a5a961ddbe8c000e7132f50fb959b33ba2903fa3f425a4",
        "hash": "c504a74309665ccce8a5a961ddbe8c000e7132f50fb959b33ba2903fa3f425a4",
        "version": 2,
        "size": 125,
        "vsize": 125,
        "weight": 500,
        "locktime": 0,
        "vin": [
          {
            "txid": "eccedceb25af81f68f02ed57ab806074050f9c69b0ac2e9cf3d4c0509121fc08",
            "vout": 0,
            "scriptSig": {
              "asm": "",
              "hex": ""
            },
            "sequence": 0
          }
        ],
        "vout": [
          {
            "value": 0.00500000,
            "n": 0,
            "scriptPubKey": {
              "asm": "0 1fec7b0cdd5d4a5740f8707a35af617e3da77bfdad7731bb1e9e95cef37e1122",
              "hex": "00201fec7b0cdd5d4a5740f8707a35af617e3da77bfdad7731bb1e9e95cef37e1122",
              "address": "tb1qrlk8krxat499ws8cwparttmp0c76w7la44mnrwc7n62uaum7zy3qqpzu66",
              "type": "witness_v0_scripthash"
            }
          },
          {
            "value": 0.09499846,
            "n": 1,
            "scriptPubKey": {
              "asm": "0 676e2f5667dd11db79b5db102054ecd5ba31bbc6",
              "hex": "0014676e2f5667dd11db79b5db102054ecd5ba31bbc6",
              "address": "tb1qvahz74n8m5gak7d4mvgzq48v6karrw7xq75883",
              "type": "witness_v0_keyhash"
            }
          }
        ]
      },
      "witness_script": {
        "asm": "2 026fe92b3a023515dfea39275d8b1fdfa90282afc8459b4f99c29b305cefd4192a 03c85d8ad130cf3de659f898d24243b59c160b11348b0179ee2bf52a78f67905a3 2 OP_CHECKMULTISIG",
        "hex": "5221026fe92b3a023515dfea39275d8b1fdfa90282afc8459b4f99c29b305cefd4192a2103c85d8ad130cf3de659f898d24243b59c160b11348b0179ee2bf52a78f67905a352ae",
        "type": "multisig"
      },
      "bip32_derivs": [
        {
          "pubkey": "026fe92b3a023515dfea39275d8b1fdfa90282afc8459b4f99c29b305cefd4192a",
          "master_fingerprint": "81cb7277",
          "path": "m"
        },
        {
          "pubkey": "03c85d8ad130cf3de659f898d24243b59c160b11348b0179ee2bf52a78f67905a3",
          "master_fingerprint": "73d2e32f",
          "path": "m"
        }
      ]
    }
  ],
  "outputs": [
    {
      "witness_script": {
        "asm": "2 02cd8078cf00523944ea4df1bafeea65af4f8e3c8880261ccf423fa8b695a61ef3 02e8fe51ce16c59367c32c0eb5e21a87dc42f8e04089eb04255ff3993f516abcb0 2 OP_CHECKMULTISIG",
        "hex": "522102cd8078cf00523944ea4df1bafeea65af4f8e3c8880261ccf423fa8b695a61ef32102e8fe51ce16c59367c32c0eb5e21a87dc42f8e04089eb04255ff3993f516abcb052ae",
        "type": "multisig"
      },
      "bip32_derivs": [
        {
          "pubkey": "02cd8078cf00523944ea4df1bafeea65af4f8e3c8880261ccf423fa8b695a61ef3",
          "master_fingerprint": "99665d65",
          "path": "m"
        },
        {
          "pubkey": "02e8fe51ce16c59367c32c0eb5e21a87dc42f8e04089eb04255ff3993f516abcb0",
          "master_fingerprint": "4ac00958",
          "path": "m"
        }
      ]
    },
    {
      "bip32_derivs": [
        {
          "pubkey": "02f221e098c9fed758c551c8ea442a63c10ebee8a36f0d770fa378ce77fa1e738c",
          "master_fingerprint": "6810b50e",
          "path": "m/0'/1'/153'"
        }
      ]
    }
  ],
  "fee": 0.00000180
}
@antonilol
Copy link
Contributor Author

this one has a multisig input, but i also tried witness v0 keyhash inputs and they failed with the same error

@alexbosworth
Copy link
Contributor

alexbosworth commented Mar 26, 2022

what is the peer id? oh sorry I thought this was a peer returned err nm

@guggero
Copy link
Collaborator

guggero commented Mar 28, 2022

Thank you for the report. I was able to reproduce it and narrow it down to the bip32_derivs of the inputs and outputs.

      "bip32_derivs": [
        {
          "pubkey": "026fe92b3a023515dfea39275d8b1fdfa90282afc8459b4f99c29b305cefd4192a",
          "master_fingerprint": "81cb7277",
          "path": "m"
        },
        {
          "pubkey": "03c85d8ad130cf3de659f898d24243b59c160b11348b0179ee2bf52a78f67905a3",
          "master_fingerprint": "73d2e32f",
          "path": "m"
        }
      ]

Those derivation paths seem to be empty. Even though that is allowed by the spec (and should probably be fixed in the Golang implementation of the PSBT library), this seems weird. Can you tell us anything about those inputs or derivation paths? Are you using a hardware wallet with HWI?

@antonilol
Copy link
Contributor Author

I imported those keys in bitcoin core bitcoin-cli -testnet importprivkey ...

@antonilol
Copy link
Contributor Author

But what does lnd do with the derivation paths?

@guggero
Copy link
Collaborator

guggero commented Mar 28, 2022

Ah, interesting, thanks. lnd doesn't do anything with them. But the Golang PSBT library that lnd uses fails to parse the PSBT because of this check: https://github.com/btcsuite/btcd/blob/master/btcutil/psbt/bip32.go#L44

I'll create a fix in the mentioned library.

@Roasbeef
Copy link
Member

This was auto closed by the btcd PR (TIL that's even possible), but we still need to update lnd to use the btcutil/psbt/v1.1.2 tag. Which is done in this PR:

@Roasbeef Roasbeef reopened this Mar 30, 2022
Roasbeef added a commit to Roasbeef/lnd that referenced this issue Mar 30, 2022
Updates a version of `btcutil/psbt` that has looser parsing requirements
to properly match the BIP.

Fixes: lightningnetwork#6372
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants