Skip to content

Commit

Permalink
Several changes from PKT Cash project (#1204)
Browse files Browse the repository at this point in the history
* Fixed CompactFilterPayload deserialization

* Fixed transaction policy to limit based on virtual size rather than real size

* Small improvement in Transaction serialization to match spec

* Fixed unknown payload data deserialization

* Backed out changeset: 39140bd2e298

* Allow to override Transaction validation method
  • Loading branch information
UCIS authored May 20, 2024
1 parent 963b55f commit 98e4876
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
4 changes: 2 additions & 2 deletions NBitcoin/Protocol/Payloads/CompactFilterPayload.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ public CompactFilterPayload()
{
}

public new void ReadWrite(BitcoinStream stream)
public override void ReadWriteCore(BitcoinStream stream)
{
stream.ReadWrite(ref _FilterType);
stream.ReadWrite(ref _BlockHash);
stream.ReadWrite(_FilterBytes);
stream.ReadWriteAsVarString(ref _FilterBytes);
}
}

Expand Down
9 changes: 8 additions & 1 deletion NBitcoin/Protocol/UnknowPayload.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
Expand Down Expand Up @@ -43,7 +44,13 @@ public byte[] Data
}
public override void ReadWriteCore(BitcoinStream stream)
{
stream.ReadWrite(_Data);
if (stream.Serializing) {
stream.ReadWrite(_Data);
} else {
MemoryStream ms = new MemoryStream();
stream.Inner.CopyTo(ms);
_Data = ms.ToArray();
}
}
}
}
6 changes: 3 additions & 3 deletions NBitcoin/Transaction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1585,8 +1585,8 @@ public virtual void ReadWrite(BitcoinStream stream)
if (flags != 0)
{
/* Use extended format in case witnesses are to be serialized. */
TxInList vinDummy = new TxInList();
stream.ReadWrite(ref vinDummy);
byte marker = 0;
stream.ReadWrite(ref marker);
stream.ReadWrite(ref flags);
}
stream.ReadWrite(ref vin);
Expand Down Expand Up @@ -2039,7 +2039,7 @@ public virtual bool HasWitness
/// Context free transaction check
/// </summary>
/// <returns>The error or success of the check</returns>
public TransactionCheckResult Check()
public virtual TransactionCheckResult Check()
{
// Basic checks that don't depend on any context
if (Inputs.Count == 0)
Expand Down

0 comments on commit 98e4876

Please sign in to comment.