/// <summary>
 /// Does a readwrite to the stream of this persistence entry.
 /// </summary>
 /// <param name="stream">Stream to do readwrite to.</param>
 public void ReadWrite(BitcoinStream stream)
 {
     stream.ReadWrite(ref this.tx);
     stream.ReadWriteAsCompactVarInt(ref this.time);
     stream.ReadWriteAsCompactVarInt(ref this.feeDelta);
 }
Пример #2
0
		public void ReadWrite(BitcoinStream stream)
		{
			if(stream.Serializing)
			{
				uint o = (uint)(nHeight * 2 + (fCoinBase ? 1 : 0));
				stream.ReadWriteAsCompactVarInt(ref o);
				if(nHeight > 0)
					stream.ReadWriteAsCompactVarInt(ref nVersion);
				TxOutCompressor compressor = new TxOutCompressor(txout);
				stream.ReadWrite(ref compressor);
			}
			else
			{
				uint nCode = 0;
				stream.ReadWriteAsCompactVarInt(ref nCode);
				nHeight = nCode / 2;
				fCoinBase = (nCode & 1) != 0;
				if(nHeight > 0)
					stream.ReadWriteAsCompactVarInt(ref nVersion);
				TxOutCompressor compressor = new TxOutCompressor();
				stream.ReadWrite(ref compressor);
				txout = compressor.TxOut;
			}
		}
Пример #3
0
 public void ReadWrite(BitcoinStream stream)
 {
     if(stream.Serializing)
     {
         var compr = Compress();
         if(compr != null)
         {
             stream.ReadWrite(ref compr);
             return;
         }
         uint nSize = (uint)_Script.Length + nSpecialScripts;
         stream.ReadWriteAsCompactVarInt(ref nSize);
         stream.ReadWrite(ref _Script);
     }
     else
     {
         uint nSize = 0;
         stream.ReadWriteAsCompactVarInt(ref nSize);
         if(nSize < nSpecialScripts)
         {
             byte[] vch = new byte[GetSpecialSize(nSize)];
             stream.ReadWrite(ref vch);
             _Script = Decompress(nSize, vch).ToRawScript();
             return;
         }
         nSize -= nSpecialScripts;
         _Script = new byte[nSize];
         stream.ReadWrite(ref _Script);
     }
 }
Пример #4
0
 public void ReadWrite(BitcoinStream stream)
 {
     if(stream.Serializing)
     {
         ulong val = CompressAmount((ulong)_TxOut.Value.Satoshi);
         stream.ReadWriteAsCompactVarInt(ref val);
     }
     else
     {
         ulong val = 0;
         stream.ReadWriteAsCompactVarInt(ref val);
         _TxOut.Value = new Money(DecompressAmount(val));
     }
     ScriptCompressor cscript = new ScriptCompressor(_TxOut.ScriptPubKey);
     stream.ReadWrite(ref cscript);
     if(!stream.Serializing)
         _TxOut.ScriptPubKey = new Script(cscript.ScriptBytes);
 }
Пример #5
0
 public void ReadWrite(BitcoinStream stream)
 {
     stream.ReadWrite(ref _Add);
     stream.ReadWriteAsCompactVarInt(ref _HeightOrBackstep);
     if(_Add)
     {
         stream.ReadWrite(ref _BlockHeader);
     }
 }