Capitalisk / ldpos-commander

CLI client for LDPoS blockchains
MIT License
3 stars 2 forks source link

User should be able to verify if a transaction is valid #9

Closed jondubois closed 3 years ago

jondubois commented 3 years ago

User should be able to verify if a transaction is valid (check the signature).

maarteNNNN commented 3 years ago
verifyTransaction(transaction) {
    if (!this.verifyTransactionId(transaction)) {
      return false;
    }
    let { senderSignature, signatures, ...transactionWithoutSignatures } = transaction;
    let transactionJSON = this.stringifyObject(transactionWithoutSignatures);
    return this.merkle.verify(transactionJSON, senderSignature, transaction.sigPublicKey);
 }

I need to understand better what this does.

jondubois commented 3 years ago

The verifyTransaction method just checks that the transaction is valid. It checks that:

But to ensure that a transaction is signed by a specific account, you would also need to check that the sigPublicKey on the transaction corresponds to the sigPublicKey on the account (based on the blockchain data). You can use the getAccount method on the JS client to get the account details (including their sigPublicKey) from a node and check that it matches the sigPublicKey from the transaction.

jondubois commented 3 years ago

That said, I think maybe we can not implement this feature right now. It's probably best left to later. I can't remember what the use case was for this feature.

jondubois commented 3 years ago

I think we can close this issue as it is not very useful.