Changeset View
Changeset View
Standalone View
Standalone View
web/cashtab/src/hooks/useBCH.js
Show First 20 Lines • Show All 269 Lines • ▼ Show 20 Lines | const burnToken = async (BCH, chronik, wallet, { tokenId, amount }) => { | ||||
throw err; | throw err; | ||||
} | } | ||||
// return the explorer link for the broadcasted tx | // return the explorer link for the broadcasted tx | ||||
return `${currency.blockExplorerUrl}/tx/${broadcastResponse.txid}`; | return `${currency.blockExplorerUrl}/tx/${broadcastResponse.txid}`; | ||||
}; | }; | ||||
const getRecipientPublicKey = async ( | const getRecipientPublicKey = async ( | ||||
BCH, | |||||
chronik, | chronik, | ||||
recipientAddress, | recipientAddress, | ||||
optionalMockPubKeyResponse = false, | optionalMockPubKeyResponse = false, | ||||
) => { | ) => { | ||||
// Necessary because jest can't mock | // Necessary because jest can't mock | ||||
// chronikTxHistoryAtAddress = await chronik.script('p2pkh', recipientAddressHash160).history(/*page=*/ 0, /*page_size=*/ 10); | // chronikTxHistoryAtAddress = await chronik.script('p2pkh', recipientAddressHash160).history(/*page=*/ 0, /*page_size=*/ 10); | ||||
if (optionalMockPubKeyResponse) { | if (optionalMockPubKeyResponse) { | ||||
return optionalMockPubKeyResponse; | return optionalMockPubKeyResponse; | ||||
▲ Show 20 Lines • Show All 97 Lines • ▼ Show 20 Lines | ) => { | ||||
let encryptedEj; // serialized encryption data object | let encryptedEj; // serialized encryption data object | ||||
// if the user has opted to encrypt this message | // if the user has opted to encrypt this message | ||||
if (encryptionFlag) { | if (encryptionFlag) { | ||||
try { | try { | ||||
// get the pub key for the recipient address | // get the pub key for the recipient address | ||||
let recipientPubKey = await getRecipientPublicKey( | let recipientPubKey = await getRecipientPublicKey( | ||||
BCH, | |||||
chronik, | chronik, | ||||
destinationAddress, | destinationAddress, | ||||
optionalMockPubKeyResponse, | optionalMockPubKeyResponse, | ||||
); | ); | ||||
// if the API can't find a pub key, it is due to the wallet having no outbound tx | // if the API can't find a pub key, it is due to the wallet having no outbound tx | ||||
if (recipientPubKey === 'not found') { | if (recipientPubKey === 'not found') { | ||||
throw new Error( | throw new Error( | ||||
▲ Show 20 Lines • Show All 137 Lines • Show Last 20 Lines |