Changeset View
Changeset View
Standalone View
Standalone View
cashtab/src/components/SignVerifyMsg/SignVerifyMsg.js
Show First 20 Lines • Show All 82 Lines • ▼ Show 20 Lines | const SignVerifyMsg = () => { | ||||
const [messageVerificationSigIsValid, setMessageVerificationSigIsValid] = | const [messageVerificationSigIsValid, setMessageVerificationSigIsValid] = | ||||
useState(false); | useState(false); | ||||
const [messageVerificationSigError, setMessageVerificationSigError] = | const [messageVerificationSigError, setMessageVerificationSigError] = | ||||
useState(false); | useState(false); | ||||
const signMessageByPk = () => { | const signMessageByPk = () => { | ||||
try { | try { | ||||
// First, get required params | // First, get required params | ||||
const keyPair = utxolib.ECPair.fromWIF( | const keyPair = utxolib.ECPair.fromWIF( | ||||
wallet.paths.find(pathInfo => pathInfo.path === 1899).wif, | wallet.paths.get(1899).wif, | ||||
utxolib.networks.ecash, | utxolib.networks.ecash, | ||||
); | ); | ||||
// Reference https://github.com/Permissionless-Software-Foundation/bch-js/blob/master/src/bitcoincash.js#L161 | // Reference https://github.com/Permissionless-Software-Foundation/bch-js/blob/master/src/bitcoincash.js#L161 | ||||
const privKey = keyPair.__D; | const privKey = keyPair.__D; | ||||
// Now you can get the local signature | // Now you can get the local signature | ||||
const messageSignature = xecMessage | const messageSignature = xecMessage | ||||
.sign( | .sign( | ||||
▲ Show 20 Lines • Show All 127 Lines • ▼ Show 20 Lines | return ( | ||||
<Form.Item> | <Form.Item> | ||||
<SignMessageLabel>Address:</SignMessageLabel> | <SignMessageLabel>Address:</SignMessageLabel> | ||||
{wallet !== false && ( | {wallet !== false && ( | ||||
<AddressCopyCtn> | <AddressCopyCtn> | ||||
<Input | <Input | ||||
name="signMessageAddress" | name="signMessageAddress" | ||||
disabled={true} | disabled={true} | ||||
value={ | value={ | ||||
wallet.paths.find( | wallet.paths.get(1899).address | ||||
pathInfo => | |||||
pathInfo.path === 1899, | |||||
).address | |||||
} | } | ||||
/> | /> | ||||
<CopyToClipboard | <CopyToClipboard | ||||
data={ | data={ | ||||
wallet.paths.find( | wallet.paths.get(1899).address | ||||
pathInfo => | |||||
pathInfo.path === 1899, | |||||
).address | |||||
} | } | ||||
showToast | showToast | ||||
> | > | ||||
<ThemedCopySolid /> | <ThemedCopySolid /> | ||||
</CopyToClipboard> | </CopyToClipboard> | ||||
</AddressCopyCtn> | </AddressCopyCtn> | ||||
)} | )} | ||||
</Form.Item> | </Form.Item> | ||||
▲ Show 20 Lines • Show All 109 Lines • Show Last 20 Lines |