lnp2pBot / bot

Peer-to-peer lightning network telegram bot
MIT License
212 stars 106 forks source link

Convert JS to TS (commits 7-13 of PR435) - attempt#2 #585

Closed webwarrior-ws closed 1 month ago

webwarrior-ws commented 2 months ago

Supersedes #557. Added a commit that should fix bug in disputes.

webwarrior-ws commented 2 months ago

The bugs should be fixed now, but I haven't tested.

webwarrior-ws commented 2 months ago

It also happened to me that the wizard_add_invoice_init message was not being sent in any order even though it entered the wizard because any command or invoice that I sent to it would delete it. However, I stopped it and started it again and it worked.

Not sure about this one. Maybe it was because validateAdmin failed.

Catrya commented 2 months ago

Hola@webwarrior-ws @Mersho Cuando el administrador va a tomar una disputa aparece este error en los registros:

[2024-09-04T10:09:59.680-04:00] error: Community was not found in DB Error: Community was not found in DB
    at /home/catry/bot/bot/validations.js:208:27
    at step (/home/catry/bot/bot/validations.js:56:23)
    at Object.next (/home/catry/bot/bot/validations.js:37:53)
    at fulfilled (/home/catry/bot/bot/validations.js:28:58)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

This error has already been solved

webwarrior-ws commented 2 months ago

Al enviar una factura para recibir, siempre devuelve este error al comprador:Invoice expiry is too short

@webwarrior-ws @Mersho That error is still there, it always says Invoice expiry is too short but if I change to or any other branch and put the same invoice it accepts it without problem

I tried with my test setup and could not reproduce this bug.

Catrya commented 2 months ago

@grunch could you try to reproduce it? I can't get that error not to appear, thanks :)

webwarrior-ws commented 2 months ago

Added some debug logging. Maybe that will help with identifying the problem.

Catrya commented 2 months ago

Added some debug logging. Maybe that will help with identifying the problem.

Well, the bot did not show the wizard_add_invoice_init message and this error appeared: [2024-09-09T09:49:10.191-04:00] error: All promises were rejected AggregateError: All promises were rejected

But I knew it was 500 sats so I put the invoice and this appears:

Date(invoice.expires_at) = Mon Sep 09 2024 10:49:28 GMT-0400 (hora de verano de Cuba)
latestDate = Mon Sep 09 2024 10:49:47 GMT-0400 (hora de verano de Cuba)
INVOICE_EXPIRATION_WINDOW = 3600000
webwarrior-ws commented 2 months ago

I don't see any bug in lnp2pBot code here. Invoice expires less than INVOICE_EXPIRATION_WINDOW (1 hour) from time of running, and that results in error. I don't know why main branch doesn't result in error in the same scenario. Maybe this code never worked as intended? I noticed that in original code, Date is compared to string.

knocte commented 2 months ago

Maybe this code never worked as intended? I noticed that in original code, Date is compared to string.

Looks like we need @grunch's input here?

grunch commented 2 months ago

Hi guys!

I'm testing it, after I take a dispute of an order created in the global channel is works perfectly, after I take a dispute of an order created on a community it doesn't work, here the log

[2024-09-10T11:48:18.398-03:00] error: 400: Bad Request: can't parse entities: Character '.' is reserved and must be escaped with the preceding '\' Error: 400: Bad Request: can't parse entities: Character '.' is reserved and must be escaped with the preceding '\'
    at Telegram.callApi (/home/grunch/dev/bot-warrior/node_modules/telegraf/lib/core/network/client.js:264:19)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async exports.disputeData (/home/grunch/dev/bot-warrior/bot/modules/dispute/messages.js:90:5)
    at async exports.takeDispute (/home/grunch/dev/bot-warrior/bot/modules/dispute/actions.js:39:3)
    at async execute (/home/grunch/dev/bot-warrior/node_modules/telegraf/lib/composer.js:468:17)
    at async /home/grunch/dev/bot-warrior/node_modules/telegraf/lib/composer.js:469:21
webwarrior-ws commented 2 months ago

@grunch I have tried to reproduce the bug, but I can't take a dispute - when I click on "Take dispute" button I get a message "You have been banned!". As I only have 2 telegram accounts, solver user is one of the participants, maybe that's the issue?

webwarrior-ws commented 2 months ago

Me and @knocte managed to take and resolve dispute in community. That error looks like contents of some variable is not escaped properly. I've seen a commit in main that adds escaping. I rebased this branch. Maybe this will also solve the bug. If not, I added a commit that dumps contents of the problematic message into console.

grunch commented 2 months ago

@grunch I have tried to reproduce the bug, but I can't take a dispute - when I click on "Take dispute" button I get a message "You have been banned!". As I only have 2 telegram accounts, solver user is one of the participants, maybe that's the issue?

Yes, we ban users after being involved on n disputes, I think that restriction is not useful and we should remove it in the future, but to continue just remove the ban on the document for that user, change field banned to false, then try again

knocte commented 2 months ago

change field banned to false, then try again

Francisco, that is old info. After webwarrior wrote that message, I assisted him in his testing, being the 3rd user in his setup (the solver, in particular), and he couldn't reproduce the issue. See https://github.com/lnp2pBot/bot/pull/585#issuecomment-2346186472 , and test again with the new logs added please.

grunch commented 2 months ago

@grunch I have tried to reproduce the bug, but I can't take a dispute - when I click on "Take dispute" button I get a message "You have been banned!". As I only have 2 telegram accounts, solver user is one of the participants, maybe that's the issue?

Hi @webwarrior-ws sorry for the delay, are you able to run the bot in this branch? I'm testing and I'm getting this errors

[2024-09-16T17:22:26.672-03:00] error: ResubcribeInvoice catch: 503,UnexpectedGetInvoicesError,[object Object] 
[2024-09-16T17:23:00.027-03:00] error: 503,FailedToConnectToDaemon 
[2024-09-16T17:23:00.028-03:00] error: node info catch error: TypeError: Cannot read properties of undefined (reading 'is_synced_to_chain') 
[2024-09-16T17:24:00.022-03:00] error: 503,FailedToConnectToDaemon 
[2024-09-16T17:24:00.022-03:00] error: node info catch error: TypeError: Cannot read properties of undefined (reading 'is_synced_to_chain') 

I that we are having conflics, can you solve them and we can try again?

webwarrior-ws commented 2 months ago

@grunch I've rebased PR branch and there are no merge conflicts now. I've also tested it with standard sell/buy procedure and got no 503 errors that you have mentioned.

webwarrior-ws commented 1 month ago

@grunch applied your patch, updated locales and disputes test

grunch commented 1 month ago

@grunch applied your patch, updated locales and disputes test

great job, thanks for this contribution, as we are receiving some donations we want to give back some sats to our contributors, it's more of a symbolic gesture of gratitude 😃

Please add as a comment a lightning invoice with amount of 200,000 sats

webwarrior-ws commented 1 month ago

lnbc2m1pn0dtz0pp5ru28d55mfjw2aypjvsu7xnd5uj7363mz095slnwmca05mcequ9nscqpjsp5vuprh07ze5nk2k6rhx7zjy67axfqmsej9gmt6a7zudhsy7ej8zas9q7sqqqqqqqqqqqqqqqqqqqsqqqqqysgqdqqmqz9gxqyjw5qrzjqwryaup9lh50kkranzgcdnn2fgvx390wgj5jd07rwr3vxeje0glcll6lyxlsu4fuhqqqqqlgqqqqqeqqjqu7s52ap9967fnyvqc9nphcccsqpl3txa679zpzw2f0h6gwqhex7qwf5y2eywlmd5wyjx9e7k5ckn2luml34c304mtyuze87zy5mkfdgpmqngrw

grunch commented 1 month ago

lnbc2m1pn0dtz0pp5ru28d55mfjw2aypjvsu7xnd5uj7363mz095slnwmca05mcequ9nscqpjsp5vuprh07ze5nk2k6rhx7zjy67axfqmsej9gmt6a7zudhsy7ej8zas9q7sqqqqqqqqqqqqqqqqqqqsqqqqqysgqdqqmqz9gxqyjw5qrzjqwryaup9lh50kkranzgcdnn2fgvx390wgj5jd07rwr3vxeje0glcll6lyxlsu4fuhqqqqqlgqqqqqeqqjqu7s52ap9967fnyvqc9nphcccsqpl3txa679zpzw2f0h6gwqhex7qwf5y2eywlmd5wyjx9e7k5ckn2luml34c304mtyuze87zy5mkfdgpmqngrw

Payment hash: 1f1476d29b4c9cae90326439e34db4e4bd1d476279690fcddbc75f4de320e167 Payment status: SUCCEEDED, preimage: ed4600e227269b6d29068d1b7eb51e8bd77f9137b94e334e6bcb561b5ffcc7cf