Skip to content

Commit

Permalink
Change feerate to 1 sat/vbyte (#664)
Browse files Browse the repository at this point in the history
  • Loading branch information
raphjaph authored Oct 17, 2022
1 parent 67acc50 commit 40119b7
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/subcommand/wallet/transaction_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ type Result<T> = std::result::Result<T, Error>;
impl TransactionBuilder {
const TARGET_POSTAGE: u64 = 10_000;
const MAX_POSTAGE: u64 = 2 * Self::TARGET_POSTAGE;
const FEE_RATE: usize = 1;

pub(crate) fn build_transaction(
ranges: BTreeMap<OutPoint, Vec<(u64, u64)>>,
Expand Down Expand Up @@ -122,7 +123,7 @@ impl TransactionBuilder {
let ordinal_offset = self.calculate_ordinal_offset();

let tx = self.build()?;
let fee = Amount::from_sat((2 * tx.vsize()).try_into().unwrap());
let fee = Amount::from_sat((Self::FEE_RATE * tx.vsize()).try_into().unwrap());

let output_amount = self
.outputs
Expand Down Expand Up @@ -467,7 +468,7 @@ mod tests {
witness: Witness::new(),
},],
output: vec![TxOut {
value: 5000 - 164,
value: 5000 - 82,
script_pubkey: "tb1q6en7qjxgw4ev8xwx94pzdry6a6ky7wlfeqzunz"
.parse::<Address>()
.unwrap()
Expand All @@ -489,15 +490,15 @@ mod tests {
pretty_assert_eq!(
TransactionBuilder::build_transaction(
utxos.into_iter().collect(),
Ordinal(14900),
Ordinal(14950),
"tb1q6en7qjxgw4ev8xwx94pzdry6a6ky7wlfeqzunz"
.parse()
.unwrap(),
"tb1qjsv26lap3ffssj6hfy8mzn0lg5vte6a42j75ww"
.parse()
.unwrap(),
),
Err(Error::ConsumedByFee(Ordinal(14900)))
Err(Error::ConsumedByFee(Ordinal(14950)))
)
}

Expand Down Expand Up @@ -647,7 +648,7 @@ mod tests {
.script_pubkey(),
},
TxOut {
value: 1_000_000 - TransactionBuilder::TARGET_POSTAGE - 226,
value: 1_000_000 - TransactionBuilder::TARGET_POSTAGE - 113,
script_pubkey: "tb1qjsv26lap3ffssj6hfy8mzn0lg5vte6a42j75ww"
.parse::<Address>()
.unwrap()
Expand Down

0 comments on commit 40119b7

Please sign in to comment.