Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Payment Hash to response and better error messages #51

Merged
merged 5 commits into from
Jan 22, 2024

Conversation

jonathanlei
Copy link
Contributor

@jonathanlei jonathanlei commented Dec 19, 2023

High Level Overview of Change

Add Payment Hash to server response
Add more error code logging.
Add env.example and better local testing instructions instead of command line instruction.

Type of Change

  • [
    X] New feature (non-breaking change which adds functionality)

@jonathanlei jonathanlei changed the title add payment Hash Add Payment Hash to response and error messages Dec 19, 2023
src/routes/accounts.ts Outdated Show resolved Hide resolved
src/routes/accounts.ts Outdated Show resolved Hide resolved
@@ -71,10 +71,20 @@ export default async function (req: Request, res: Response) {

try {
let result;
let paymentHash;
try {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move the signing out of the the try. That way you dont have to create the variable paymentHash.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I moved it out, the purpose of having it there is that the hash should be different before and after submitting right? I could have an error statement catching signing errors too.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The hash will be the same before and after

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

then we don't need signing

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Signing is used to add the signature field but that doesnt change the hash as far as I know.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The signature is among the data used to compute a transaction's identifying hash. Adding or changing the signature will change the transaction hash. Relatedly, you can learn about transaction malleability here. Generally speaking, I don't consider any given transaction to have a hash yet if it is not signed (yet).

The hash is the same before and after submitting, if you are submitting a signed transaction.

src/routes/accounts.ts Show resolved Hide resolved
src/types.ts Outdated Show resolved Hide resolved
src/routes/accounts.ts Outdated Show resolved Hide resolved
@jonathanlei jonathanlei changed the title Add Payment Hash to response and error messages Add Payment Hash to response and better error messages Jan 12, 2024
Copy link
Contributor

@intelliot intelliot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is fine, although I have not tested it. Note that after a transaction is signed, it is possible to compute the transaction's hash. Submitting the transaction doesn't change its hash. So the extra assignment should be unnecessary; though I also don't think it would hurt.

@jonathanlei jonathanlei merged commit 3452116 into master Jan 22, 2024
1 check passed
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants