Skip to content

Commit

Permalink
Merge #743: gui: coinbase transaction output scripts may not represen…
Browse files Browse the repository at this point in the history
…t valid addresses

2f2975c coinbase transaction outputs may not have valid scripts (edouard)

Pull request description:

  close #738
  liana-gui v2 also tried to display addresses from transaction outputs to user when clicking on transaction detail.

ACKs for top commit:
  edouardparis:
    Self-ACK 2f2975c

Tree-SHA512: 7f5fc374baec773fef848cd104b8acbd34ce19a04f9614d0c446a93ee8b6b976acd98d7494031651a614bef38c0913217865f2086bf19a018ce17f57ef362c57
  • Loading branch information
edouardparis committed Oct 24, 2023
2 parents 4257860 + 2f2975c commit ec2e2e5
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 18 deletions.
17 changes: 7 additions & 10 deletions gui/src/app/view/home.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,17 +158,14 @@ fn event_list_view(i: usize, event: &HistoryTransaction) -> Column<'_, Message>
.to_string(),
) {
Some(p1_regular(label))
} else if let Ok(addr) =
bitcoin::Address::from_script(&output.script_pubkey, event.network)
{
event.labels.get(&addr.to_string()).map(|label| {
p1_regular(format!("address label: {}", label)).style(color::GREY_3)
})
} else {
event
.labels
.get(
&bitcoin::Address::from_script(&output.script_pubkey, event.network)
.unwrap()
.to_string(),
)
.map(|label| {
p1_regular(format!("address label: {}", label)).style(color::GREY_3)
})
None
};
if event.is_external() {
if !event.change_indexes.contains(&output_index) {
Expand Down
10 changes: 5 additions & 5 deletions gui/src/app/view/psbt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -820,8 +820,8 @@ fn payment_view<'a>(
labels_editing: &'a HashMap<String, form::Value<String>>,
) -> Element<'a, Message> {
let addr = Address::from_script(&output.script_pubkey, network)
.unwrap()
.to_string();
.ok()
.map(|a| a.to_string());
let outpoint = OutPoint {
txid,
vout: i as u32,
Expand All @@ -848,7 +848,7 @@ fn payment_view<'a>(
)
.push(amount(&Amount::from_sat(output.value))),
)
.push(
.push_maybe(addr.map(|addr| {
Column::new()
.push(
Row::new()
Expand Down Expand Up @@ -880,8 +880,8 @@ fn payment_view<'a>(
.push(p1_bold("Address label:").style(color::GREY_3))
.push(p2_regular(label).style(color::GREY_3)),
)
})),
)
}))
}))
.into()
}

Expand Down
6 changes: 3 additions & 3 deletions gui/src/daemon/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -365,9 +365,9 @@ impl Labelled for HistoryTransaction {
txid,
vout: vout as u32,
}));
items.push(LabelItem::Address(
Address::from_script(&output.script_pubkey, self.network).unwrap(),
));
if let Ok(addr) = Address::from_script(&output.script_pubkey, self.network) {
items.push(LabelItem::Address(addr));
}
}
items
}
Expand Down

0 comments on commit ec2e2e5

Please sign in to comment.