Skip to content

TxOrdering::Untouched no longer ensures the order of tx input #244

Open
@eauxxs

Description

@eauxxs

Describe the bug
Since add_utxo of build_tx in 1.2.0 uses hashmap to contain input, TxOrdrering cannot ensure that the order is not changed.

To Reproduce

    let utxos = wallet1
        .list_unspent()
        .map(|o| o.outpoint)
        .collect::<Vec<_>>();
    let builder = wallet1.build_tx();
    builder
        .ordering(bdk_wallet::TxOrdering::Untouched)
        .fee_rate(FeeRate::from_sat_per_vb(5).unwrap())
        .add_utxo(utxos[0])
        .unwrap()
        .add_utxo(utxos[1])
        .unwrap()
        .add_recipient(
            wallet1.peek_address(External, 0).address.script_pubkey(),
            bitcoin::Amount::from_sat(1000),
        );

    let inputs = builder.finish().unwrap().unsigned_tx.input;
    // can't assert
    assert!(inputs[0].previous_output == utxos[0]);
    assert!(inputs[1].previous_output == utxos[1]);

Expected behavior

    assert!(inputs[0].previous_output == utxos[0]);
    assert!(inputs[1].previous_output == utxos[1]);

Build environment

  • BDK tag/commit: 1.2.0
  • OS+version:
  • Rust/Cargo version: *
  • Rust/Cargo target: *

Additional context

pub(crate) utxos: HashMap<OutPoint, WeightedUtxo>,

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    Status

    In Progress

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions