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

experimental utxos selection issues #342

Open
HinsonSIDAN opened this issue Oct 19, 2024 · 3 comments
Open

experimental utxos selection issues #342

HinsonSIDAN opened this issue Oct 19, 2024 · 3 comments
Assignees

Comments

@HinsonSIDAN
Copy link
Member

Describe the bug

Wallet got utxos containing necessary value & token, but failed to select

[
    {
        "input": {
            "outputIndex": 56,
            "txHash": "5357731ff8aaacadb4834c87ab5048d1205ede5c9dbd6e24ebd1023713d54a28"
        },
        "output": {
            "address": "addr_test1qqzgg5pcaeyea69uptl9da5g7fajm4m0yvxndx9f4lxpkehqgezy0s04rtdwlc0tlvxafpdrfxnsg7ww68ge3j7l0lnszsw2wt",
            "amount": [
                {
                    "unit": "lovelace",
                    "quantity": "4135865608"
                },
                {
                    "unit": "5066154a102ee037390c5236f78db23239b49c5748d3d349f3ccf04b55534458",
                    "quantity": "8000000000"
                }
            ]
        }
    },
    {
        "input": {
            "outputIndex": 4,
            "txHash": "24b018ae80021a3bcedcf46cb9ac9979ed51906a5be37597a2f7923db20139c2"
        },
        "output": {
            "address": "addr_test1qqzgg5pcaeyea69uptl9da5g7fajm4m0yvxndx9f4lxpkehqgezy0s04rtdwlc0tlvxafpdrfxnsg7ww68ge3j7l0lnszsw2wt",
            "amount": [
                {
                    "unit": "lovelace",
                    "quantity": "16102666"
                }
            ]
        }
    },
    {
        "input": {
            "outputIndex": 11,
            "txHash": "d0b1c3a1165eecd5273409062a1efdf28f56061829fc665cf762750998cca0df"
        },
        "output": {
            "address": "addr_test1qqzgg5pcaeyea69uptl9da5g7fajm4m0yvxndx9f4lxpkehqgezy0s04rtdwlc0tlvxafpdrfxnsg7ww68ge3j7l0lnszsw2wt",
            "amount": [
                {
                    "unit": "lovelace",
                    "quantity": "7722658"
                }
            ]
        }
    },
    {
        "input": {
            "outputIndex": 1,
            "txHash": "fb16ad965811e400d039f5c7ebb5acd70512e221e0abc8eb85770f2df399ea29"
        },
        "output": {
            "address": "addr_test1qqzgg5pcaeyea69uptl9da5g7fajm4m0yvxndx9f4lxpkehqgezy0s04rtdwlc0tlvxafpdrfxnsg7ww68ge3j7l0lnszsw2wt",
            "amount": [
                {
                    "unit": "lovelace",
                    "quantity": "2873215"
                }
            ]
        }
    },
    {
        "input": {
            "outputIndex": 1,
            "txHash": "398a5993db18da4eb8485703f9f9d6a681304cbe0d2b3ad3a5f7035684e67129"
        },
        "output": {
            "address": "addr_test1qqzgg5pcaeyea69uptl9da5g7fajm4m0yvxndx9f4lxpkehqgezy0s04rtdwlc0tlvxafpdrfxnsg7ww68ge3j7l0lnszsw2wt",
            "amount": [
                {
                    "unit": "lovelace",
                    "quantity": "14594553"
                },
                {
                    "unit": "a103a8efea8fa65b2799c841be990520e051a46f584154cdb43b0d346d65736820283029",
                    "quantity": "1"
                }
            ]
        }
    },
    {
        "input": {
            "outputIndex": 0,
            "txHash": "b1b145db3b1c577a44a885a53720c22509598035ddc2dd9a1eb6633bcd0861b4"
        },
        "output": {
            "address": "addr_test1qqzgg5pcaeyea69uptl9da5g7fajm4m0yvxndx9f4lxpkehqgezy0s04rtdwlc0tlvxafpdrfxnsg7ww68ge3j7l0lnszsw2wt",
            "amount": [
                {
                    "unit": "lovelace",
                    "quantity": "2369921413"
                },
                {
                    "unit": "740de29e6df5871d2203a25c9690d957fae861dd3791c1acbdc91146",
                    "quantity": "1"
                },
                {
                    "unit": "f060f0ef7fa4c3c6d3a4f831c639038db0f625c548a711f2b276a282",
                    "quantity": "2"
                }
            ]
        }
    }
]

To Reproduce

With above utxos, select:

{
    "unit": "740de29e6df5871d2203a25c9690d957fae861dd3791c1acbdc91146",
    "quantity": "1"
},
@HinsonSIDAN
Copy link
Member Author

One possible reason / edge case is that when we rely on auto min-utxo calculation, the output value is not considered at selection. E.g.

 sendRefScriptOnchain = async (scriptIndex: ScriptIndex) => {
    const { utxos, walletAddress } = await this.getWalletInfoForTx();
    const { scriptAddress } = this.getOwnerNativeScript();
    const txHex = await this.mesh
      .txOut(scriptAddress, []) // minutxo ada for this output is not considered
      .txOutReferenceScript(getScriptCbor(this.paramUtxo, scriptIndex))
      .changeAddress(walletAddress)
      .selectUtxosFrom(utxos, 'experimental')
      .complete();
    return txHex;
  };

Maybe we needa implement / integrate min utxo calculation at TS level to solve the issue

@HinsonSIDAN
Copy link
Member Author

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

No branches or pull requests

2 participants