Why class InventoryVector inherit from Payload? I think that InventoryVector is not stand alone Bitcoin message, it is only part of the message (e.g. InventoryPayload) - so I think that InventoryVector is not Payload - it is only IBitcoinSerializable - it doesn't have Command (which Payload expect).
The reason I found that is, it isn't json serializable:
code:
var invVector = new InventoryVector(InventoryType.MSG_TX, uint256.One);
Console.WriteLine(JsonSerializer.Serialize(invVector));
Exception:
Unhandled exception. System.ArgumentException: NBitcoin.Protocol.InventoryVector is not a payload
at NBitcoin.Protocol.PayloadAttribute.GetCommandName(Type type)
at NBitcoin.Protocol.Payload.get_Command()
at System.Text.Json.Serialization.Metadata.JsonPropertyInfo`1.GetMemberAndWriteJson(Object obj, WriteStack& state, Utf8JsonWriter writer)
at System.Text.Json.Serialization.Converters.ObjectDefaultConverter`1.OnTryWrite(Utf8JsonWriter writer, T value, JsonSerializerOptions options, WriteStack& state)
at System.Text.Json.Serialization.JsonConverter`1.TryWrite(Utf8JsonWriter writer, T& value, JsonSerializerOptions options, WriteStack& state)
at System.Text.Json.Serialization.JsonConverter`1.WriteCore(Utf8JsonWriter writer, T& value, JsonSerializerOptions options, WriteStack& state)
at System.Text.Json.JsonSerializer.WriteUsingSerializer[TValue](Utf8JsonWriter writer, TValue& value, JsonTypeInfo jsonTypeInfo)
at System.Text.Json.JsonSerializer.WriteStringUsingSerializer[TValue](TValue& value, JsonTypeInfo jsonTypeInfo)
at System.Text.Json.JsonSerializer.Serialize[TValue](TValue value, JsonSerializerOptions options)
Hello everyone! I am working with NBitcoin, it is good library, but i found something, that i think is bug:
public class InventoryVector : Payload, IBitcoinSerializable
ref: https://github.com/MetacoSA/NBitcoin/blob/602dea5ed312e5a7e3bca639f39690cf185b3590/NBitcoin/Protocol/InventoryVector.cs#L25Why class
InventoryVector
inherit fromPayload
? I think thatInventoryVector
is not stand alone Bitcoin message, it is only part of the message (e.g.InventoryPayload
) - so I think thatInventoryVector
is notPayload
- it is onlyIBitcoinSerializable
- it doesn't haveCommand
(whichPayload
expect).The reason I found that is, it isn't json serializable: code:
Exception:
Thank you for helping me! :)