You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When the transaction created by the wallet has some outputs with values larger than MAX_SAFE_INTEGER, sheikah may round them to the nearest valid float and then send an invalid transaction.
For example, creating a transaciton that tries to send 9 million wits:
Using the node CLI, we can calculate the value of the inputs, to summarize:
inputs: 3000000000000000 + 1498028000000009 + 30000000012345680
outputs: 9000000000000000 + 25496909012345690
fee according to sheikah: 1119000000000 (1 wit / weight unit)
However, if we calculate (inputs - outputs), the actual fee is 1118999999999.
The problem is that the change output should be 25496909012345689 instead of 25496909012345690. This can be seen in the following JSON-RPC logs. The first transaction is the one sent from sheikah and it is invalid with error "Failed to verify the signature of transaction". The second transaction is a copy of the first but with that one output manually changed, and it is sent successfully.
{"jsonrpc":"2.0","method":"inventory","params":{"transaction":{"ValueTransfer":{"body":{"inputs":[{"output_pointer":"988ed9952b6d6195f5afdaf4a3d934ee81c45c8eed96f218c49a8637b1b55023:0"},{"output_pointer":"988ed9952b6d6195f5afdaf4a3d934ee81c45c8eed96f218c49a8637b1b55023:1"},{"output_pointer":"6977e18fa4988ae7fc17c4a8462d3cb262153ad23954bd8e0abaa62239fe23fe:0"}],"outputs":[{"pkh":"twit1vfuklxq4p5d7t744evcrj04r68q7j2f8yj0vqx","time_lock":0,"value":9000000000000000},{"pkh":"twit1lq6vc30s9w6lad2gsmqd028z8zdvjs2r4hmdj5","time_lock":0,"value":25496909012345690}]},"signatures":[{"public_key":{"bytes":[223,106,84,98,186,170,171,0,160,129,45,64,26,180,3,239,237,240,218,147,49,140,142,233,52,150,246,61,236,173,139,204],"compressed":3},"signature":{"Secp256k1":{"der":[48,69,2,33,0,205,100,244,242,167,81,242,185,38,28,142,72,232,18,253,42,130,71,241,136,176,181,247,54,136,87,108,211,145,88,49,237,2,32,110,218,235,243,104,253,197,76,219,84,153,217,65,121,37,196,41,218,210,227,155,147,30,172,89,41,252,210,150,65,81,254]}}},{"public_key":{"bytes":[126,11,75,235,151,155,199,96,45,91,211,86,51,229,247,88,255,211,147,94,190,159,117,45,180,192,162,138,116,253,236,225],"compressed":3},"signature":{"Secp256k1":{"der":[48,68,2,32,105,215,154,161,6,160,43,110,16,53,250,204,9,27,247,183,223,81,33,114,95,112,187,126,15,236,58,192,90,182,127,148,2,32,66,181,236,190,29,170,243,236,228,185,13,139,165,253,162,224,132,124,193,101,205,52,151,54,17,19,58,208,42,114,126,225]}}},{"public_key":{"bytes":[223,106,84,98,186,170,171,0,160,129,45,64,26,180,3,239,237,240,218,147,49,140,142,233,52,150,246,61,236,173,139,204],"compressed":3},"signature":{"Secp256k1":{"der":[48,69,2,33,0,205,100,244,242,167,81,242,185,38,28,142,72,232,18,253,42,130,71,241,136,176,181,247,54,136,87,108,211,145,88,49,237,2,32,110,218,235,243,104,253,197,76,219,84,153,217,65,121,37,196,41,218,210,227,155,147,30,172,89,41,252,210,150,65,81,254]}}}]}}},"id":71}
{"jsonrpc":"2.0","error":{"code":-32603,"message":"Failed to verify the signature of transaction 9bb1aecde93a605912d260394e96bf2c4b0918f9ad9c31c22d9afb3ccacda4b7: Fail in verify process"},"id":71}
{"jsonrpc":"2.0","method":"inventory","params":{"transaction":{"ValueTransfer":{"body":{"inputs":[{"output_pointer":"988ed9952b6d6195f5afdaf4a3d934ee81c45c8eed96f218c49a8637b1b55023:0"},{"output_pointer":"988ed9952b6d6195f5afdaf4a3d934ee81c45c8eed96f218c49a8637b1b55023:1"},{"output_pointer":"6977e18fa4988ae7fc17c4a8462d3cb262153ad23954bd8e0abaa62239fe23fe:0"}],"outputs":[{"pkh":"twit1vfuklxq4p5d7t744evcrj04r68q7j2f8yj0vqx","time_lock":0,"value":9000000000000000},{"pkh":"twit1lq6vc30s9w6lad2gsmqd028z8zdvjs2r4hmdj5","time_lock":0,"value":25496909012345689}]},"signatures":[{"public_key":{"bytes":[223,106,84,98,186,170,171,0,160,129,45,64,26,180,3,239,237,240,218,147,49,140,142,233,52,150,246,61,236,173,139,204],"compressed":3},"signature":{"Secp256k1":{"der":[48,69,2,33,0,205,100,244,242,167,81,242,185,38,28,142,72,232,18,253,42,130,71,241,136,176,181,247,54,136,87,108,211,145,88,49,237,2,32,110,218,235,243,104,253,197,76,219,84,153,217,65,121,37,196,41,218,210,227,155,147,30,172,89,41,252,210,150,65,81,254]}}},{"public_key":{"bytes":[126,11,75,235,151,155,199,96,45,91,211,86,51,229,247,88,255,211,147,94,190,159,117,45,180,192,162,138,116,253,236,225],"compressed":3},"signature":{"Secp256k1":{"der":[48,68,2,32,105,215,154,161,6,160,43,110,16,53,250,204,9,27,247,183,223,81,33,114,95,112,187,126,15,236,58,192,90,182,127,148,2,32,66,181,236,190,29,170,243,236,228,185,13,139,165,253,162,224,132,124,193,101,205,52,151,54,17,19,58,208,42,114,126,225]}}},{"public_key":{"bytes":[223,106,84,98,186,170,171,0,160,129,45,64,26,180,3,239,237,240,218,147,49,140,142,233,52,150,246,61,236,173,139,204],"compressed":3},"signature":{"Secp256k1":{"der":[48,69,2,33,0,205,100,244,242,167,81,242,185,38,28,142,72,232,18,253,42,130,71,241,136,176,181,247,54,136,87,108,211,145,88,49,237,2,32,110,218,235,243,104,253,197,76,219,84,153,217,65,121,37,196,41,218,210,227,155,147,30,172,89,41,252,210,150,65,81,254]}}}]}}},"id":71}
{"jsonrpc":"2.0","result":true,"id":71}
After manually fixing the transaction, sheikah indexes it and shows it, but we can see how the value of the second output and the fee are wrong:
The text was updated successfully, but these errors were encountered:
When the transaction created by the wallet has some outputs with values larger than MAX_SAFE_INTEGER, sheikah may round them to the nearest valid float and then send an invalid transaction.
For example, creating a transaciton that tries to send 9 million wits:
Using the node CLI, we can calculate the value of the inputs, to summarize:
However, if we calculate (inputs - outputs), the actual fee is 1118999999999.
The problem is that the change output should be 25496909012345689 instead of 25496909012345690. This can be seen in the following JSON-RPC logs. The first transaction is the one sent from sheikah and it is invalid with error "Failed to verify the signature of transaction". The second transaction is a copy of the first but with that one output manually changed, and it is sent successfully.
After manually fixing the transaction, sheikah indexes it and shows it, but we can see how the value of the second output and the fee are wrong:
The text was updated successfully, but these errors were encountered: