@@ -12,29 +12,29 @@ use crate::sign::SpendableOutputDescriptor;
12
12
13
13
use bitcoin:: transaction:: Transaction ;
14
14
15
- use crate :: routing:: router:: Route ;
16
15
use crate :: ln:: chan_utils:: HTLCClaim ;
16
+ use crate :: routing:: router:: Route ;
17
17
18
18
macro_rules! log_iter {
19
19
( $obj: expr) => {
20
20
$crate:: util:: logger:: DebugIter ( $obj)
21
- }
21
+ } ;
22
22
}
23
23
24
24
/// Logs a pubkey in hex format.
25
25
#[ macro_export]
26
26
macro_rules! log_pubkey {
27
27
( $obj: expr) => {
28
28
$crate:: util:: logger:: DebugPubKey ( & $obj)
29
- }
29
+ } ;
30
30
}
31
31
32
32
/// Logs a byte slice in hex format.
33
33
#[ macro_export]
34
34
macro_rules! log_bytes {
35
35
( $obj: expr) => {
36
36
$crate:: util:: logger:: DebugBytes ( & $obj)
37
- }
37
+ } ;
38
38
}
39
39
40
40
pub ( crate ) struct DebugFundingInfo < ' a > ( pub & ' a ChannelId ) ;
@@ -45,10 +45,8 @@ impl<'a> core::fmt::Display for DebugFundingInfo<'a> {
45
45
}
46
46
macro_rules! log_funding_info {
47
47
( $key_storage: expr) => {
48
- $crate:: util:: macro_logger:: DebugFundingInfo (
49
- & $key_storage. channel_id( )
50
- )
51
- }
48
+ $crate:: util:: macro_logger:: DebugFundingInfo ( & $key_storage. channel_id( ) )
49
+ } ;
52
50
}
53
51
54
52
pub ( crate ) struct DebugRoute < ' a > ( pub & ' a Route ) ;
@@ -57,7 +55,14 @@ impl<'a> core::fmt::Display for DebugRoute<'a> {
57
55
for ( idx, p) in self . 0 . paths . iter ( ) . enumerate ( ) {
58
56
writeln ! ( f, "path {}:" , idx) ?;
59
57
for h in p. hops . iter ( ) {
60
- writeln ! ( f, " node_id: {}, short_channel_id: {}, fee_msat: {}, cltv_expiry_delta: {}" , log_pubkey!( h. pubkey) , h. short_channel_id, h. fee_msat, h. cltv_expiry_delta) ?;
58
+ writeln ! (
59
+ f,
60
+ " node_id: {}, short_channel_id: {}, fee_msat: {}, cltv_expiry_delta: {}" ,
61
+ log_pubkey!( h. pubkey) ,
62
+ h. short_channel_id,
63
+ h. fee_msat,
64
+ h. cltv_expiry_delta
65
+ ) ?;
61
66
}
62
67
writeln ! ( f, " blinded_tail: {:?}" , p. blinded_tail) ?;
63
68
}
@@ -67,7 +72,7 @@ impl<'a> core::fmt::Display for DebugRoute<'a> {
67
72
macro_rules! log_route {
68
73
( $obj: expr) => {
69
74
$crate:: util:: macro_logger:: DebugRoute ( & $obj)
70
- }
75
+ } ;
71
76
}
72
77
73
78
pub ( crate ) struct DebugTx < ' a > ( pub & ' a Transaction ) ;
@@ -76,14 +81,21 @@ impl<'a> core::fmt::Display for DebugTx<'a> {
76
81
if self . 0 . input . len ( ) >= 1 && self . 0 . input . iter ( ) . any ( |i| !i. witness . is_empty ( ) ) {
77
82
let first_input = & self . 0 . input [ 0 ] ;
78
83
let witness_script_len = first_input. witness . last ( ) . unwrap_or ( & [ ] ) . len ( ) ;
79
- if self . 0 . input . len ( ) == 1 && witness_script_len == 71 &&
80
- ( first_input. sequence . 0 >> 8 * 3 ) as u8 == 0x80 {
84
+ if self . 0 . input . len ( ) == 1
85
+ && witness_script_len == 71
86
+ && ( first_input. sequence . 0 >> 8 * 3 ) as u8 == 0x80
87
+ {
81
88
write ! ( f, "commitment tx " ) ?;
82
89
} else if self . 0 . input . len ( ) == 1 && witness_script_len == 71 {
83
90
write ! ( f, "closing tx " ) ?;
84
- } else if self . 0 . input . len ( ) == 1 && HTLCClaim :: from_witness ( & first_input. witness ) == Some ( HTLCClaim :: OfferedTimeout ) {
91
+ } else if self . 0 . input . len ( ) == 1
92
+ && HTLCClaim :: from_witness ( & first_input. witness ) == Some ( HTLCClaim :: OfferedTimeout )
93
+ {
85
94
write ! ( f, "HTLC-timeout tx " ) ?;
86
- } else if self . 0 . input . len ( ) == 1 && HTLCClaim :: from_witness ( & first_input. witness ) == Some ( HTLCClaim :: AcceptedPreimage ) {
95
+ } else if self . 0 . input . len ( ) == 1
96
+ && HTLCClaim :: from_witness ( & first_input. witness )
97
+ == Some ( HTLCClaim :: AcceptedPreimage )
98
+ {
87
99
write ! ( f, "HTLC-success tx " ) ?;
88
100
} else {
89
101
let mut num_preimage = 0 ;
@@ -92,15 +104,22 @@ impl<'a> core::fmt::Display for DebugTx<'a> {
92
104
for inp in & self . 0 . input {
93
105
let htlc_claim = HTLCClaim :: from_witness ( & inp. witness ) ;
94
106
match htlc_claim {
95
- Some ( HTLCClaim :: AcceptedPreimage ) |Some ( HTLCClaim :: OfferedPreimage ) => num_preimage += 1 ,
96
- Some ( HTLCClaim :: AcceptedTimeout ) |Some ( HTLCClaim :: OfferedTimeout ) => num_timeout += 1 ,
107
+ Some ( HTLCClaim :: AcceptedPreimage ) | Some ( HTLCClaim :: OfferedPreimage ) => {
108
+ num_preimage += 1
109
+ } ,
110
+ Some ( HTLCClaim :: AcceptedTimeout ) | Some ( HTLCClaim :: OfferedTimeout ) => {
111
+ num_timeout += 1
112
+ } ,
97
113
Some ( HTLCClaim :: Revocation ) => num_revoked += 1 ,
98
114
None => continue ,
99
115
}
100
116
}
101
117
if num_preimage > 0 || num_timeout > 0 || num_revoked > 0 {
102
- write ! ( f, "HTLC claim tx ({} preimage, {} timeout, {} revoked) " ,
103
- num_preimage, num_timeout, num_revoked) ?;
118
+ write ! (
119
+ f,
120
+ "HTLC claim tx ({} preimage, {} timeout, {} revoked) " ,
121
+ num_preimage, num_timeout, num_revoked
122
+ ) ?;
104
123
}
105
124
}
106
125
} else {
@@ -115,7 +134,7 @@ impl<'a> core::fmt::Display for DebugTx<'a> {
115
134
macro_rules! log_tx {
116
135
( $obj: expr) => {
117
136
$crate:: util:: macro_logger:: DebugTx ( & $obj)
118
- }
137
+ } ;
119
138
}
120
139
121
140
pub ( crate ) struct DebugSpendable < ' a > ( pub & ' a SpendableOutputDescriptor ) ;
@@ -124,13 +143,21 @@ impl<'a> core::fmt::Display for DebugSpendable<'a> {
124
143
match self . 0 {
125
144
& SpendableOutputDescriptor :: StaticOutput { ref outpoint, .. } => {
126
145
write ! ( f, "StaticOutput {}:{} marked for spending" , outpoint. txid, outpoint. index) ?;
127
- }
146
+ } ,
128
147
& SpendableOutputDescriptor :: DelayedPaymentOutput ( ref descriptor) => {
129
- write ! ( f, "DelayedPaymentOutput {}:{} marked for spending" , descriptor. outpoint. txid, descriptor. outpoint. index) ?;
130
- }
148
+ write ! (
149
+ f,
150
+ "DelayedPaymentOutput {}:{} marked for spending" ,
151
+ descriptor. outpoint. txid, descriptor. outpoint. index
152
+ ) ?;
153
+ } ,
131
154
& SpendableOutputDescriptor :: StaticPaymentOutput ( ref descriptor) => {
132
- write ! ( f, "StaticPaymentOutput {}:{} marked for spending" , descriptor. outpoint. txid, descriptor. outpoint. index) ?;
133
- }
155
+ write ! (
156
+ f,
157
+ "StaticPaymentOutput {}:{} marked for spending" ,
158
+ descriptor. outpoint. txid, descriptor. outpoint. index
159
+ ) ?;
160
+ } ,
134
161
}
135
162
Ok ( ( ) )
136
163
}
@@ -139,7 +166,7 @@ impl<'a> core::fmt::Display for DebugSpendable<'a> {
139
166
macro_rules! log_spendable {
140
167
( $obj: expr) => {
141
168
$crate:: util:: macro_logger:: DebugSpendable ( & $obj)
142
- }
169
+ } ;
143
170
}
144
171
145
172
/// Create a new Record and log it. You probably don't want to use this macro directly,
0 commit comments