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

[bug/feature]: Implement PrevId[] UTXO selection for FundVirtualPSBT RPC method #1164

Open
habibitcoin opened this issue Oct 30, 2024 · 1 comment
Labels
bug Something isn't working needs triage

Comments

@habibitcoin
Copy link
Contributor

habibitcoin commented Oct 30, 2024

Background

When operating a pocket universe, an operator may want to assist users in funding a PSBT to fulfill a Taproot Asset address transfer. In the case of Tajfi, we do this by taking the user's public key and then searching for UTXOs we control that have a script key matching the user, and then including an array of user-controlled-UTXOs that match, or exceed, the decoded amount of the Taproot Asset address invoice to fulfill.

Currently, we cannot provide the PrevId because the RPC method is not yet implemented, but it does seem that future support was already planned: https://github.com/lightninglabs/taproot-assets/blob/main/rpcserver.go#L2065

case req.GetRaw() != nil:
		raw := req.GetRaw()
		if len(raw.Inputs) > 0 {
			return nil, fmt.Errorf("template inputs not yet " +
				"supported")
		}

So I'd say this is kinda inbetween a bug and feature request. I think this would probably be a great beginner user task, and I'll probably take a stab at it soon.

Your environment

Using tapd v0.4.1. Although probably not relevant since as mentioned above, this behavior/error path seems to be expected regardless of path.

Steps to reproduce

This should be reproducible by sending a valid RPC payload for FundVirtualPSBT. An example of this payload for the HTTP request is provided below:

{
  "raw": {
    "recipients": {
      "tapabcxyz": 0 
    },
    "inputs": [
      {
        "outpoint": {
          "txid": "da742200b442ab7d6b8d5e39c2b1203f74b1ff3fcb5237d0418771b960e5243f",
          "output_index": 1
        },
        "id": "0a17de7503cc844f3a4fbf964af818266cd5f8369b2927971e8bafd62d897fdf",
        "script_key": "02d4d18c8f36edad6f3fba2407ac4a8b5d9416071febac4016adeeff8dd862e83a"
      }
    ]
  }
}

Removing the inputs object will allow the call to continue, but can result in a problem where the UTXOs selected might not have the desired script_key the pocket universe user intends on using to fulfill their transfer.

Expected behavior

The daemon should attempt to only fund the virtual PSBT using the inputs provided in the raw payload.

@habibitcoin
Copy link
Contributor Author

Gave a stab at this in #1172 and have something that has at least unblocked our internal testing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs triage
Projects
Status: 🆕 New
Development

No branches or pull requests

1 participant