diff --git a/NBitcoin/ConsensusFactory.cs b/NBitcoin/ConsensusFactory.cs index 30c5d0d7a..3677a7f68 100644 --- a/NBitcoin/ConsensusFactory.cs +++ b/NBitcoin/ConsensusFactory.cs @@ -79,6 +79,50 @@ public bool TryCreateNew(out T result) where T : IBitcoinSerializable return success; } + public virtual Payload CreatePayload(string command) + { + return command switch + { + "inv" => new InvPayload(), + "tx" => new TxPayload(), + "getdata" => new GetDataPayload(), + "headers" => new HeadersPayload(), + "block" => new BlockPayload(), +#if !NOSOCKET + "addr" => new AddrPayload(), + "addrv2" => new AddrV2Payload(), + "version" => new VersionPayload(), +#endif + "ping" => new PingPayload(), + "pong" => new PongPayload(), + "getaddr" => new GetAddrPayload(), + "blocktxn" => new BlockTxnPayload(), + "cmpctblock" => new CmpctBlockPayload(), + "cfilter" => new CompactFilterPayload(), + "cfcheckpt" => new CompactFilterCheckPointPayload(), + "cfheaders" => new CompactFilterHeadersPayload(), + "feefilter" => new FeeFilterPayload(), + "filteradd" => new FilterAddPayload(), + "filterload" => new FilterLoadPayload(), + "getblocktxn" => new GetBlockTxnPayload(), + "getblocks" => new GetBlocksPayload(), + "getcfilters" => new GetCompactFiltersPayload(), + "getcfheaders" => new GetCompactFilterHeadersPayload(), + "getcfcheckpt" => new GetCompactFilterCheckPointPayload(), + "getheaders" => new GetHeadersPayload(), + "havewitness" => new HaveWitnessPayload(), + "mempool" => new MempoolPayload(), + "merkleblock" => new MerkleBlockPayload(), + "sendaddrv2" => new SendAddrV2Payload(), + "sendcmpct" => new SendCmpctPayload(), + "sendheaders" => new SendHeadersPayload(), + "utxos" => new UTxOutputPayload(), + "verack" => new VerAckPayload(), + "wtxidrelay" => new WTxIdRelayPayload(), + _ => new UnknownPayload(command) + }; + } + public virtual ProtocolCapabilities GetProtocolCapabilities(uint protocolVersion) { return new ProtocolCapabilities() diff --git a/NBitcoin/Protocol/BitcoinSerializablePayload.cs b/NBitcoin/Protocol/BitcoinSerializablePayload.cs index c99ec4401..ba668cf13 100644 --- a/NBitcoin/Protocol/BitcoinSerializablePayload.cs +++ b/NBitcoin/Protocol/BitcoinSerializablePayload.cs @@ -6,7 +6,7 @@ namespace NBitcoin.Protocol { - public class BitcoinSerializablePayload : Payload where T : IBitcoinSerializable, new() + public abstract class BitcoinSerializablePayload : Payload where T : IBitcoinSerializable, new() { public BitcoinSerializablePayload() { diff --git a/NBitcoin/Protocol/Message.cs b/NBitcoin/Protocol/Message.cs index 06a527027..b31f31fef 100644 --- a/NBitcoin/Protocol/Message.cs +++ b/NBitcoin/Protocol/Message.cs @@ -72,7 +72,6 @@ public bool IfPayloadIs(Action action) where TPayload : Payl // We use this for big blocks, because the default array pool would allocate a new array. We do not need lot's of bucket such arrays are short lived. readonly static Lazy> BigArrayPool = new Lazy>(() => ArrayPool.Create(0x02000000, 5), false); ArrayPool GetArrayPool(int size) => size < 1_048_576 ? ArrayPool.Shared : BigArrayPool.Value; - public void ReadWrite(BitcoinStream stream) { if (Payload == null && stream.Serializing) @@ -130,7 +129,7 @@ public void ReadWrite(BitcoinStream stream) BitcoinStream payloadStream = new BitcoinStream(new MemoryStream(payloadBytes, 0, length, false), false); payloadStream.CopyParameters(stream); - var payload = PayloadFactory.Instance.Create(Command); + var payload = stream.ConsensusFactory.CreatePayload(Command); if (payload is UnknownPayload) Logs.NodeServer.LogWarning("Unknown command received {command}", Command); diff --git a/NBitcoin/Protocol/Payload.cs b/NBitcoin/Protocol/Payload.cs index be9036fa9..0f878154e 100644 --- a/NBitcoin/Protocol/Payload.cs +++ b/NBitcoin/Protocol/Payload.cs @@ -6,14 +6,14 @@ namespace NBitcoin.Protocol { - public class Payload : IBitcoinSerializable + /// + /// A P2P Bitcoin payload + /// + public abstract class Payload : IBitcoinSerializable { - public virtual string Command + public abstract string Command { - get - { - return PayloadFactory.Instance.GetCommand(this); - } + get; } #region IBitcoinSerializable Members @@ -34,7 +34,7 @@ public virtual void ReadWriteCore(BitcoinStream stream) public override string ToString() { - return this.GetType().Name; + return Command; } } } diff --git a/NBitcoin/Protocol/PayloadFactory.cs b/NBitcoin/Protocol/PayloadFactory.cs deleted file mode 100644 index 8d564a386..000000000 --- a/NBitcoin/Protocol/PayloadFactory.cs +++ /dev/null @@ -1,103 +0,0 @@ -using System; -using NBitcoin.Protocol.Payloads; - -namespace NBitcoin.Protocol -{ - public class PayloadFactory - { - public static readonly PayloadFactory Instance = new PayloadFactory(); - - private PayloadFactory() - { - } - - - public Payload Create(string command) - { - return command switch - { -#if !NOSOCKET - "addr" => new AddrPayload(), - "addrv2" => new AddrV2Payload(), - "version" => new VersionPayload(), -#endif - "ping" => new PingPayload(), - "pong" => new PongPayload(), - "inv" => new InvPayload(), - "getdata" => new GetDataPayload(), - "tx" => new TxPayload(), - "getaddr" => new GetAddrPayload(), - "headers" => new HeadersPayload(), - "block" => new BlockPayload(), - "blocktxn" => new BlockTxnPayload(), - "cmpctblock" => new CmpctBlockPayload(), - "cfilter" => new CompactFilterPayload(), - "cfcheckpt" => new CompactFilterCheckPointPayload(), - "cfheaders" => new CompactFilterHeadersPayload(), - "feefilter" => new FeeFilterPayload(), - "filteradd" => new FilterAddPayload(), - "filterload" => new FilterLoadPayload(), - "getblocktxn" => new GetBlockTxnPayload(), - "getblocks" => new GetBlocksPayload(), - "getcfilters" => new GetCompactFiltersPayload(), - "getcfheaders" => new GetCompactFilterHeadersPayload(), - "getcfcheckpt" => new GetCompactFilterCheckPointPayload(), - "getheaders" => new GetHeadersPayload(), - "havewitness" => new HaveWitnessPayload(), - "mempool" => new MempoolPayload(), - "merkleblock" => new MerkleBlockPayload(), - "sendaddrv2" => new SendAddrV2Payload(), - "sendcmpct" => new SendCmpctPayload(), - "sendheaders" => new SendHeadersPayload(), - "utxos" => new UTxOutputPayload(), - "verack" => new VerAckPayload(), - "wtxidrelay" => new WTxIdRelayPayload(), - _ => new UnknownPayload(command) - }; - } - - public string GetCommand(Payload payload) - { - return payload switch - { -#if !NOSOCKET - AddrV2Payload => "addrv2", - AddrPayload => "addr", - VersionPayload => "version", -#endif - PingPayload => "ping", - PongPayload => "pong", - InvPayload => "inv", - TxPayload => "tx", - GetDataPayload => "getdata", - HeadersPayload => "headers", - BlockPayload => "block", - BlockTxnPayload => "blocktxn", - CmpctBlockPayload => "cmpctblock", - CompactFilterPayload => "cfilter", - CompactFilterHeadersPayload => "cfheaders", - CompactFilterCheckPointPayload => "cfcheckpt", - FeeFilterPayload => "feefilter", - FilterAddPayload => "filteradd", - FilterLoadPayload => "filterload", - GetAddrPayload => "getaddr", - GetBlockTxnPayload => "getblocktxn", - GetBlocksPayload => "getblocks", - GetCompactFiltersPayload => "getcfilters", - GetCompactFilterHeadersPayload => "getcfheaders", - GetCompactFilterCheckPointPayload => "getcfcheckpt", - GetHeadersPayload => "getheaders", - HaveWitnessPayload => "havewitness", - MempoolPayload => "mempool", - MerkleBlockPayload => "merkleblock", - SendAddrV2Payload => "sendaddrv2", - SendCmpctPayload => "sendcmpct", - SendHeadersPayload => "sendheaders", - UTxOutputPayload => "utxos", - VerAckPayload => "verack", - WTxIdRelayPayload => "wtxidrelay", - _ => throw new NotSupportedException($"Unknown command for Payload type: {payload.GetType().Name}") - }; - } - } -} diff --git a/NBitcoin/Protocol/Payloads/AddrPayload.cs b/NBitcoin/Protocol/Payloads/AddrPayload.cs index e8bb17da1..36ebc2c49 100644 --- a/NBitcoin/Protocol/Payloads/AddrPayload.cs +++ b/NBitcoin/Protocol/Payloads/AddrPayload.cs @@ -13,6 +13,7 @@ namespace NBitcoin.Protocol public class AddrPayload : Payload, IBitcoinSerializable { + public override string Command => "addr"; NetworkAddress[] addr_list = new NetworkAddress[0]; public NetworkAddress[] Addresses { @@ -56,6 +57,7 @@ public override string ToString() public class AddrV2Payload : AddrPayload { + public override string Command => "addrv2"; public AddrV2Payload() : base() { @@ -79,4 +81,4 @@ public override void ReadWriteCore(BitcoinStream stream) } } } -#endif \ No newline at end of file +#endif diff --git a/NBitcoin/Protocol/Payloads/BlockPayload.cs b/NBitcoin/Protocol/Payloads/BlockPayload.cs index cf8a9b8f7..6a022808e 100644 --- a/NBitcoin/Protocol/Payloads/BlockPayload.cs +++ b/NBitcoin/Protocol/Payloads/BlockPayload.cs @@ -12,6 +12,7 @@ namespace NBitcoin.Protocol public class BlockPayload : BitcoinSerializablePayload { + public override string Command => "block"; public BlockPayload() { diff --git a/NBitcoin/Protocol/Payloads/BlockTxnPayload.cs b/NBitcoin/Protocol/Payloads/BlockTxnPayload.cs index 2b5c7d4f7..4c322e131 100644 --- a/NBitcoin/Protocol/Payloads/BlockTxnPayload.cs +++ b/NBitcoin/Protocol/Payloads/BlockTxnPayload.cs @@ -9,6 +9,7 @@ namespace NBitcoin.Protocol public class BlockTxnPayload : Payload { + public override string Command => "blocktxn"; uint256 _BlockId; public uint256 BlockId diff --git a/NBitcoin/Protocol/Payloads/CmpctBlockPayload.cs b/NBitcoin/Protocol/Payloads/CmpctBlockPayload.cs index aa7ff74e5..6838ebb72 100644 --- a/NBitcoin/Protocol/Payloads/CmpctBlockPayload.cs +++ b/NBitcoin/Protocol/Payloads/CmpctBlockPayload.cs @@ -11,6 +11,7 @@ namespace NBitcoin.Protocol public class CmpctBlockPayload : Payload { + public override string Command => "cmpctblock"; public CmpctBlockPayload() { diff --git a/NBitcoin/Protocol/Payloads/CompactFilterPayload.cs b/NBitcoin/Protocol/Payloads/CompactFilterPayload.cs index e5e1a4f65..b1e2f7583 100644 --- a/NBitcoin/Protocol/Payloads/CompactFilterPayload.cs +++ b/NBitcoin/Protocol/Payloads/CompactFilterPayload.cs @@ -9,6 +9,7 @@ namespace NBitcoin.Protocol public class CompactFilterPayload : Payload { + public override string Command => "cfilter"; private byte _FilterType = (byte)FilterType.Basic; private byte[] _FilterBytes; private uint256 _BlockHash = new uint256(); @@ -61,6 +62,7 @@ public CompactFilterPayload() public class CompactFilterCheckPointPayload : Payload { + public override string Command => "cfcheckpt"; protected byte _FilterType = (byte)FilterType.Basic; protected uint256 _StopHash = uint256.Zero; protected List _FilterHeaders = new List(); @@ -112,6 +114,7 @@ public override void ReadWriteCore(BitcoinStream stream) public class CompactFilterHeadersPayload: CompactFilterCheckPointPayload { + public override string Command => "cfheaders"; private uint256 _PreviousFilterHeader = uint256.Zero; public override void ReadWriteCore(BitcoinStream stream) diff --git a/NBitcoin/Protocol/Payloads/FeeFilterPayload.cs b/NBitcoin/Protocol/Payloads/FeeFilterPayload.cs index 02d2b17aa..2a118076e 100644 --- a/NBitcoin/Protocol/Payloads/FeeFilterPayload.cs +++ b/NBitcoin/Protocol/Payloads/FeeFilterPayload.cs @@ -6,6 +6,7 @@ namespace NBitcoin.Protocol public class FeeFilterPayload : Payload { + public override string Command => "feefilter"; public FeeFilterPayload() { _feeRate = FeeRate.Zero; diff --git a/NBitcoin/Protocol/Payloads/FilterAddPayload.cs b/NBitcoin/Protocol/Payloads/FilterAddPayload.cs index 62a47e09d..a86c1258d 100644 --- a/NBitcoin/Protocol/Payloads/FilterAddPayload.cs +++ b/NBitcoin/Protocol/Payloads/FilterAddPayload.cs @@ -9,6 +9,7 @@ namespace NBitcoin.Protocol public class FilterAddPayload : Payload { + public override string Command => "filteradd"; public FilterAddPayload() { diff --git a/NBitcoin/Protocol/Payloads/FilterLoadPayload.cs b/NBitcoin/Protocol/Payloads/FilterLoadPayload.cs index fc9bb812a..e0899fa75 100644 --- a/NBitcoin/Protocol/Payloads/FilterLoadPayload.cs +++ b/NBitcoin/Protocol/Payloads/FilterLoadPayload.cs @@ -12,6 +12,7 @@ namespace NBitcoin.Protocol public class FilterLoadPayload : BitcoinSerializablePayload { + public override string Command => "filterload"; public FilterLoadPayload() { diff --git a/NBitcoin/Protocol/Payloads/GetAddrPayload.cs b/NBitcoin/Protocol/Payloads/GetAddrPayload.cs index 27792a349..4803c218f 100644 --- a/NBitcoin/Protocol/Payloads/GetAddrPayload.cs +++ b/NBitcoin/Protocol/Payloads/GetAddrPayload.cs @@ -12,5 +12,6 @@ namespace NBitcoin.Protocol public class GetAddrPayload : Payload { + public override string Command => "getaddr"; } } diff --git a/NBitcoin/Protocol/Payloads/GetBlockTxnPayload.cs b/NBitcoin/Protocol/Payloads/GetBlockTxnPayload.cs index 58345018e..cf66e85f8 100644 --- a/NBitcoin/Protocol/Payloads/GetBlockTxnPayload.cs +++ b/NBitcoin/Protocol/Payloads/GetBlockTxnPayload.cs @@ -9,6 +9,7 @@ namespace NBitcoin.Protocol public class GetBlockTxnPayload : Payload { + public override string Command => "getblocktxn"; uint256 _BlockId = uint256.Zero; public uint256 BlockId diff --git a/NBitcoin/Protocol/Payloads/GetBlocksPayload.cs b/NBitcoin/Protocol/Payloads/GetBlocksPayload.cs index 03e567c14..ecd6b0d1f 100644 --- a/NBitcoin/Protocol/Payloads/GetBlocksPayload.cs +++ b/NBitcoin/Protocol/Payloads/GetBlocksPayload.cs @@ -12,6 +12,7 @@ namespace NBitcoin.Protocol public class GetBlocksPayload : Payload { + public override string Command => "getblocks"; public GetBlocksPayload(BlockLocator locator) { BlockLocators = locator; diff --git a/NBitcoin/Protocol/Payloads/GetCompactFiltersPayload.cs b/NBitcoin/Protocol/Payloads/GetCompactFiltersPayload.cs index 1a54d423d..58843880e 100644 --- a/NBitcoin/Protocol/Payloads/GetCompactFiltersPayload.cs +++ b/NBitcoin/Protocol/Payloads/GetCompactFiltersPayload.cs @@ -65,6 +65,7 @@ public override void ReadWriteCore(BitcoinStream stream) public class GetCompactFiltersPayload : CompactFiltersQueryPayload { + public override string Command => "getcfilters"; public GetCompactFiltersPayload(FilterType filterType, uint startHeight, uint256 stopHash) : base(filterType, startHeight, stopHash) { @@ -79,6 +80,7 @@ public GetCompactFiltersPayload() { } public class GetCompactFilterHeadersPayload : CompactFiltersQueryPayload { + public override string Command => "getcfheaders"; public GetCompactFilterHeadersPayload(FilterType filterType, uint startHeight, uint256 stopHash) : base(filterType, startHeight, stopHash) { @@ -90,6 +92,7 @@ public GetCompactFilterHeadersPayload() { } public class GetCompactFilterCheckPointPayload : Payload { + public override string Command => "getcfcheckpt"; private byte _FilterType; private uint256 _StopHash; diff --git a/NBitcoin/Protocol/Payloads/GetDataPayload.cs b/NBitcoin/Protocol/Payloads/GetDataPayload.cs index b0030550c..b206f8d16 100644 --- a/NBitcoin/Protocol/Payloads/GetDataPayload.cs +++ b/NBitcoin/Protocol/Payloads/GetDataPayload.cs @@ -12,6 +12,7 @@ namespace NBitcoin.Protocol public class GetDataPayload : Payload { + public override string Command => "getdata"; public GetDataPayload() { } diff --git a/NBitcoin/Protocol/Payloads/GetHeadersPayload.cs b/NBitcoin/Protocol/Payloads/GetHeadersPayload.cs index c5f3ea9a4..5769dce9b 100644 --- a/NBitcoin/Protocol/Payloads/GetHeadersPayload.cs +++ b/NBitcoin/Protocol/Payloads/GetHeadersPayload.cs @@ -12,6 +12,7 @@ namespace NBitcoin.Protocol public class GetHeadersPayload : Payload { + public override string Command => "getheaders"; public GetHeadersPayload() { diff --git a/NBitcoin/Protocol/Payloads/HaveWitnessPayload.cs b/NBitcoin/Protocol/Payloads/HaveWitnessPayload.cs index 47fd343cb..7c8360d0c 100644 --- a/NBitcoin/Protocol/Payloads/HaveWitnessPayload.cs +++ b/NBitcoin/Protocol/Payloads/HaveWitnessPayload.cs @@ -9,6 +9,7 @@ namespace NBitcoin.Protocol public class HaveWitnessPayload : Payload { + public override string Command => "havewitness"; public HaveWitnessPayload() { diff --git a/NBitcoin/Protocol/Payloads/HeadersPayload.cs b/NBitcoin/Protocol/Payloads/HeadersPayload.cs index 86ec222bf..24502f7f4 100644 --- a/NBitcoin/Protocol/Payloads/HeadersPayload.cs +++ b/NBitcoin/Protocol/Payloads/HeadersPayload.cs @@ -13,6 +13,7 @@ namespace NBitcoin.Protocol public class HeadersPayload : Payload { + public override string Command => "headers"; class BlockHeaderWithTxCount : IBitcoinSerializable { public BlockHeaderWithTxCount() diff --git a/NBitcoin/Protocol/Payloads/InvPayload.cs b/NBitcoin/Protocol/Payloads/InvPayload.cs index 6e5efcc3f..b00f9f4bf 100644 --- a/NBitcoin/Protocol/Payloads/InvPayload.cs +++ b/NBitcoin/Protocol/Payloads/InvPayload.cs @@ -12,6 +12,7 @@ namespace NBitcoin.Protocol public class InvPayload : Payload, IBitcoinSerializable, IEnumerable { + public override string Command => "inv"; public InvPayload() { diff --git a/NBitcoin/Protocol/Payloads/MempoolPayload.cs b/NBitcoin/Protocol/Payloads/MempoolPayload.cs index a34e1d242..413738cc7 100644 --- a/NBitcoin/Protocol/Payloads/MempoolPayload.cs +++ b/NBitcoin/Protocol/Payloads/MempoolPayload.cs @@ -12,5 +12,6 @@ namespace NBitcoin.Protocol public class MempoolPayload : Payload { + public override string Command => "mempool"; } } diff --git a/NBitcoin/Protocol/Payloads/MerkleBlockPayload.cs b/NBitcoin/Protocol/Payloads/MerkleBlockPayload.cs index 6c8e4eaee..a18999eed 100644 --- a/NBitcoin/Protocol/Payloads/MerkleBlockPayload.cs +++ b/NBitcoin/Protocol/Payloads/MerkleBlockPayload.cs @@ -12,6 +12,7 @@ namespace NBitcoin.Protocol public class MerkleBlockPayload : BitcoinSerializablePayload { + public override string Command => "merkleblock"; public MerkleBlockPayload() { diff --git a/NBitcoin/Protocol/Payloads/NotFoundPayload.cs b/NBitcoin/Protocol/Payloads/NotFoundPayload.cs index 132fb8736..07e4bf27b 100644 --- a/NBitcoin/Protocol/Payloads/NotFoundPayload.cs +++ b/NBitcoin/Protocol/Payloads/NotFoundPayload.cs @@ -11,6 +11,7 @@ namespace NBitcoin.Protocol /// public class NotFoundPayload : Payload, IEnumerable { + public override string Command => "notfound"; public NotFoundPayload() { diff --git a/NBitcoin/Protocol/Payloads/PingPayload.cs b/NBitcoin/Protocol/Payloads/PingPayload.cs index 425d54c97..43a252041 100644 --- a/NBitcoin/Protocol/Payloads/PingPayload.cs +++ b/NBitcoin/Protocol/Payloads/PingPayload.cs @@ -9,7 +9,7 @@ namespace NBitcoin.Protocol public class PingPayload : Payload { - + public override string Command => "ping"; public PingPayload() { _Nonce = RandomUtils.GetUInt64(); diff --git a/NBitcoin/Protocol/Payloads/PongPayload.cs b/NBitcoin/Protocol/Payloads/PongPayload.cs index 7968e82e3..a3a5a9d72 100644 --- a/NBitcoin/Protocol/Payloads/PongPayload.cs +++ b/NBitcoin/Protocol/Payloads/PongPayload.cs @@ -9,6 +9,7 @@ namespace NBitcoin.Protocol public class PongPayload : Payload { + public override string Command => "pong"; private ulong _Nonce; public ulong Nonce { diff --git a/NBitcoin/Protocol/Payloads/SendAddrV2Payload.cs b/NBitcoin/Protocol/Payloads/SendAddrV2Payload.cs index 872bb9726..9305dd912 100644 --- a/NBitcoin/Protocol/Payloads/SendAddrV2Payload.cs +++ b/NBitcoin/Protocol/Payloads/SendAddrV2Payload.cs @@ -12,5 +12,6 @@ namespace NBitcoin.Protocol public class SendAddrV2Payload : Payload { + public override string Command => "sendaddrv2"; } } diff --git a/NBitcoin/Protocol/Payloads/SendCmpctPayload.cs b/NBitcoin/Protocol/Payloads/SendCmpctPayload.cs index 985386f2e..f0444d965 100644 --- a/NBitcoin/Protocol/Payloads/SendCmpctPayload.cs +++ b/NBitcoin/Protocol/Payloads/SendCmpctPayload.cs @@ -9,6 +9,7 @@ namespace NBitcoin.Protocol public class SendCmpctPayload : Payload { + public override string Command => "sendcmpct"; public SendCmpctPayload() { diff --git a/NBitcoin/Protocol/Payloads/SendHeadersPayload.cs b/NBitcoin/Protocol/Payloads/SendHeadersPayload.cs index 9b390756d..c1d3d687a 100644 --- a/NBitcoin/Protocol/Payloads/SendHeadersPayload.cs +++ b/NBitcoin/Protocol/Payloads/SendHeadersPayload.cs @@ -9,5 +9,6 @@ namespace NBitcoin.Protocol public class SendHeadersPayload : Payload { + public override string Command => "sendheaders"; } } diff --git a/NBitcoin/Protocol/Payloads/TxPayload.cs b/NBitcoin/Protocol/Payloads/TxPayload.cs index 39fdffc8d..6c2970226 100644 --- a/NBitcoin/Protocol/Payloads/TxPayload.cs +++ b/NBitcoin/Protocol/Payloads/TxPayload.cs @@ -12,6 +12,7 @@ namespace NBitcoin.Protocol public class TxPayload : Payload { + public override string Command => "tx"; public TxPayload() { diff --git a/NBitcoin/Protocol/Payloads/UTxOutputPayload.cs b/NBitcoin/Protocol/Payloads/UTxOutputPayload.cs index 64bc7219c..189fd8c2e 100644 --- a/NBitcoin/Protocol/Payloads/UTxOutputPayload.cs +++ b/NBitcoin/Protocol/Payloads/UTxOutputPayload.cs @@ -1,10 +1,11 @@ using System.Collections; -namespace NBitcoin.Protocol.Payloads +namespace NBitcoin.Protocol { public class UTxOutputPayload : Payload { + public override string Command => "utxos"; private UTxOutputs _uTxOutputs; public override void ReadWriteCore(BitcoinStream stream) diff --git a/NBitcoin/Protocol/Payloads/VerAckPayload.cs b/NBitcoin/Protocol/Payloads/VerAckPayload.cs index 70b885744..e58d3941c 100644 --- a/NBitcoin/Protocol/Payloads/VerAckPayload.cs +++ b/NBitcoin/Protocol/Payloads/VerAckPayload.cs @@ -9,6 +9,7 @@ namespace NBitcoin.Protocol public class VerAckPayload : Payload, IBitcoinSerializable { + public override string Command => "verack"; #region IBitcoinSerializable Members public override void ReadWriteCore(BitcoinStream stream) diff --git a/NBitcoin/Protocol/Payloads/VersionPayload.cs b/NBitcoin/Protocol/Payloads/VersionPayload.cs index 9f4485de6..7acda8895 100644 --- a/NBitcoin/Protocol/Payloads/VersionPayload.cs +++ b/NBitcoin/Protocol/Payloads/VersionPayload.cs @@ -57,6 +57,7 @@ public enum NodeServices : ulong public class VersionPayload : Payload, IBitcoinSerializable { + public override string Command => "version"; static string _NUserAgent; public static string GetNBitcoinUserAgent() { @@ -237,4 +238,4 @@ public override string ToString() } } } -#endif \ No newline at end of file +#endif diff --git a/NBitcoin/Protocol/Payloads/WTxIdRelayPayload.cs b/NBitcoin/Protocol/Payloads/WTxIdRelayPayload.cs index 9fa1771e5..d2da9f783 100644 --- a/NBitcoin/Protocol/Payloads/WTxIdRelayPayload.cs +++ b/NBitcoin/Protocol/Payloads/WTxIdRelayPayload.cs @@ -6,5 +6,6 @@ namespace NBitcoin.Protocol public class WTxIdRelayPayload : Payload { + public override string Command => "wtxidrelay"; } }