@@ -1585,7 +1585,7 @@ public virtual void ReadWrite(BitcoinStream stream)
15851585 }
15861586 else
15871587 {
1588- if ( Inputs . Count == 0 && ! stream . AllowNoInputs )
1588+ if ( Inputs . Count == 0 && ! stream . AllowNoInputs && witSupported )
15891589 throw new InvalidOperationException ( "The transaction must have at least one input" ) ;
15901590 stream . ReadWrite ( ref nVersion ) ;
15911591
@@ -1679,7 +1679,22 @@ public void PrecomputeHash(bool invalidateExisting, bool lazily)
16791679 public Transaction Clone ( bool cloneCache )
16801680 {
16811681 var clone = GetConsensusFactory ( ) . CreateTransaction ( ) ;
1682- clone . ReadWrite ( this . ToBytes ( ) , GetConsensusFactory ( ) ) ;
1682+ MemoryStream ms = new MemoryStream ( ) ;
1683+ var txOptions = this . Inputs . Count is 0 ? TransactionOptions . None : TransactionOptions . All ;
1684+ var stream = new BitcoinStream ( ms , true )
1685+ {
1686+ TransactionOptions = txOptions ,
1687+ ConsensusFactory = GetConsensusFactory ( ) ,
1688+ AllowNoInputs = true
1689+ } ;
1690+ this . ReadWrite ( stream ) ;
1691+ ms . Position = 0 ;
1692+ stream = new BitcoinStream ( ms , false )
1693+ {
1694+ TransactionOptions = txOptions ,
1695+ ConsensusFactory = GetConsensusFactory ( )
1696+ } ;
1697+ clone . ReadWrite ( stream ) ;
16831698 if ( cloneCache )
16841699 clone . _Hashes = _Hashes . ToArray ( ) ;
16851700 return clone ;
@@ -2463,11 +2478,7 @@ public virtual ConsensusFactory GetConsensusFactory()
24632478 }
24642479
24652480 public Transaction Clone ( )
2466- {
2467- var instance = GetConsensusFactory ( ) . CreateTransaction ( ) ;
2468- instance . ReadWrite ( new BitcoinStream ( this . ToBytes ( ) ) { ConsensusFactory = GetConsensusFactory ( ) } ) ;
2469- return instance ;
2470- }
2481+ => Clone ( false ) ;
24712482
24722483 public void FromBytes ( byte [ ] bytes )
24732484 {
0 commit comments