@@ -140,7 +140,15 @@ pub fn save_action<'a>(warning: Option<&Error>, saved: bool) -> Element<'a, Mess
140
140
}
141
141
}
142
142
143
- pub fn broadcast_action < ' a > ( warning : Option < & Error > , saved : bool ) -> Element < ' a , Message > {
143
+ /// Return the modal view to broadcast a transaction.
144
+ ///
145
+ /// `conflicting_txids` contains the IDs of any directly conflicting transactions
146
+ /// of the transaction to be broadcast.
147
+ pub fn broadcast_action < ' a > (
148
+ conflicting_txids : & HashSet < Txid > ,
149
+ warning : Option < & Error > ,
150
+ saved : bool ,
151
+ ) -> Element < ' a , Message > {
144
152
if saved {
145
153
card:: simple ( text ( "Transaction is broadcast" ) )
146
154
. width ( Length :: Fixed ( 400.0 ) )
@@ -151,15 +159,71 @@ pub fn broadcast_action<'a>(warning: Option<&Error>, saved: bool) -> Element<'a,
151
159
Column :: new ( )
152
160
. spacing ( 10 )
153
161
. push_maybe ( warning. map ( |w| warn ( Some ( w) ) ) )
154
- . push ( text ( "Broadcast the transaction" ) )
162
+ . push ( Container :: new ( h4_bold ( "Broadcast the transaction" ) ) . width ( Length :: Fill ) )
163
+ . push_maybe ( if conflicting_txids. is_empty ( ) {
164
+ None
165
+ } else {
166
+ Some (
167
+ conflicting_txids. iter ( ) . fold (
168
+ Column :: new ( )
169
+ . spacing ( 5 )
170
+ . push ( Row :: new ( ) . spacing ( 10 ) . push ( icon:: warning_icon ( ) ) . push ( text (
171
+ if conflicting_txids. len ( ) > 1 {
172
+ "WARNING: Broadcasting this transaction \
173
+ will invalidate some pending payments."
174
+ } else {
175
+ "WARNING: Broadcasting this transaction \
176
+ will invalidate a pending payment."
177
+ } ,
178
+ ) ) )
179
+ . push ( Row :: new ( ) . padding ( [ 0 , 30 ] ) . push ( text (
180
+ if conflicting_txids. len ( ) > 1 {
181
+ "The following transactions are \
182
+ spending one or more inputs \
183
+ from the transaction to be \
184
+ broadcast and will be \
185
+ dropped, along with any other \
186
+ transactions that depend on them:"
187
+ } else {
188
+ "The following transaction is \
189
+ spending one or more inputs \
190
+ from the transaction to be \
191
+ broadcast and will be \
192
+ dropped, along with any other \
193
+ transactions that depend on it:"
194
+ } ,
195
+ ) ) ) ,
196
+ |col, txid| {
197
+ col. push (
198
+ Row :: new ( )
199
+ . padding ( [ 0 , 30 ] )
200
+ . spacing ( 5 )
201
+ . align_items ( Alignment :: Center )
202
+ . push ( text ( txid. to_string ( ) ) )
203
+ . push (
204
+ Button :: new (
205
+ icon:: clipboard_icon ( ) . style ( color:: GREY_3 ) ,
206
+ )
207
+ . on_press ( Message :: Clipboard ( txid. to_string ( ) ) )
208
+ . style ( theme:: Button :: TransparentBorder ) ,
209
+ ) ,
210
+ )
211
+ } ,
212
+ ) ,
213
+ )
214
+ } )
155
215
. push (
156
216
Row :: new ( ) . push ( Column :: new ( ) . width ( Length :: Fill ) ) . push (
157
217
button:: primary ( None , "Broadcast" )
158
218
. on_press ( Message :: Spend ( SpendTxMessage :: Confirm ) ) ,
159
219
) ,
160
220
) ,
161
221
)
162
- . width ( Length :: Fixed ( 400.0 ) )
222
+ . width ( Length :: Fixed ( if conflicting_txids. is_empty ( ) {
223
+ 400.0
224
+ } else {
225
+ 800.0
226
+ } ) )
163
227
. into ( )
164
228
}
165
229
}
0 commit comments