Skip to content
This repository has been archived by the owner on Apr 15, 2019. It is now read-only.

Could not sign transaction: Could not parse transaction JSON. #605

Closed
got3nks opened this issue Sep 3, 2018 · 13 comments
Closed

Could not sign transaction: Could not parse transaction JSON. #605

got3nks opened this issue Sep 3, 2018 · 13 comments

Comments

@got3nks
Copy link

got3nks commented Sep 3, 2018

When trying to sign a transaction executing lisk in command line mode the transaction is not parsed correctly.

lisk@server:~$ lisk sign transaction '{"amount":"10000000","recipientId":"xxxx","senderPublicKey":"2b3c..27","timestamp":71864464,"type":0,"fee":"10000000","recipientPublicKey":null,"asset":{},"signature":"7b48..106","id":"12891..."}'
{"error":"Could not sign transaction: Could not parse transaction JSON."}

The same command works if using lisk in interactive mode, using exactly the same string.

lisk@server:~$ lisk
Lisk Commander  Copyright (C) 2017–2018  Lisk Foundation
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w`.
This is free software, and you are welcome to redistribute it under certain conditions; type `show c` for details.

 _      _     _       _____                                          _
| |    (_)   | |     / ____|                                        | |
| |     _ ___| | __ | |     ___  _ __ ___  _ __ ___   __ _ _ __   __| | ___ _ __
| |    | / __| |/ / | |    / _ \| '_ ` _ \| '_ ` _ \ / _` | '_ \ / _` |/ _ \ '__|
| |____| \__ \   <  | |___| (_) | | | | | | | | | | | (_| | | | | (_| |  __/ |
|______|_|___/_|\_\  \_____\___/|_| |_| |_|_| |_| |_|\__,_|_| |_|\__,_|\___|_|

Running v1.0.0.
Type `help` to get started.

lisk> sign transaction '{"amount":"10000000","recipientId":"xxxx","senderPublicKey":"2b3c..27","timestamp":71864464,"type":0,"fee":"10000000","recipientPublicKey":null,"asset":{},"signature":"7b48..106","id":"12891..."}'
Please enter your secret passphrase: ***
Please re-enter your secret passphrase: ***
@shuse2
Copy link
Contributor

shuse2 commented Sep 3, 2018

@got3nks
Thank you for reporting.

It is coming from underling library vorpal, which we are replacing in 2.0.0.

./bin/lisk sign transaction '{"amount":"10000000","recipientId":"123L","senderPublicKey":"2b3c27","timestamp":71864464,"type":0,"fee":"10000000","recipientPublicKey":null,"asset":{},"signature":"7b48106","id":"12891"}'

if you single quote like above, it will return { as an argument.

It will be fixed on 2.0.0

@got3nks
Copy link
Author

got3nks commented Sep 3, 2018

Any workaround until 2.0.0 is released?

@willclarktech
Copy link
Contributor

@got3nks It should work in interactive mode: we've experienced similar inconsistencies along these lines before, which is part of the reason we're switching frameworks from vorpal to oclif.

@got3nks
Copy link
Author

got3nks commented Sep 3, 2018

We started using lisk-commander in CLI mode to integrate the new version of Lisk Core (version 1.x) which has deprecated API calls we were using before. This looked like the easiest way to create an account, create and sign transactions.
Of course it can't be used in interactive mode for that purpose.

@shuse2
Copy link
Contributor

shuse2 commented Sep 3, 2018

@got3nks
I will look into it and check if it's fixable in vorpal library

@shuse2
Copy link
Contributor

shuse2 commented Sep 4, 2018

@got3nks
I found the cause of the problem.
https://github.com/LiskHQ/vorpal/blob/master/lib/util.js#L23
In here it's parsing the arguments, but by the time it receives the argument,
'{"some": "json"}' will become {"some": "json"} without quotes.
Therefore, it will split the argument into further chunks.

In order to avoid that, ugly workaround would be to
\''{"some": "json"}'\' put escaped single quotes around them, then it will be recognise as a string.

Since it's an ugly workaround, I will not close this issue, and make sure it's fixed in 2.0

@shuse2 shuse2 self-assigned this Sep 4, 2018
@got3nks
Copy link
Author

got3nks commented Sep 5, 2018

It worked, thanks @shuse2!

@got3nks
Copy link
Author

got3nks commented Sep 5, 2018

Unfortunately, we are getting this error when submitting the signed transaction to our Lisk node (POST /api/transactions)

{"message":"Failed to verify signature"}

Tried to create the transaction and sign it in interactive mode too but same error is returned. Is the secret passphrase required by lisk-commander the same as the mnemonic seed (BIP39 words)?

@shuse2
Copy link
Contributor

shuse2 commented Sep 5, 2018

In commander, we do not enforce the mnemonic passphrase now.
You can use any passphrase that you created.

I have tried the same procedure on the 1.0.0 version, but it works fine for me.

what is the procedure that you did from creating the transaction to signing it?

@got3nks
Copy link
Author

got3nks commented Sep 5, 2018

lisk> create transaction transfer 0.1 receiverAddress

When prompting Please enter your secret passphrase: I'm using the mnemonic BIP39 words.

Then

lisk> sign transaction transactionJson where transactionJson is the output of the previous command. Using the same mnemonic when asked for passphrase.

When submitting the signed transaction to the Lisk node I get the mentioned error:
{"message":"Failed to verify signature"}

@willclarktech
Copy link
Contributor

@got3nks If you've provided the passphrase when creating the transaction, it will sign it at the same time, so you don't need to sign it again. (FYI you can also use the --passphrase option to provide the passphrase without a prompt.)

@got3nks
Copy link
Author

got3nks commented Sep 5, 2018

Great, it worked. Thank you.

@shuse2
Copy link
Contributor

shuse2 commented Sep 26, 2018

Closing as this is fixed on latest 2.0.0 branch.

./bin/run transaction:sign '{"amount":"10000000000","recipientId":"100L","senderPublicKey":"a4465fd76c16fcc458448076372abf1912cc5b150663a64dffefe550f96feadd","timestamp":73841175,"type":0,"fee":"10000000","recipientPublicKey":null,"asset":{},"id":"485681146996430875"}'
? Please enter your secret passphrase:  [hidden]
? Please re-enter your secret passphrase:  [hidden]
{
        "amount": "10000000000",
        "recipientId": "100L",
        "senderPublicKey": "a4465fd76c16fcc458448076372abf1912cc5b150663a64dffefe550f96feadd",
        "timestamp": 73841175,
        "type": 0,
        "fee": "10000000",
        "recipientPublicKey": null,
        "asset": {},
        "id": "485681146996430875",
        "signature": "8c2fd2727c1b5fa6fb8c45ca177a92031400e9ac600af923f384518c98eba93146243603a58d9e2276bcb905287b63dec5a5b1492c9037e26f0ce86706eabe0a"
}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants