MetacoSA / NBitcoin

Comprehensive Bitcoin library for the .NET framework.
MIT License
1.86k stars 840 forks source link

RPCClient.GetBlock (for Litecoin network) method throws when passing block number 2265984 #1125

Closed CoinmaniaExchange closed 1 year ago

CoinmaniaExchange commented 1 year ago

When calling an RPC function on a node running Litecoin Core 0.21.2 (a major update) the GetBlock method throws System.FormatException. Starting from this major update a new mweb field is returned in the response JSON object. Litecoin is no longer compatible with the Bitcoin wire protocol Blockbook uses to deserialize block data. The details of the exception are as follows:
System.FormatException HResult=0x80131537 Message=Unknown transaction optional data Source=NBitcoin StackTrace: at NBitcoin.Transaction.ReadWrite(BitcoinStream stream) at NBitcoin.BitcoinStream.ReadWrite[T](T& data) at NBitcoin.BitcoinStream.ReadWrite[T](List`1& list) at NBitcoin.Block.ReadWrite(BitcoinStream stream) at NBitcoin.BitcoinSerializableExtensions.ReadWrite(IBitcoinSerializable serializable, Stream stream, Boolean serializing, ConsensusFactory consensusFactory, Nullable`1 version) at NBitcoin.Block.Parse(String hex, ConsensusFactory consensusFactory) at NBitcoin.Block.Parse(String hex, Network network) at NBitcoin.RPC.RPCClient.<GetBlockAsync>d__106.MoveNext() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at NBitcoin.RPC.RPCClient.GetBlock(uint256 blockId)
Are you planning to take into account the above change in the library?

twilightrus commented 1 year ago

+1

NicolasDorier commented 1 year ago

making new version with the fix

NicolasDorier commented 1 year ago

Pushed on 3.0.15, reopen if still an issue, didn't test it