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

elements-cli decodepsbt doesn't set inputs.witness_utxo.asset field #1371

Open
roconnor-blockstream opened this issue Oct 30, 2024 · 8 comments · May be fixed by #1372
Open

elements-cli decodepsbt doesn't set inputs.witness_utxo.asset field #1371

roconnor-blockstream opened this issue Oct 30, 2024 · 8 comments · May be fixed by #1372

Comments

@roconnor-blockstream
Copy link
Contributor

Example:

$ VOUT=0

$ TXID=905e43dfb58c9d7d02512b17f118e44205d773fa5c414a9f8899ffc24f399751

$ PSET=$(result/bin/elements-cli utxoupdatepsbt $(result/bin/elements-cli createpsbt "[{\"txid\": \"$TXID\", \"vout\": $VOUT, \"sequence\": 4294967294}]" "[{\"tex1qyh6tyhspd9w8jhqee8a2uzvyk9lnwp2n8ssur0\": 0.000008, \"blinder_index\": 0}, {\"fee\": 0.000001}]"))

$ result/bin/elements-cli decodepsbt $PSET
{
  "global_xpubs": [
  ],
  "tx_version": 2,
  "fallback_locktime": 0,
  "input_count": 1,
  "output_count": 1,
  "psbt_version": 2,
  "proprietary": [
  ],
  "fees": {
    "bitcoin": 0.00000100
  },
  "unknown": {
  },
  "inputs": [
    {
      "witness_utxo": {
        "amount": 0.00000900,
        "scriptPubKey": {
          "asm": "0 25f4b25e01695c795c19c9faae0984b17f370553",
          "desc": "addr(tex1qyh6tyhspd9w8jhqee8a2uzvyk9lnwp2n8ssur0)#d4ydyt2f",
          "hex": "001425f4b25e01695c795c19c9faae0984b17f370553",
          "address": "tex1qyh6tyhspd9w8jhqee8a2uzvyk9lnwp2n8ssur0",
          "type": "witness_v0_keyhash"
        }
      },
      "previous_txid": "905e43dfb58c9d7d02512b17f118e44205d773fa5c414a9f8899ffc24f399751",
      "previous_vout": 0,
      "sequence": 4294967294
    }
  ],
  "outputs": [
    {
      "amount": 0.00000800,
      "script": {
        "asm": "0 25f4b25e01695c795c19c9faae0984b17f370553",
        "desc": "addr(tex1qyh6tyhspd9w8jhqee8a2uzvyk9lnwp2n8ssur0)#d4ydyt2f",
        "hex": "001425f4b25e01695c795c19c9faae0984b17f370553",
        "address": "tex1qyh6tyhspd9w8jhqee8a2uzvyk9lnwp2n8ssur0",
        "type": "witness_v0_keyhash"
      },
      "asset": "144c654344aa716d6f3abcc1ca90e5641e4e2a7f633bc09fe3baf64585819a49",
      "blinder_index": 0
    },
    {
      "amount": 0.00000100,
      "script": {
        "asm": "",
        "desc": "raw()#58lrscpx",
        "hex": "",
        "type": "fee"
      },
      "asset": "144c654344aa716d6f3abcc1ca90e5641e4e2a7f633bc09fe3baf64585819a49"
    }
  ]
}

Without the "asset" field from the utxo data, a taproot signature cannot be made.

Other PSET style commands such as walletcreatefundedpsbt appear to have the same issue.

I'm not really sure how/if taproot PSET even works at all.

@roconnor-blockstream
Copy link
Contributor Author

cc @apoelstra

@apoelstra
Copy link
Member

This is super weird. I don't see anywhere in the code that the asset would be being dropped. In the source code for utxoupdatepsbt you can see input.witness_utxo = coin.out; which copies the whole output out of the mempool and into the PSBT. So how does the asset go missing? I don't know.

The wallet RPCs appear not to set input.witness_utxo at all, so that's a bug.

@roconnor-blockstream
Copy link
Contributor Author

I had an input.witness_utxo field why I tested walletcreatefundedpsbt.

@roconnor-blockstream
Copy link
Contributor Author

It could be decodepsbt that is actually broken, which would explain a lot.

@apoelstra
Copy link
Member

Ah... ok, de/serialization is done with SerializeToVector and DeserializeToVector which just pass to the consensus encoding of TxOut, which should include both the asset and the nonce. So that seems fine.

But the decodepsbt logic which converts to JSON explicitly pulls the amount, and not the asset or nonce, out of the output.

So this bug might merely be in the JSON display.

@roconnor-blockstream
Copy link
Contributor Author

nonce shouldn't be considered part of the utxo, so let's not pull that. It is loaded up with some random uninitialized memory sometimes. ... OTOH, if it is encoded in the PSET data, it should reflect that. Maybe we need another bug report: nonces in psbt utxo's are f'd up.

@apoelstra
Copy link
Member

Yeah -- I think we should probably change the serialization (and the spec) to define that they be nulled out.

Ideally the nonce ought to be there, but because of #1004 it's not practically possible. (See #1187 where Allen complained specifically that this results in nonces being f'd up in PSET.)

@roconnor-blockstream
Copy link
Contributor Author

So we already have #1187 for the nonce issue. We can make this the decodepsbt issue for not showing the asset field. And I see I accidentally set the title of this issue correctly.

@delta1 delta1 changed the title elements-cli decodepsbt doesn't set inputs.witness_tx.asset field elements-cli decodepsbt doesn't set inputs.witness_utxo.asset field Nov 1, 2024
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

Successfully merging a pull request may close this issue.

2 participants