Closed RazvanBerbece closed 2 years ago
Commit 1a1b93ab7550b1988f34d362995382711c5e90f5 solved the SignTransaction() issue. However, now FullNodeTcpServer returns a "0" response to wallet sending new transaction upstream
It seems the issue is coming from FullNodeTcpServer.cs in HandleDataFromPeer(). The Blockchain deserialization check returns a value instead of null ? It should return null as the received data is transaction data
{
"Sender":"MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCfO8+667Xo8W7MIBMST6THpJ+tJKTPKaUxkdxkLUiB8o4tXD+0Ak/wL7bVOJ1Cg9wE/5mlzcu1TD6E6U3c2J16PdaRCmgCFHRoFfulNuGDZRiQtM5IHqxoBPJchdFWJCJwW415f45+T7aceMEjdfD+PZBdGuED/YpcTLuhQ1SUvwIDAQAB",
"Receiver":"MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDYHEoOrXBjmGT8XQLRoZOLTR5Ce5fOzeMYGqUvsMYSqzJj7sc4XGURqDg3FRBhpveygLmTeBpdUoQrfd4JnIpu03NI+igw96vrpwKy/0gpCYG7NWC5cpLXUTs8Z1qbPMIGpoa4/0WIvwn7UryyFTWP6buqkVRBHgazRoUdx/elcwIDAQAB",
"Amount":1000,
"Id":"92c9516e-491b-469c-8ef9-acf6733085f1",
"Hash":"8c98612000d2527deef3dce37c14a6661cf06ccb0b31516d077f1ead79b73806",
"Signature":"Hq6Kjwlgv/m9xlrmQqa7sT04dYOxbh3fEIhRoTGLpdTWceIQfKUH0svOxfRtlDaKP6l+zNHn6hvCvsi92PsGf0YXMUqVog5Eh1qdrZyZRy5d9d2bi4s2PevYtuNYGkRoXH/p9wP4uvWk2lpk7OFizMDvYxYUoY50tHByPfL5sc4="
}
Still trying to fix the failed deserialization to Transaction
.
When receivedData
is used as param in Static Blockchain
creators, it seems that Blockchain.Deserialize
DOES NOT return null, which should definitely be the case ! To investigate further.
{
"FromIp": "192.168.0.1",
"ToIp": "82.26.1.87",
"Timestamp": "2022-06-28T23:41:14.613533+01:00",
"Data": "GET BALANCE MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCfO8+667Xo8W7MIBMST6THpJ+tJKTPKaUxkdxkLUiB8o4tXD+0Ak/wL7bVOJ1Cg9wE/5mlzcu1TD6E6U3c2J16PdaRCmgCFHRoFfulNuGDZRiQtM5IHqxoBPJchdFWJCJwW415f45+T7aceMEjdfD+PZBdGuED/YpcTLuhQ1SUvwIDAQAB",
"TrafficDirection": "In"
}
---------------------------------------------------------------------------------------------------------------------------------------------------------------
{
"FromIp": "192.168.0.1",
"ToIp": "82.26.1.87",
"Timestamp": "2022-06-28T23:41:24.236374+01:00",
"Data": "{\n \"Sender\": \"MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCfO8+667Xo8W7MIBMST6THpJ+tJKTPKaUxkdxkLUiB8o4tXD+0Ak/wL7bVOJ1Cg9wE/5mlzcu1TD6E6U3c2J16PdaRCmgCFHRoFfulNuGDZRiQtM5IHqxoBPJchdFWJCJwW415f45+T7aceMEjdfD+PZBdGuED/YpcTLuhQ1SUvwIDAQAB\",\n \"Receiver\": \"MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDYHEoOrXBjmGT8XQLRoZOLTR5Ce5fOzeMYGqUvsMYSqzJj7sc4XGURqDg3FRBhpveygLmTeBpdUoQrfd4JnIpu03NI+igw96vrpwKy/0gpCYG7NWC5cpLXUTs8Z1qbPMIGpoa4/0WIvwn7UryyFTWP6buqkVRBHgazRoUdx/elcwIDAQAB\",\n \"Amount\": 11000,\n \"Id\": \"55082f0c-ae20-4d8a-80d3-8432b755254f\",\n \"Hash\": \"1441004c87d8d0bafbf64f72c794f4d14135fa6a3b5ca7d9f138ad8a359da04d\",\n \"Signature\": \"T0vQZBtOZko1cfGHvKBKWTAOsDUZS+6QhA7yXlnGpXylisK7h5QjHwmt5sIzQpv1n+EQu4YRlpdsrnKGfY/yAhYOf9ypDHZj5h+RlejygcqP3IWtY1k4l94g/SQO/YIsV1h5PuGcxRk/S+tnxulTBW0SOAoj8Iz6Bci30rT2YzY=\"\n}",
"TrafficDirection": "In"
}
---------------------------------------------------------------------------------------------------------------------------------------------------------------
{
"FromIp": "192.168.0.1",
"ToIp": "82.26.1.87",
"Timestamp": "2022-06-28T23:43:58.16433+01:00",
"Data": "GET BALANCE MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCfO8+667Xo8W7MIBMST6THpJ+tJKTPKaUxkdxkLUiB8o4tXD+0Ak/wL7bVOJ1Cg9wE/5mlzcu1TD6E6U3c2J16PdaRCmgCFHRoFfulNuGDZRiQtM5IHqxoBPJchdFWJCJwW415f45+T7aceMEjdfD+PZBdGuED/YpcTLuhQ1SUvwIDAQAB",
"TrafficDirection": "In"
}
---------------------------------------------------------------------------------------------------------------------------------------------------------------
{
"FromIp": "192.168.0.1",
"ToIp": "82.26.1.87",
"Timestamp": "2022-06-28T23:44:13.023168+01:00",
"Data": "{\n \"Sender\": \"MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCfO8+667Xo8W7MIBMST6THpJ+tJKTPKaUxkdxkLUiB8o4tXD+0Ak/wL7bVOJ1Cg9wE/5mlzcu1TD6E6U3c2J16PdaRCmgCFHRoFfulNuGDZRiQtM5IHqxoBPJchdFWJCJwW415f45+T7aceMEjdfD+PZBdGuED/YpcTLuhQ1SUvwIDAQAB\",\n \"Receiver\": \"MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDYHEoOrXBjmGT8XQLRoZOLTR5Ce5fOzeMYGqUvsMYSqzJj7sc4XGURqDg3FRBhpveygLmTeBpdUoQrfd4JnIpu03NI+igw96vrpwKy/0gpCYG7NWC5cpLXUTs8Z1qbPMIGpoa4/0WIvwn7UryyFTWP6buqkVRBHgazRoUdx/elcwIDAQAB\",\n \"Amount\": 11000,\n \"Id\": \"91d554c7-5ac0-406d-b34c-530ae7a8fd24\",\n \"Hash\": \"9b84ec2433044e4a0a16e2bc0090f09afa85d8104d723586049187a6cfe01c7b\",\n \"Signature\": \"EML4DQYAWSaz+hh6e1BES5ujGvW+DjAuXxBc8ZhUXQbXVGD8Azo7kFdWlD+l9C0hwOxV8U4Fm1mn9twX5nxO39PcuAr4BxG69joJc9oGlgBqgPpNKz3ODt8cnUQ/uhf4qg2Ap8MvH9P4rXbVIbV4IxL8OP9GnvKXpGsBjeQ6aFs=\"\n}",
"TrafficDirection": "In"
}
---------------------------------------------------------------------------------------------------------------------------------------------------------------
Fixed as of 5286b7d9eb5d20f88385dbaa0d9f09ca598231d9.
The issue was that the deserializer for Transaction
and Blockchain
were not using MissingMemberHandling = MissingMemberHandling.Error
to throw when deserialization would fail because of missing fields.
After changing to JsonConvert.DeserializeObject
, it worked, as now the deserialization methods return null
when appropiate.
Next Steps
Check the
Wallet(string, string, string = def)
constructor in theWallet
class. This issue probably has something to do with how the public and private keys are loaded. The underlyingRSACryptoServiceProvider
might need more configs passed to it to create the correct object and respectively the correct "value" forrsa.ImportParameters(wallet.GetKeyPairParams());
Stack Trace
Error occured in SignTransaction(): System.Security.Cryptography.CryptographicException: Value was invalid. at System.Security.Cryptography.RSACryptoServiceProvider.ImportParameters(RSAParameters parameters) at TransactionNS.Transaction.SignTransaction(Wallet wallet) in /Users/razvan-antonioberbece/Desktop/Projects/Blockchain/ZRD/ZRD - TESTING 1/src/Transaction/Transaction.cs:line 72
Transaction Example