Changeset View
Changeset View
Standalone View
Standalone View
web/cashtab/src/components/Send/Send.js
Show First 20 Lines • Show All 57 Lines • ▼ Show 20 Lines | |||||
import { | import { | ||||
TokenParamLabel, | TokenParamLabel, | ||||
MessageVerificationParamLabel, | MessageVerificationParamLabel, | ||||
} from 'components/Common/Atoms'; | } from 'components/Common/Atoms'; | ||||
import { PlusSquareOutlined } from '@ant-design/icons'; | import { PlusSquareOutlined } from '@ant-design/icons'; | ||||
import styled from 'styled-components'; | import styled from 'styled-components'; | ||||
import WalletLabel from 'components/Common/WalletLabel.js'; | import WalletLabel from 'components/Common/WalletLabel.js'; | ||||
import { ThemedCopySolid } from 'components/Common/CustomIcons'; | import { ThemedCopySolid } from 'components/Common/CustomIcons'; | ||||
import xecMessage from 'xecjs-message'; | |||||
const { TextArea } = Input; | const { TextArea } = Input; | ||||
const SignMessageLabel = styled.div` | const SignMessageLabel = styled.div` | ||||
text-align: left; | text-align: left; | ||||
color: ${props => props.theme.forms.text}; | color: ${props => props.theme.forms.text}; | ||||
`; | `; | ||||
▲ Show 20 Lines • Show All 603 Lines • ▼ Show 20 Lines | const handleVerifySigChange = e => { | ||||
setMessageVerificationSigError('Invalid signature'); | setMessageVerificationSigError('Invalid signature'); | ||||
} | } | ||||
setMessageVerificationSig(value); | setMessageVerificationSig(value); | ||||
}; | }; | ||||
const verifyMessageBySig = async () => { | const verifyMessageBySig = async () => { | ||||
let verification; | let verification; | ||||
let newVerification; | |||||
try { | try { | ||||
verification = await bchObj.BitcoinCash.verifyMessage( | verification = await bchObj.BitcoinCash.verifyMessage( | ||||
toLegacyCash(messageVerificationAddr), | toLegacyCash(messageVerificationAddr), | ||||
messageVerificationSig, | messageVerificationSig, | ||||
messageVerificationMsg, | messageVerificationMsg, | ||||
); | ); | ||||
newVerification = xecMessage.verify( | |||||
messageVerificationMsg, | |||||
messageVerificationAddr, | |||||
messageVerificationSig, | |||||
); | |||||
} catch (err) { | } catch (err) { | ||||
console.log(`Error in verifyMessageBySig`, err); | |||||
errorNotification( | errorNotification( | ||||
'Error', | 'Error', | ||||
'Unable to execute signature verification', | 'Unable to execute signature verification', | ||||
); | ); | ||||
} | } | ||||
if (verification === newVerification) { | |||||
console.log( | |||||
`Both signature verification methods return the same result`, | |||||
); | |||||
} else { | |||||
console.log(`legacy verification method returned`, verification); | |||||
console.log(`new verification method returned`, newVerification); | |||||
} | |||||
if (verification) { | if (verification) { | ||||
generalNotification('Signature successfully verified', 'Verified'); | generalNotification('Signature successfully verified', 'Verified'); | ||||
} else { | } else { | ||||
errorNotification( | errorNotification( | ||||
'Error', | 'Error', | ||||
'Signature does not match address and message', | 'Signature does not match address and message', | ||||
); | ); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 657 Lines • Show Last 20 Lines |