Skip to content

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

Closed
@habibitcoin

Description

@habibitcoin

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    ✅ Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions