@@ -161,9 +161,7 @@ public override ConsensusFactory GetConsensusFactory()
161161 public override void ReadWrite ( BitcoinStream stream )
162162 {
163163 var witSupported = ( ( ( uint ) stream . TransactionOptions & ( uint ) TransactionOptions . Witness ) != 0 ) &&
164- stream . ProtocolCapabilities . SupportWitness ;
165-
166- //var mwebSupported = false; //when mweb is supported in nbitcoin this is to be fixed
164+ stream . ProtocolCapabilities . SupportWitness ;
167165
168166 byte flags = 0 ;
169167 if ( ! stream . Serializing )
@@ -172,11 +170,8 @@ public override void ReadWrite(BitcoinStream stream)
172170 /* Try to read the vin. In case the dummy is there, this will be read as an empty vector. */
173171 stream . ReadWrite ( ref vin ) ;
174172 vin . Transaction = this ;
175- var hasNoDummy = ( nVersion & NoDummyInput ) != 0 && vin . Count == 0 ;
176- if ( witSupported && hasNoDummy )
177- nVersion = nVersion & ~ NoDummyInput ;
178173
179- if ( vin . Count == 0 && witSupported && ! hasNoDummy )
174+ if ( vin . Count == 0 && witSupported )
180175 {
181176 /* We read a dummy or an empty vin. */
182177 stream . ReadWrite ( ref flags ) ;
@@ -224,8 +219,10 @@ public override void ReadWrite(BitcoinStream stream)
224219 }
225220 else
226221 {
227- var version = ( witSupported && ( vin . Count == 0 && vout . Count > 0 ) ) ? nVersion | NoDummyInput : nVersion ;
228- stream . ReadWrite ( ref version ) ;
222+ if ( Inputs . Count == 0 && ! stream . AllowNoInputs )
223+ throw new InvalidOperationException ( "The transaction must have at least one input" ) ;
224+
225+ stream . ReadWrite ( ref nVersion ) ;
229226
230227 if ( witSupported )
231228 {
@@ -238,8 +235,8 @@ public override void ReadWrite(BitcoinStream stream)
238235 if ( flags != 0 )
239236 {
240237 /* Use extended format in case witnesses are to be serialized. */
241- TxInList vinDummy = new TxInList ( ) ;
242- stream . ReadWrite ( ref vinDummy ) ;
238+ byte marker = 0 ;
239+ stream . ReadWrite ( ref marker ) ;
243240 stream . ReadWrite ( ref flags ) ;
244241 }
245242 stream . ReadWrite ( ref vin ) ;
0 commit comments