@@ -94,7 +94,9 @@ impl Readable for ChangeSetDeserWrapper<BdkLocalChainChangeSet> {
9494 decode_tlv_stream ! ( reader, {
9595 ( 0 , blocks, required) ,
9696 } ) ;
97- Ok ( Self ( BdkLocalChainChangeSet { blocks : blocks. 0 . unwrap ( ) } ) )
97+ Ok ( Self ( BdkLocalChainChangeSet {
98+ blocks : blocks. 0 . expect ( "required blocks TLV field should be present" ) ,
99+ } ) )
98100 }
99101}
100102
@@ -141,10 +143,10 @@ impl Readable for ChangeSetDeserWrapper<BdkTxGraphChangeSet<ConfirmationBlockTim
141143 } ) ;
142144
143145 Ok ( Self ( BdkTxGraphChangeSet {
144- txs : txs. 0 . unwrap ( ) . 0 ,
145- txouts : txouts. 0 . unwrap ( ) ,
146- anchors : anchors. 0 . unwrap ( ) . 0 ,
147- last_seen : last_seen. 0 . unwrap ( ) ,
146+ txs : txs. 0 . expect ( "required txs TLV field should be present" ) . 0 ,
147+ txouts : txouts. 0 . expect ( "required txouts TLV field should be present" ) ,
148+ anchors : anchors. 0 . expect ( "required anchors TLV field should be present" ) . 0 ,
149+ last_seen : last_seen. 0 . expect ( "required last_seen TLV field should be present" ) ,
148150 first_seen : first_seen. unwrap_or_default ( ) ,
149151 last_evicted : last_evicted. unwrap_or_default ( ) ,
150152 } ) )
@@ -177,7 +179,10 @@ impl Readable for ChangeSetDeserWrapper<BTreeSet<(ConfirmationBlockTime, Txid)>>
177179 ( 0 , time, required) ,
178180 ( 2 , txid, required) ,
179181 } ) ;
180- set. insert ( ( time. 0 . unwrap ( ) . 0 , txid. 0 . unwrap ( ) ) ) ;
182+ set. insert ( (
183+ time. 0 . expect ( "required confirmation time TLV field should be present" ) . 0 ,
184+ txid. 0 . expect ( "required txid TLV field should be present" ) ,
185+ ) ) ;
181186 }
182187 Ok ( Self ( set) )
183188 }
@@ -205,7 +210,7 @@ impl Readable for ChangeSetDeserWrapper<BTreeSet<Arc<Transaction>>> {
205210 read_tlv_fields ! ( reader, {
206211 ( 0 , tx, required) ,
207212 } ) ;
208- set. insert ( Arc :: new ( tx. 0 . unwrap ( ) ) ) ;
213+ set. insert ( Arc :: new ( tx. 0 . expect ( "required transaction TLV field should be present" ) ) ) ;
209214 }
210215 Ok ( Self ( set) )
211216 }
@@ -232,8 +237,10 @@ impl Readable for ChangeSetDeserWrapper<ConfirmationBlockTime> {
232237 } ) ;
233238
234239 Ok ( Self ( ConfirmationBlockTime {
235- block_id : block_id. 0 . unwrap ( ) . 0 ,
236- confirmation_time : confirmation_time. 0 . unwrap ( ) ,
240+ block_id : block_id. 0 . expect ( "required block_id TLV field should be present" ) . 0 ,
241+ confirmation_time : confirmation_time
242+ . 0
243+ . expect ( "required confirmation_time TLV field should be present" ) ,
237244 } ) )
238245 }
239246}
@@ -257,7 +264,10 @@ impl Readable for ChangeSetDeserWrapper<BlockId> {
257264 ( 2 , hash, required) ,
258265 } ) ;
259266
260- Ok ( Self ( BlockId { height : height. 0 . unwrap ( ) , hash : hash. 0 . unwrap ( ) } ) )
267+ Ok ( Self ( BlockId {
268+ height : height. 0 . expect ( "required height TLV field should be present" ) ,
269+ hash : hash. 0 . expect ( "required hash TLV field should be present" ) ,
270+ } ) )
261271 }
262272}
263273
@@ -285,7 +295,10 @@ impl Readable for ChangeSetDeserWrapper<BdkIndexerChangeSet> {
285295 decode_tlv_stream ! ( reader, { ( 0 , last_revealed, required) } ) ;
286296
287297 Ok ( Self ( BdkIndexerChangeSet {
288- last_revealed : last_revealed. 0 . unwrap ( ) . 0 ,
298+ last_revealed : last_revealed
299+ . 0
300+ . expect ( "required last_revealed TLV field should be present" )
301+ . 0 ,
289302 spk_cache : Default :: default ( ) ,
290303 } ) )
291304 }
@@ -317,7 +330,10 @@ impl Readable for ChangeSetDeserWrapper<BTreeMap<DescriptorId, u32>> {
317330 ( 0 , descriptor_id, required) ,
318331 ( 2 , last_index, required) ,
319332 } ) ;
320- set. insert ( descriptor_id. 0 . unwrap ( ) . 0 , last_index. 0 . unwrap ( ) ) ;
333+ set. insert (
334+ descriptor_id. 0 . expect ( "required descriptor_id TLV field should be present" ) . 0 ,
335+ last_index. 0 . expect ( "required last_index TLV field should be present" ) ,
336+ ) ;
321337 }
322338 Ok ( Self ( set) )
323339 }
@@ -336,7 +352,9 @@ impl Readable for ChangeSetDeserWrapper<DescriptorId> {
336352
337353 decode_tlv_stream ! ( reader, { ( 0 , hash, required) } ) ;
338354
339- Ok ( Self ( DescriptorId ( hash. 0 . unwrap ( ) . 0 ) ) )
355+ Ok ( Self ( DescriptorId (
356+ hash. 0 . expect ( "required descriptor hash TLV field should be present" ) . 0 ,
357+ ) ) )
340358 }
341359}
342360
@@ -351,6 +369,9 @@ impl Readable for ChangeSetDeserWrapper<Sha256Hash> {
351369 use bitcoin:: hashes:: Hash ;
352370
353371 let buf: [ u8 ; 32 ] = Readable :: read ( reader) ?;
354- Ok ( Self ( Sha256Hash :: from_slice ( & buf[ ..] ) . unwrap ( ) ) )
372+ Ok ( Self (
373+ Sha256Hash :: from_slice ( & buf[ ..] )
374+ . expect ( "a 32-byte buffer should decode into a sha256 hash" ) ,
375+ ) )
355376 }
356377}
0 commit comments