26
26
27
27
use bitcoin:: secp256k1:: PublicKey ;
28
28
use bitcoin:: secp256k1:: ecdsa:: Signature ;
29
- use bitcoin:: { secp256k1, Witness , Transaction } ;
29
+ use bitcoin:: { secp256k1, Witness } ;
30
30
use bitcoin:: blockdata:: script:: Script ;
31
31
use bitcoin:: hash_types:: { Txid , BlockHash } ;
32
32
@@ -42,7 +42,7 @@ use crate::io_extras::read_to_end;
42
42
43
43
use crate :: events:: { MessageSendEventsProvider , OnionMessageProvider } ;
44
44
use crate :: util:: logger;
45
- use crate :: util:: ser:: { LengthReadable , Readable , ReadableArgs , Writeable , Writer , WithoutLength , FixedLengthReader , HighZeroBytesDroppedBigSize , Hostname } ;
45
+ use crate :: util:: ser:: { LengthReadable , Readable , ReadableArgs , Writeable , Writer , WithoutLength , FixedLengthReader , HighZeroBytesDroppedBigSize , Hostname , TransactionU16LenLimited } ;
46
46
47
47
use crate :: ln:: { PaymentPreimage , PaymentHash , PaymentSecret } ;
48
48
@@ -425,45 +425,6 @@ pub struct ChannelReady {
425
425
pub short_channel_id_alias : Option < u64 > ,
426
426
}
427
427
428
- /// A wrapper for a `Transaction` which can only be constructed with [`TransactionU16LenLimited::new`]
429
- /// if the `Transaction`'s consensus-serialized length is <= u16::MAX.
430
- ///
431
- /// Use [`TransactionU16LenLimited::into_transaction`] to convert into the contained `Transaction`.
432
- #[ derive( Clone , Debug , PartialEq , Eq ) ]
433
- pub struct TransactionU16LenLimited ( Transaction ) ;
434
-
435
- impl TransactionU16LenLimited {
436
- /// Constructs a new `TransactionU16LenLimited` from a `Transaction` only if it's consensus-
437
- /// serialized length is <= u16::MAX.
438
- pub fn new ( transaction : Transaction ) -> Result < Self , ( ) > {
439
- if transaction. serialized_length ( ) > ( u16:: MAX as usize ) {
440
- Err ( ( ) )
441
- } else {
442
- Ok ( Self ( transaction) )
443
- }
444
- }
445
-
446
- /// Consumes this `TransactionU16LenLimited` and returns its contained `Transaction`.
447
- pub fn into_transaction ( self ) -> Transaction {
448
- self . 0
449
- }
450
- }
451
-
452
- impl Writeable for TransactionU16LenLimited {
453
- fn write < W : Writer > ( & self , w : & mut W ) -> Result < ( ) , io:: Error > {
454
- ( self . 0 . serialized_length ( ) as u16 ) . write ( w) ?;
455
- self . 0 . write ( w)
456
- }
457
- }
458
-
459
- impl Readable for TransactionU16LenLimited {
460
- fn read < R : Read > ( r : & mut R ) -> Result < Self , DecodeError > {
461
- let len = <u16 as Readable >:: read ( r) ?;
462
- let mut tx_reader = FixedLengthReader :: new ( r, len as u64 ) ;
463
- Ok ( Self ( Readable :: read ( & mut tx_reader) ?) )
464
- }
465
- }
466
-
467
428
/// A tx_add_input message for adding an input during interactive transaction construction
468
429
///
469
430
// TODO(dual_funding): Add spec link for `tx_add_input`.
@@ -850,7 +811,7 @@ impl NetAddress {
850
811
}
851
812
852
813
impl Writeable for NetAddress {
853
- fn write < W : Writer > ( & self , writer : & mut W ) -> Result < ( ) , io:: Error > {
814
+ fn write < W : Writer > ( & self , writer : & mut W ) -> Result < ( ) , io:: Error > {
854
815
match self {
855
816
& NetAddress :: IPv4 { ref addr, ref port } => {
856
817
1u8 . write ( writer) ?;
@@ -2454,10 +2415,9 @@ mod tests {
2454
2415
use hex;
2455
2416
use crate :: ln:: { PaymentPreimage , PaymentHash , PaymentSecret } ;
2456
2417
use crate :: ln:: features:: { ChannelFeatures , ChannelTypeFeatures , InitFeatures , NodeFeatures } ;
2457
- use crate :: ln:: msgs:: { self , TransactionU16LenLimited } ;
2458
- use crate :: ln:: msgs:: { FinalOnionHopData , OnionErrorPacket , OnionHopDataFormat } ;
2418
+ use crate :: ln:: msgs:: { self , FinalOnionHopData , OnionErrorPacket , OnionHopDataFormat } ;
2459
2419
use crate :: routing:: gossip:: { NodeAlias , NodeId } ;
2460
- use crate :: util:: ser:: { Writeable , Readable , Hostname } ;
2420
+ use crate :: util:: ser:: { Writeable , Readable , Hostname , TransactionU16LenLimited } ;
2461
2421
2462
2422
use bitcoin:: hashes:: hex:: FromHex ;
2463
2423
use bitcoin:: util:: address:: Address ;
0 commit comments