File tree Expand file tree Collapse file tree 1 file changed +8
-10
lines changed Expand file tree Collapse file tree 1 file changed +8
-10
lines changed Original file line number Diff line number Diff line change @@ -156,15 +156,13 @@ function useSendPayment () {
156156 WALLET_SEND_PAYMENT_TIMEOUT_MS )
157157
158158 // some wallets like Coinos will always immediately return success without providing the preimage
159- if ( preimage ) {
160- if ( ! verifyPreimage ( invoice , preimage ) ) {
161- logger . warn ( 'wallet returned success with invalid proof of payment' )
162- } else {
163- logger . ok ( `↗ payment sent: ${ formatSats ( invoice . satsRequested ) } ` )
164- }
165- } else {
166- logger . warn ( 'wallet returned success without proof of payment' )
159+ if ( ! preimage ) {
160+ return logger . warn ( 'wallet returned success without proof of payment' )
161+ }
162+ if ( ! verifyPreimage ( invoice . hash , preimage ) ) {
163+ return logger . warn ( 'wallet returned success with invalid proof of payment' )
167164 }
165+ logger . ok ( `↗ payment sent: ${ formatSats ( invoice . satsRequested ) } ` )
168166 } catch ( err ) {
169167 // we don't log the error here since we want to handle receiver errors separately
170168 const message = err . message || err . toString ?. ( )
@@ -173,7 +171,7 @@ function useSendPayment () {
173171 } , [ ] )
174172}
175173
176- function verifyPreimage ( invoice , preimage ) {
174+ function verifyPreimage ( hash , preimage ) {
177175 const preimageHash = Buffer . from ( sha256 ( Buffer . from ( preimage , 'hex' ) ) ) . toString ( 'hex' )
178- return invoice . hash === preimageHash
176+ return hash === preimageHash
179177}
You can’t perform that action at this time.
0 commit comments