-
Notifications
You must be signed in to change notification settings - Fork 19
Fix handling of empty payment IDs #621
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -45,13 +45,12 @@ export const shouldTriggerOnSuccess = ( | |
| let isPaymentIdValid = true | ||
| let isOpReturnValid = true | ||
|
|
||
| if(!randomSatoshis || randomSatoshis === 0){ | ||
| if(!isBCH){ | ||
| const paymentIdsMatch = expectedPaymentId === paymentId; | ||
| if(!isBCH){ | ||
| if(!randomSatoshis || randomSatoshis === 0){ | ||
| const paymentIdsMatch = !!expectedPaymentId && expectedPaymentId === paymentId; | ||
| isPaymentIdValid = disablePaymentId ? true : paymentIdsMatch; | ||
|
Comment on lines
+50
to
51
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: rg -n --type=ts -A 10 -B 2 'shouldTriggerOnSuccess\s*\('Repository: PayButton/paybutton Length of output: 15179 🏁 Script executed: rg -n --type=ts -C 5 'disablePaymentId'Repository: PayButton/paybutton Length of output: 50375 🏁 Script executed: sed -n '87,113p' react/lib/tests/util/validate.test.tsRepository: PayButton/paybutton Length of output: 975 🏁 Script executed: sed -n '42,85p' react/lib/tests/util/validate.test.tsRepository: PayButton/paybutton Length of output: 1407 🏁 Script executed: sed -n '87,115p' react/lib/tests/util/validate.test.tsRepository: PayButton/paybutton Length of output: 1131 🏁 Script executed: # Also check the full validate.ts function to understand all validation steps
cat -n react/lib/util/validate.ts | head -65Repository: PayButton/paybutton Length of output: 2735 🏁 Script executed: # Check how PayButton sets up the checkSuccessInfo and what paymentId/disablePaymentId values flow through
sed -n '130,320p' react/lib/components/PayButton/PayButton.tsx | grep -A 50 -B 5 'checkSuccessInfo'Repository: PayButton/paybutton Length of output: 645 🏁 Script executed: # Check how thisPaymentId is determined in PayButton
sed -n '130,250p' react/lib/components/PayButton/PayButton.tsx | grep -B 10 -A 3 'thisPaymentId\|paymentId ='Repository: PayButton/paybutton Length of output: 45 🏁 Script executed: # Look at PayButton's useState and variable initialization for paymentId and disablePaymentId
sed -n '64,130p' react/lib/components/PayButton/PayButton.tsxRepository: PayButton/paybutton Length of output: 2377 🏁 Script executed: # Check WidgetContainer logic around line 111 and how it determines disablePaymentId
sed -n '106,220p' react/lib/components/Widget/WidgetContainer.tsxRepository: PayButton/paybutton Length of output: 3742 🏁 Script executed: # Check the test expectations more carefully - does it expect true or false?
sed -n '87,130p' react/lib/tests/util/validate.test.ts | tail -40Repository: PayButton/paybutton Length of output: 1488 🏁 Script executed: # Check PayButton getPaymentId logic to confirm when paymentId is actually set
sed -n '136,162p' react/lib/components/PayButton/PayButton.tsxRepository: PayButton/paybutton Length of output: 872 🏁 Script executed: # Check WidgetContainer initialization of paymentId and disablePaymentId flow
sed -n '154,250p' react/lib/components/Widget/WidgetContainer.tsx | grep -A 3 -B 3 'paymentId\|disablePaymentId'Repository: PayButton/paybutton Length of output: 505 🏁 Script executed: # Check what isPropsTrue does
rg -n 'function isPropsTrue|const isPropsTrue' react/lib/Repository: PayButton/paybutton Length of output: 149 🏁 Script executed: # Check isPropsTrue implementation
sed -n '66,75p' react/lib/util/format.tsRepository: PayButton/paybutton Length of output: 282 🏁 Script executed: # Check if Widget/WidgetContainer has logic to fetch paymentId like PayButton does
rg -n 'getPaymentId\|createPayment' react/lib/components/Widget/Repository: PayButton/paybutton Length of output: 45 🏁 Script executed: # Check if there's a way paymentId gets generated in WidgetContainer - check for useEffect with paymentId
sed -n '300,450p' react/lib/components/Widget/WidgetContainer.tsx | grep -A 20 'useEffect'Repository: PayButton/paybutton Length of output: 1509 🏁 Script executed: # Check Widget.tsx to see if it has paymentId generation logic
rg -n 'getPaymentId\|createPayment' react/lib/components/Widget/Widget.tsxRepository: PayButton/paybutton Length of output: 45 🏁 Script executed: # Search for where internalPaymentId gets set in WidgetContainer or if there's initialization logic
rg -n 'setInternalPaymentId\|setPaymentId' react/lib/components/Widget/WidgetContainer.tsxRepository: PayButton/paybutton Length of output: 45 🏁 Script executed: # Check if WidgetContainer has any effect that initializes paymentId
sed -n '250,400p' react/lib/components/Widget/WidgetContainer.tsx | head -80Repository: PayButton/paybutton Length of output: 2127 🏁 Script executed: # Get the full context of WidgetContainer to understand the complete flow from start to when shouldTriggerOnSuccess is called
wc -l react/lib/components/Widget/WidgetContainer.tsxRepository: PayButton/paybutton Length of output: 114 🏁 Script executed: # Check the signature and props of WidgetContainer to see if paymentId is passed in
sed -n '20,50p' react/lib/components/Widget/WidgetContainer.tsxRepository: PayButton/paybutton Length of output: 981 🏁 Script executed: # Check how PayButton initializes and manages the socket setup with checkSuccessInfo
sed -n '290,320p' react/lib/components/PayButton/PayButton.tsxRepository: PayButton/paybutton Length of output: 868 🏁 Script executed: # Final check: look at the test setup for the critical case - what does the test comment say?
sed -n '87,120p' react/lib/tests/util/validate.test.tsRepository: PayButton/paybutton Length of output: 1340 🏁 Script executed: # Verify the complete picture - check if there are any other callers besides PayButton and WidgetContainer
rg -n 'new WidgetContainer\|<WidgetContainer' react/lib/Repository: PayButton/paybutton Length of output: 45 Verify that WidgetContainer honors the implicit The fix correctly prevents false positives by requiring This is safe in PayButton (which calls The test at lines 87-120 confirms this contract is intentional—the comment states: "Payment IDs are not set when the button is built so any tx with the same address and amount could match." Ensure WidgetContainer always sets 🤖 Prompt for AI Agents |
||
| } | ||
| } | ||
| if(!isBCH){ | ||
|
|
||
| const rawOpReturnIsEmptyOrUndefined = rawOpReturn === '' || rawOpReturn === undefined; | ||
| const opReturn = rawOpReturnIsEmptyOrUndefined ? message : rawOpReturn | ||
| const opReturnIsEmptyOrUndefined = opReturn === '' || opReturn === undefined; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
%splaceholders produce identical, unreadable test names for object-basedtest.eachrows.Jest's
$variablesyntax is required for object rows, and "you cannot use$variablewith the printf formatting except for%%" — i.e.%sis only forArray<Array>rows where each element maps to a positional argument. WithArray<Object>rows, all three%sresolve to[object Object], so all four matrix cases will surface with the same name when one fails, making it impossible to identify which combination broke.🐛 Proposed fix — use `$propertyName` syntax
📝 Committable suggestion
🤖 Prompt for AI Agents