Skip to content

Commit

Permalink
Revert "fix: transaction fee calcs"
Browse files Browse the repository at this point in the history
This reverts commit 4660214.
  • Loading branch information
veeso committed Jul 26, 2024
1 parent 4660214 commit a828ed3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
5 changes: 0 additions & 5 deletions src/utils/fees.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,6 @@ pub fn estimate_transaction_fees(
current_fee_rate.fee_vb(vbytes as u64).unwrap()
}

pub fn calculate_transaction_fees(transaction: &Transaction, current_fee_rate: FeeRate) -> Amount {
let vbytes = transaction.vsize();
current_fee_rate.fee_vb(vbytes as u64).unwrap()
}

fn estimate_vbytes(
inputs: usize,
script_type: ScriptType,
Expand Down
13 changes: 10 additions & 3 deletions src/wallet/builder/rune.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ use bitcoin::transaction::Version;
use bitcoin::{Address, Amount, FeeRate, ScriptBuf, Transaction, TxIn, TxOut};
use ordinals::{Edict, Etching, RuneId, Runestone as OrdRunestone};

use crate::fees::calculate_transaction_fees;
use crate::fees::estimate_transaction_fees;
use crate::wallet::builder::TxInputInfo;
use crate::wallet::ScriptType;
use crate::{OrdError, OrdTransactionBuilder};

/// Postage amount for rune transaction.
Expand Down Expand Up @@ -128,7 +129,13 @@ impl OrdTransactionBuilder {
output: outputs,
};

let fee_amount = calculate_transaction_fees(&unsigned_tx, args.fee_rate);
let fee_amount = estimate_transaction_fees(
ScriptType::P2TR,
unsigned_tx.input.len(),
args.fee_rate,
&None,
unsigned_tx.output.clone(),
);
let change_amount = args
.input_amount()
.checked_sub(fee_amount + RUNE_POSTAGE * 2)
Expand All @@ -154,7 +161,7 @@ mod tests {
use bitcoin::{Network, OutPoint, PrivateKey, PublicKey, Txid};

use super::*;
use crate::wallet::{LocalSigner, ScriptType};
use crate::wallet::LocalSigner;
use crate::Wallet;

#[tokio::test]
Expand Down

0 comments on commit a828ed3

Please sign in to comment.