Merge #882: gui: use descriptor helper function to get unsigned tx max size
e373ad45d4ee33ae36636030a0c97ea9302d3514 gui: use helper for unsigned tx max size (jp1ac4) Pull request description: This is to resolve #880 using the new helper function from #881 to get the max possible size of the unsigned transaction. The following screenshot is taken using both new and old implementations together and shows the new estimated feerate changes from 0 to 1 sat/vbyte:  ACKs for top commit: darosior: ACK e373ad4 Tree-SHA512: b8d3aee84eaae8614db7dc4749fd86aa3df61bfa720bba0a978076f7a2c6e37a29ad8c8448e8bff16017438672ce1e681e2a916e2350c29c1fbac4aba5315d87
This commit is contained in:
commit
53fa0816a9
2
gui/Cargo.lock
generated
2
gui/Cargo.lock
generated
@ -2431,7 +2431,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "liana"
|
name = "liana"
|
||||||
version = "4.0.0"
|
version = "4.0.0"
|
||||||
source = "git+https://github.com/wizardsardine/liana?branch=master#87d1c55d2e5b6edc5cc2033759a6a936435b67b6"
|
source = "git+https://github.com/wizardsardine/liana?branch=master#dee069e72343a67607f4429125e4c80dc0d73055"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"backtrace",
|
"backtrace",
|
||||||
"bdk_coin_select",
|
"bdk_coin_select",
|
||||||
|
|||||||
@ -38,9 +38,9 @@ pub struct SpendTx {
|
|||||||
pub change_indexes: Vec<usize>,
|
pub change_indexes: Vec<usize>,
|
||||||
pub spend_amount: Amount,
|
pub spend_amount: Amount,
|
||||||
pub fee_amount: Option<Amount>,
|
pub fee_amount: Option<Amount>,
|
||||||
/// The maximum size difference (in virtual bytes) of
|
/// Maximum possible size of the unsigned transaction after satisfaction
|
||||||
/// an input in this transaction before and after satisfaction.
|
/// (assuming all inputs are for the same descriptor).
|
||||||
pub max_sat_vbytes: usize,
|
pub max_vbytes: u64,
|
||||||
pub status: SpendStatus,
|
pub status: SpendStatus,
|
||||||
pub sigs: PartialSpendInfo,
|
pub sigs: PartialSpendInfo,
|
||||||
pub updated_at: Option<u32>,
|
pub updated_at: Option<u32>,
|
||||||
@ -63,7 +63,7 @@ impl SpendTx {
|
|||||||
desc: &LianaDescriptor,
|
desc: &LianaDescriptor,
|
||||||
network: Network,
|
network: Network,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let max_sat_vbytes = desc.max_sat_vbytes();
|
let max_vbytes = desc.unsigned_tx_max_vbytes(&psbt.unsigned_tx);
|
||||||
let mut change_indexes = Vec::new();
|
let mut change_indexes = Vec::new();
|
||||||
let (change_amount, spend_amount) = psbt.unsigned_tx.output.iter().enumerate().fold(
|
let (change_amount, spend_amount) = psbt.unsigned_tx.output.iter().enumerate().fold(
|
||||||
(Amount::from_sat(0), Amount::from_sat(0)),
|
(Amount::from_sat(0), Amount::from_sat(0)),
|
||||||
@ -167,7 +167,7 @@ impl SpendTx {
|
|||||||
change_indexes,
|
change_indexes,
|
||||||
spend_amount,
|
spend_amount,
|
||||||
fee_amount: inputs_amount.and_then(|a| a.checked_sub(spend_amount + change_amount)),
|
fee_amount: inputs_amount.and_then(|a| a.checked_sub(spend_amount + change_amount)),
|
||||||
max_sat_vbytes,
|
max_vbytes,
|
||||||
status,
|
status,
|
||||||
sigs,
|
sigs,
|
||||||
network,
|
network,
|
||||||
@ -203,10 +203,11 @@ impl SpendTx {
|
|||||||
|
|
||||||
/// Feerate obtained if all transaction inputs have the maximum satisfaction size.
|
/// Feerate obtained if all transaction inputs have the maximum satisfaction size.
|
||||||
pub fn min_feerate_vb(&self) -> Option<u64> {
|
pub fn min_feerate_vb(&self) -> Option<u64> {
|
||||||
// This assumes all inputs are internal (have same max satisfaction size).
|
self.fee_amount.map(|a| {
|
||||||
let max_tx_vbytes =
|
a.to_sat()
|
||||||
self.psbt.unsigned_tx.vsize() + (self.max_sat_vbytes * self.psbt.inputs.len());
|
.checked_div(self.max_vbytes)
|
||||||
self.fee_amount.map(|a| a.to_sat() / max_tx_vbytes as u64)
|
.expect("a descriptor's satisfaction size is never 0")
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_send_to_self(&self) -> bool {
|
pub fn is_send_to_self(&self) -> bool {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user