secretkeylabs / xverse-web-extension

Other
40 stars 19 forks source link

Support signing psbt with bare multi-sig outputs in SRC20 #825

Open btcopenstamp opened 1 month ago

btcopenstamp commented 1 month ago

OpenStamp(https://openstamp.io/) is a comprehensive service platform for the BTC Stamps ecosystem. We are attempting to integrate the Xverse(v0.36.2 beta) wallet, but it seems that Xverse currently cannot sign SRC20 transactions. This might be because SRC20 transaction outputs include Bare Multi-Sig outputs. We hope Xverse can support such transactions so that users of the SRC20 ecosystem can effectively use the Xverse wallet.

Below is a PSBT containing a Bare Multi-Sig output: psbtBase64 = cHNidP8BAO8CAAAAAf3fctYo7PyLy262lTJjcbZfXf+PqCRHiN8G1HEJaM5tAAAAAAD9////AyMCAAAAAAAAFgAUSYgc4ve1a2mEBLnS+OqS8KShxo+ZKAAAAAAAACJRIGu93ifnTUKUsRHKlNflgLZFIL/s2nEXvFJJcZ89hiVMHAMAAAAAAABpUSECn1xRsZa4LLhK+Gp0xaMd2r81qJbqkbv9hgSaDk7bj98hAtfbIeeBPG1XWKkFvg929MVdqouJJOZykS/CjzQ87vJlIQICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAlOuAAAAAAABASuTVAAAAAAAACJRIGu93ifnTUKUsRHKlNflgLZFIL/s2nEXvFJJcZ89hiVMARcgw5kZwPX7LlUMooqWqjdRw4TMMrQBJvFI9N0iy88kPioAAAAA

{
    "result": {
        "tx": {
            "txid": "026abf33b02b2d6d04478cad907095581ab75d7ed3af4a9ffcc638212a58d8d9",
            "hash": "026abf33b02b2d6d04478cad907095581ab75d7ed3af4a9ffcc638212a58d8d9",
            "version": 2,
            "size": 239,
            "vsize": 239,
            "weight": 956,
            "locktime": 0,
            "vin": [
                {
                    "txid": "6dce680971d406df884724a88fff5d5fb671633295b66ecb8bfcec28d672dffd",
                    "vout": 0,
                    "scriptSig": {
                        "asm": "",
                        "hex": ""
                    },
                    "sequence": 4294967293
                }
            ],
            "vout": [
                {
                    "value": 0.00000547,
                    "n": 0,
                    "scriptPubKey": {
                        "asm": "0 49881ce2f7b56b698404b9d2f8ea92f0a4a1c68f",
                        "desc": "addr(bc1qfxypechhk44knpqyh8f0365j7zj2r350z4uaqk)#pgfd8gfx",
                        "hex": "001449881ce2f7b56b698404b9d2f8ea92f0a4a1c68f",
                        "address": "bc1qfxypechhk44knpqyh8f0365j7zj2r350z4uaqk",
                        "type": "witness_v0_keyhash"
                    }
                },
                {
                    "value": 0.00010393,
                    "n": 1,
                    "scriptPubKey": {
                        "asm": "1 6bbdde27e74d4294b111ca94d7e580b64520bfecda7117bc5249719f3d86254c",
                        "desc": "rawtr(6bbdde27e74d4294b111ca94d7e580b64520bfecda7117bc5249719f3d86254c)#aszgy9vn",
                        "hex": "51206bbdde27e74d4294b111ca94d7e580b64520bfecda7117bc5249719f3d86254c",
                        "address": "bc1pdw7aufl8f4pffvg3e22d0evqkezjp0lvmfc300zjf9ce70vxy4xqu408zu",
                        "type": "witness_v1_taproot"
                    }
                },
                {
                    "value": 0.00000796,
                    "n": 2,
                    "scriptPubKey": {
                        "asm": "1 029f5c51b196b82cb84af86a74c5a31ddabf35a896ea91bbfd86049a0e4edb8fdf 02d7db21e7813c6d5758a905be0f76f4c55daa8b8924e672912fc28f343ceef265 020202020202020202020202020202020202020202020202020202020202020202 3 OP_CHECKMULTISIG",
                        "desc": "multi(1,029f5c51b196b82cb84af86a74c5a31ddabf35a896ea91bbfd86049a0e4edb8fdf,02d7db21e7813c6d5758a905be0f76f4c55daa8b8924e672912fc28f343ceef265,020202020202020202020202020202020202020202020202020202020202020202)#8us7xp6u",
                        "hex": "5121029f5c51b196b82cb84af86a74c5a31ddabf35a896ea91bbfd86049a0e4edb8fdf2102d7db21e7813c6d5758a905be0f76f4c55daa8b8924e672912fc28f343ceef2652102020202020202020202020202020202020202020202020202020202020202020253ae",
                        "type": "multisig"
                    }
                }
            ]
        },
        "global_xpubs": [],
        "psbt_version": 0,
        "proprietary": [],
        "unknown": {},
        "inputs": [
            {
                "witness_utxo": {
                    "amount": 0.00021651,
                    "scriptPubKey": {
                        "asm": "1 6bbdde27e74d4294b111ca94d7e580b64520bfecda7117bc5249719f3d86254c",
                        "desc": "rawtr(6bbdde27e74d4294b111ca94d7e580b64520bfecda7117bc5249719f3d86254c)#aszgy9vn",
                        "hex": "51206bbdde27e74d4294b111ca94d7e580b64520bfecda7117bc5249719f3d86254c",
                        "address": "bc1pdw7aufl8f4pffvg3e22d0evqkezjp0lvmfc300zjf9ce70vxy4xqu408zu",
                        "type": "witness_v1_taproot"
                    }
                },
                "taproot_internal_key": "c39919c0f5fb2e550ca28a96aa3751c384cc32b40126f148f4dd22cbcf243e2a"
            }
        ],
        "outputs": [
            {},
            {},
            {}
        ],
        "fee": 0.00009915
    },
    "error": null,
    "id": null
}

Here is the code used to sign:

const response = await request('signPsbt', {
  psbt: psbtBase64,
  signInputs: {
    ["bc1pdw7aufl8f4pffvg3e22d0evqkezjp0lvmfc300zjf9ce70vxy4xqu408zu"]: [0],
  },
});

Then it shows the following error message and the error code is -32603 image

Please help confirm this issue. We believe the entire BTC Stamps ecosystem is eager to receive support from Xverse. Thank you.

teebszet commented 3 weeks ago

@btcopenstamp thanks for the report! I believe @victorkirov is looking into this, and we will have a fix for parsing bare multisig outputs soon

btcopenstamp commented 3 weeks ago

@btcopenstamp thanks for the report! I believe @victorkirov is looking into this, and we will have a fix for parsing bare multisig outputs soon

@teebszet Appreciate the quick response. @victorkirov Please feel free to comment if you have any questions. Thanks.

victorkirov commented 3 weeks ago

@btcopenstamp All good 👍 PR is open and will hopefully make it into the next release. Thanks for pointing this out 🙌

btcopenstamp commented 3 weeks ago

@btcopenstamp All good 👍 PR is open and will hopefully make it into the next release. Thanks for pointing this out 🙌

That's awesome. Appreciate your work.👍