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

Cannot call FundPSBT with a psbt with only a zero value OP_RETURN output #6386

Closed
benthecarman opened this issue Apr 1, 2022 · 6 comments · Fixed by btcsuite/btcd#1842 or #6428
Closed

Comments

@benthecarman
Copy link
Contributor

When creating trying to fund a psbt that creates an OP_RETURN with 0 value it gives the error wallet couldn't fund PSBT: PSBT packet must contain at least one input or output. If I change the output to be 1 satoshi, it will work.

@guggero
Copy link
Collaborator

guggero commented Apr 1, 2022

The error is coming from here: https://github.com/btcsuite/btcwallet/blob/master/wallet/psbt.go#L54
This checks if there is at least one output in the PSBT. Are you sure that your first attempt with 0 sats actually included the TxOut? If yes, could you please paste a sample PSBT?

@benthecarman
Copy link
Contributor Author

Here is the psbt cHNidP8BACABAAAAAAEAAAAAAAAAAA1qC2hlbGxvIHdvcmxkAAAAAAAA

decoded:

$ bitcoin-cli decodepsbt cHNidP8BACABAAAAAAEAAAAAAAAAAA1qC2hlbGxvIHdvcmxkAAAAAAAA
{
  "tx": {
    "txid": "b42fab8da654e748e6d0817f1eba248110bb3fa6da1c7e56b10f71bd1a9f2acf",
    "hash": "b42fab8da654e748e6d0817f1eba248110bb3fa6da1c7e56b10f71bd1a9f2acf",
    "version": 1,
    "size": 32,
    "vsize": 32,
    "weight": 128,
    "locktime": 0,
    "vin": [
    ],
    "vout": [
      {
        "value": 0.00000000,
        "n": 0,
        "scriptPubKey": {
          "asm": "OP_RETURN 68656c6c6f20776f726c64",
          "hex": "6a0b68656c6c6f20776f726c64",
          "type": "nulldata"
        }
      }
    ]
  },
  "unknown": {
  },
  "inputs": [
  ],
  "outputs": [
    {
    }
  ],
  "fee": 0.00000000
}

@guggero
Copy link
Collaborator

guggero commented Apr 4, 2022

Okay, this is probably a bug in the golang PSBT library... It always expects a TX to be in the witness format, but this one doesn't seem to be. Weird that bitcoind doesn't have the same issue. What tool did you create the PSBT with? Bitcoind or another tool?

@benthecarman
Copy link
Contributor Author

Okay, this is probably a bug in the golang PSBT library... It always expects a TX to be in the witness format, but this one doesn't seem to be. Weird that bitcoind doesn't have the same issue. What tool did you create the PSBT with? Bitcoind or another tool?

I made it in bitcoin-s.

BIP 174 states it shouldn't be in the witness seralization

| Unsigned Transaction
| PSBT_GLOBAL_UNSIGNED_TX = 0x00
| None
| No key data
|
| The transaction in network serialization. The scriptSigs and witnesses for each input must be empty. The transaction must be in the old serialization format (without witnesses).


@guggero
Copy link
Collaborator

guggero commented Apr 11, 2022

Oh, thanks for finding that reference, I wasn't aware of that. Then the code in https://github.com/btcsuite/btcd/blob/master/btcutil/psbt/psbt.go#L217 is incorrect. Could you open an issue in btcd with the example PSBT please?

@Roasbeef
Copy link
Member

(btcd PR was merged, but lnd needs to be updated)

guggero added a commit to guggero/lnd that referenced this issue Apr 19, 2022
Fixes lightningnetwork#6386.
Bumps the btcutil/psbt library to the latest version v1.1.3 that fixes
an issue with de-serializing a PSBT that contains an unsigned
transaction with no inputs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants