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

adjust_for_fee does not filter already used inputs #1314

Open
hal3e opened this issue Mar 28, 2024 · 0 comments
Open

adjust_for_fee does not filter already used inputs #1314

hal3e opened this issue Mar 28, 2024 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@hal3e
Copy link
Contributor

hal3e commented Mar 28, 2024

While working on #1313 I found a bug in the adjust_for_fee method. When adjusting the fee, we do not take into consideration coins/messages that were already added to the TransactionBuilder. After calculating the missing base amount, we just request the amount from the provider and we can get back a coin that is already in our inputs leading to duplicate utxos. Minimal test rerpo:

#[tokio::test]
async fn test_transfer2() -> Result<()> {
    let mut wallet_1 = WalletUnlocked::new_random(None);

    let base_asset_id = AssetId::default();
    let coins = setup_single_asset_coins(wallet_1.address(), base_asset_id, 1, 3);

    let provider = setup_test_provider(coins, vec![], None, None).await?;

    wallet_1.set_provider(provider);

    wallet_1
        .transfer(
            &Bech32Address::default(),
            3,
            AssetId::default(),
            TxPolicies::default().with_tip(1),
        )
        .await?;

    Ok(())
}
@hal3e hal3e added the bug Something isn't working label Mar 28, 2024
@segfault-magnet segfault-magnet self-assigned this May 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants