Skip to content

Commit

Permalink
Clamp payjoin fee if recommendation unavailable (#272)
Browse files Browse the repository at this point in the history
  • Loading branch information
DanGould authored Jul 17, 2023
1 parent 92e00d9 commit 7a67fae
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/bitcoin/payment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,11 @@ pub async fn create_payjoin(
let recommended_fee = Amount::from_sat(enacted_fee_rate.fee_wu(P2TR_INPUT_WEIGHT));
let max_additional_fee = std::cmp::min(
recommended_fee,
amount_available, // offer amount available if recommendation is not
amount_available, // "clamp" to amount available if recommendation is not
);

Configuration::with_fee_contribution(max_additional_fee, Some(index))
.clamp_fee_contribution(true);

Check failure on line 98 in src/bitcoin/payment.rs

View workflow job for this annotation

GitHub Actions / lint

error[E0308]: `match` arms have incompatible types --> src/bitcoin/payment.rs:100:17 | 81 | let pj_params = match additional_fee_index { | -------------------------- `match` arms have incompatible types ... 97 | / Configuration::with_fee_contribution(max_additional_fee, Some(index)) 98 | | .clamp_fee_contribution(true); | | - | | | | |______________________________________________help: consider removing this semicolon | this is found to be of type `()` 99 | } 100 | None => Configuration::non_incentivizing(), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found `Configuration`

Check failure on line 98 in src/bitcoin/payment.rs

View workflow job for this annotation

GitHub Actions / lint-wasm

error[E0308]: `match` arms have incompatible types --> src/bitcoin/payment.rs:100:17 | 81 | let pj_params = match additional_fee_index { | -------------------------- `match` arms have incompatible types ... 97 | / Configuration::with_fee_contribution(max_additional_fee, Some(index)) 98 | | .clamp_fee_contribution(true); | | - | | | | |______________________________________________help: consider removing this semicolon | this is found to be of type `()` 99 | } 100 | None => Configuration::non_incentivizing(), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found `Configuration`

Check failure on line 98 in src/bitcoin/payment.rs

View workflow job for this annotation

GitHub Actions / lint

error[E0308]: `match` arms have incompatible types --> src/bitcoin/payment.rs:100:17 | 81 | let pj_params = match additional_fee_index { | -------------------------- `match` arms have incompatible types ... 97 | / Configuration::with_fee_contribution(max_additional_fee, Some(index)) 98 | | .clamp_fee_contribution(true); | | - | | | | |______________________________________________help: consider removing this semicolon | this is found to be of type `()` 99 | } 100 | None => Configuration::non_incentivizing(), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found `Configuration`

Check failure on line 98 in src/bitcoin/payment.rs

View workflow job for this annotation

GitHub Actions / lint-wasm

error[E0308]: `match` arms have incompatible types --> src/bitcoin/payment.rs:100:17 | 81 | let pj_params = match additional_fee_index { | -------------------------- `match` arms have incompatible types ... 97 | / Configuration::with_fee_contribution(max_additional_fee, Some(index)) 98 | | .clamp_fee_contribution(true); | | - | | | | |______________________________________________help: consider removing this semicolon | this is found to be of type `()` 99 | } 100 | None => Configuration::non_incentivizing(), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found `Configuration`
}
None => Configuration::non_incentivizing(),

Check failure on line 100 in src/bitcoin/payment.rs

View workflow job for this annotation

GitHub Actions / lint

error[E0308]: `match` arms have incompatible types --> src/bitcoin/payment.rs:100:17 | 81 | let pj_params = match additional_fee_index { | -------------------------- `match` arms have incompatible types ... 97 | / Configuration::with_fee_contribution(max_additional_fee, Some(index)) 98 | | .clamp_fee_contribution(true); | | - | | | | |______________________________________________help: consider removing this semicolon | this is found to be of type `()` 99 | } 100 | None => Configuration::non_incentivizing(), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found `Configuration`

Check failure on line 100 in src/bitcoin/payment.rs

View workflow job for this annotation

GitHub Actions / lint-wasm

error[E0308]: `match` arms have incompatible types --> src/bitcoin/payment.rs:100:17 | 81 | let pj_params = match additional_fee_index { | -------------------------- `match` arms have incompatible types ... 97 | / Configuration::with_fee_contribution(max_additional_fee, Some(index)) 98 | | .clamp_fee_contribution(true); | | - | | | | |______________________________________________help: consider removing this semicolon | this is found to be of type `()` 99 | } 100 | None => Configuration::non_incentivizing(), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found `Configuration`

Check failure on line 100 in src/bitcoin/payment.rs

View workflow job for this annotation

GitHub Actions / lint

error[E0308]: `match` arms have incompatible types --> src/bitcoin/payment.rs:100:17 | 81 | let pj_params = match additional_fee_index { | -------------------------- `match` arms have incompatible types ... 97 | / Configuration::with_fee_contribution(max_additional_fee, Some(index)) 98 | | .clamp_fee_contribution(true); | | - | | | | |______________________________________________help: consider removing this semicolon | this is found to be of type `()` 99 | } 100 | None => Configuration::non_incentivizing(), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found `Configuration`

Check failure on line 100 in src/bitcoin/payment.rs

View workflow job for this annotation

GitHub Actions / lint-wasm

error[E0308]: `match` arms have incompatible types --> src/bitcoin/payment.rs:100:17 | 81 | let pj_params = match additional_fee_index { | -------------------------- `match` arms have incompatible types ... 97 | / Configuration::with_fee_contribution(max_additional_fee, Some(index)) 98 | | .clamp_fee_contribution(true); | | - | | | | |______________________________________________help: consider removing this semicolon | this is found to be of type `()` 99 | } 100 | None => Configuration::non_incentivizing(), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found `Configuration`
};
Expand Down

0 comments on commit 7a67fae

Please sign in to comment.