Changeset View
Changeset View
Standalone View
Standalone View
web/cashtab/src/hooks/useWallet.js
Show First 20 Lines • Show All 729 Lines • ▼ Show 20 Lines | ) { | ||||
notification.success({ | notification.success({ | ||||
message: 'Transaction received', | message: 'Transaction received', | ||||
description: ( | description: ( | ||||
<Paragraph> | <Paragraph> | ||||
You received{' '} | You received{' '} | ||||
{Number( | {Number( | ||||
balances.totalBalance - previousBalances.totalBalance, | balances.totalBalance - previousBalances.totalBalance, | ||||
).toFixed(currency.cashDecimals)}{' '} | ).toFixed(currency.cashDecimals)}{' '} | ||||
BCH! | {currency.ticker}! | ||||
</Paragraph> | </Paragraph> | ||||
), | ), | ||||
duration: 3, | duration: 3, | ||||
}); | }); | ||||
} | } | ||||
// Parse for incoming SLP transactions | // Parse for incoming SLP transactions | ||||
if ( | if ( | ||||
▲ Show 20 Lines • Show All 235 Lines • ▼ Show 20 Lines | const initializeWebsocket = (cashAddress, slpAddress) => { | ||||
// Note, when you send an SLP tx, you get SLP change to SLP address and BCH change to BCH address | // Note, when you send an SLP tx, you get SLP change to SLP address and BCH change to BCH address | ||||
// Also note, when you send an SLP tx, you often have inputs from both BCH and SLP addresses | // Also note, when you send an SLP tx, you often have inputs from both BCH and SLP addresses | ||||
// This causes a sent SLP tx to register 4 times from the websocket | // This causes a sent SLP tx to register 4 times from the websocket | ||||
// Best way to ignore this is to ignore any incoming utx.x with BCH or SLP address in the inputs | // Best way to ignore this is to ignore any incoming utx.x with BCH or SLP address in the inputs | ||||
// Notification for received BCH | // Notification for received BCHA | ||||
if (bchSatsReceived > 0) { | if (bchSatsReceived > 0) { | ||||
notification.success({ | notification.success({ | ||||
message: 'Transaction received', | message: 'Transaction received', | ||||
description: ( | description: ( | ||||
<Paragraph> | <Paragraph> | ||||
You received {bchSatsReceived / 1e8} BCH! | You received {bchSatsReceived / 1e8}{' '} | ||||
{currency.ticker}! | |||||
</Paragraph> | </Paragraph> | ||||
), | ), | ||||
duration: 3, | duration: 3, | ||||
}); | }); | ||||
} | } | ||||
}; | }; | ||||
} catch (err) { | } catch (err) { | ||||
console.log( | console.log( | ||||
▲ Show 20 Lines • Show All 109 Lines • ▼ Show 20 Lines | const initializeWebsocket = (cashAddress, slpAddress) => { | ||||
// Note, when you send an SLP tx, you get SLP change to SLP address and BCH change to BCH address | // Note, when you send an SLP tx, you get SLP change to SLP address and BCH change to BCH address | ||||
// Also note, when you send an SLP tx, you often have inputs from both BCH and SLP addresses | // Also note, when you send an SLP tx, you often have inputs from both BCH and SLP addresses | ||||
// This causes a sent SLP tx to register 4 times from the websocket | // This causes a sent SLP tx to register 4 times from the websocket | ||||
// Best way to ignore this is to ignore any incoming utx.x with BCH or SLP address in the inputs | // Best way to ignore this is to ignore any incoming utx.x with BCH or SLP address in the inputs | ||||
// Notification for received BCH | // Notification for received BCHA | ||||
if (bchSatsReceived > 0) { | if (bchSatsReceived > 0) { | ||||
notification.success({ | notification.success({ | ||||
message: 'Transaction received', | message: 'Transaction received', | ||||
description: ( | description: ( | ||||
<Paragraph> | <Paragraph> | ||||
You received {bchSatsReceived / 1e8} BCH! | You received {bchSatsReceived / 1e8}{' '} | ||||
{currency.ticker}! | |||||
</Paragraph> | </Paragraph> | ||||
), | ), | ||||
duration: 3, | duration: 3, | ||||
}); | }); | ||||
} | } | ||||
}; | }; | ||||
setWs(newWs); | setWs(newWs); | ||||
▲ Show 20 Lines • Show All 100 Lines • Show Last 20 Lines |