lnp/channel/shared_ext/
bip96.rs1use lnp2p::bolt::Messages;
15use wallet::lex_order::LexOrder;
16
17use crate::channel::bolt::{BoltExt, ChannelState, Error};
18use crate::channel::tx_graph::TxGraph;
19use crate::{channel, extension, ChannelExtension, Extension};
20
21#[derive(Debug, Default)]
22pub struct Bip96;
23
24impl Extension<BoltExt> for Bip96 {
25 #[inline]
26 fn identity(&self) -> BoltExt {
27 BoltExt::Bip96
28 }
29
30 fn update_from_local(&mut self, _message: &()) -> Result<(), Error> {
31 Ok(())
33 }
34
35 #[inline]
36 fn update_from_peer(&mut self, _: &Messages) -> Result<(), Error> {
37 Ok(())
41 }
42
43 fn load_state(&mut self, _state: &ChannelState) {
44 }
46
47 fn store_state(&self, _state: &mut ChannelState) {
48 }
50}
51
52impl<N> ChannelExtension<N> for Bip96
53where
54 Self: Extension<N>,
55 N: channel::Nomenclature,
56 N::State: channel::State,
57{
58 #[inline]
59 fn new() -> Box<dyn ChannelExtension<N>>
60 where
61 Self: Sized,
62 {
63 Box::new(Bip96::default())
64 }
65
66 #[inline]
67 fn build_graph(
68 &self,
69 tx_graph: &mut TxGraph,
70 _as_remote_node: bool,
71 ) -> Result<(), <N as extension::Nomenclature>::Error> {
72 tx_graph.cmt_outs.lex_order();
73 tx_graph
74 .vec_mut()
75 .into_iter()
76 .for_each(|(_, _, tx)| tx.lex_order());
77 Ok(())
78 }
79}