LiskArchive / lisk-sdk

🔩 Lisk software development kit
https://lisk.com
Apache License 2.0
2.72k stars 455 forks source link

codec.decode cannot parse params #9129

Closed 1029219814 closed 1 year ago

1029219814 commented 1 year ago

Hi, when I use the following code to decode rawTx data, I successfully completed the first step of parsing baseTransactionSchema and obtained the decodedTransaction, but when I ran the second step of validParamsSchema and tried to parse decodedTransaction.params, there appeared message: "Invalid wiretype while decoding." error. what should I do?

let decodedTransaction = liskhq.codec.decode(baseTransactionSchema, Buffer.from(req.body.rawTx, 'hex')); console.log(decodedTransaction) const decodedParams = liskhq.codec.decode(validParamsSchema, decodedTransaction.params);

CleanShot 2023-11-01 at 22 19 13@2x
shuse2 commented 1 year ago

Thanks for creating an issue @1029219814 ! Could you tell me what is the validParamsSchema you are using here?

1029219814 commented 1 year ago

Thanks for creating an issue @1029219814 ! Could you tell me what is the validParamsSchema you are using here?

thanks, this is my validParamsSchema const validParamsSchema = { $id: '/lisk/transferTransaction', title: 'Transfer transaction params', type: 'object', required: ['amount', 'recipientAddress', 'data'], properties: { amount: { dataType: 'uint64', fieldNumber: 1, }, recipientAddress: { dataType: 'bytes', fieldNumber: 2, minLength: 20, maxLength: 20, }, data: { dataType: 'string', fieldNumber: 3, minLength: 0, maxLength: 64, }, }, };

1029219814 commented 1 year ago

Thanks for creating an issue @1029219814 ! Could you tell me what is the validParamsSchema you are using here?

Also, this is my signature data0a05746f6b656e12087472616e7366657218022080ade2042a20c6cc1730cb18a29d21ff98d9746403c5b22496ea2dd0e6a2d0169f0282222c2d322 70a0801000000000000001080c2d72f1a1461ca18a0d757793f81e569e42966b0b2c28b7ed222003a40bc0959e7b7d9367fb573cb1c05f430d6d3e262e1e6 1547eb96f48ac91f556283b4f6eb8ec2397d6c576be34be4deb7695e303f25760e562484e48fe1333c990d, which is generated on the test network