diff --git a/WatchConnectivity.ios.js b/WatchConnectivity.ios.js index ad10667ab..8c4b6494d 100644 --- a/WatchConnectivity.ios.js +++ b/WatchConnectivity.ios.js @@ -56,7 +56,7 @@ export default class WatchConnectivity { // lets decode payreq and subscribe groundcontrol so we can receive push notification when our invoice is paid const decoded = await wallet.decodeInvoice(invoiceRequest); await notifications.tryToObtainPermissions(); - notifications.majorTomToGroundControl([], [decoded.payment_hash]); + notifications.majorTomToGroundControl([], [decoded.payment_hash], []); return invoiceRequest; } catch (error) { return error; diff --git a/blue_modules/notifications.js b/blue_modules/notifications.js index 62c8bdc8d..fe2d42359 100644 --- a/blue_modules/notifications.js +++ b/blue_modules/notifications.js @@ -148,10 +148,12 @@ function _getHeaders() { * * @param addresses {string[]} * @param hashes {string[]} + * @param txids {string[]} * @returns {Promise} Response object from API rest call */ -const majorTomToGroundControl = async function (addresses, hashes) { - if (!Array.isArray(addresses) || !Array.isArray(hashes)) throw new Error('no addresses or hashes provided'); +const majorTomToGroundControl = async function (addresses, hashes, txids) { + if (!Array.isArray(addresses) || !Array.isArray(hashes) || !Array.isArray(txids)) + throw new Error('no addresses or hashes or txids provided'); const pushToken = await _getPushToken(); if (!pushToken || !pushToken.token || !pushToken.os) return; @@ -163,6 +165,7 @@ const majorTomToGroundControl = async function (addresses, hashes) { body: { addresses, hashes, + txids, token: pushToken.token, os: pushToken.os, }, diff --git a/screen/lnd/browser.js b/screen/lnd/browser.js index a720f446f..66dd651c0 100644 --- a/screen/lnd/browser.js +++ b/screen/lnd/browser.js @@ -397,7 +397,7 @@ export default class Browser extends Component { // lets decode payreq and subscribe groundcontrol so we can receive push notification when our invoice is paid const decoded = await fromWallet.decodeInvoice(payreq); await notifications.tryToObtainPermissions(); - notifications.majorTomToGroundControl([], [decoded.payment_hash]); + notifications.majorTomToGroundControl([], [decoded.payment_hash], []); }, }, ], diff --git a/screen/lnd/lndCreateInvoice.js b/screen/lnd/lndCreateInvoice.js index 51e51a22e..18fb909c8 100644 --- a/screen/lnd/lndCreateInvoice.js +++ b/screen/lnd/lndCreateInvoice.js @@ -229,7 +229,7 @@ export default class LNDCreateInvoice extends Component { const fromWallet = this.state.fromWallet; const decoded = await fromWallet.decodeInvoice(invoiceRequest); await notifications.tryToObtainPermissions(); - notifications.majorTomToGroundControl([], [decoded.payment_hash]); + notifications.majorTomToGroundControl([], [decoded.payment_hash], []); // send to lnurl-withdraw callback url if that exists if (this.state.lnurlParams) { diff --git a/screen/receive/details.js b/screen/receive/details.js index dcb0b8b0a..6389c92e3 100644 --- a/screen/receive/details.js +++ b/screen/receive/details.js @@ -207,11 +207,11 @@ const ReceiveDetails = () => { } setAddressBIP21Encoded(address); await notifications.tryToObtainPermissions(); - notifications.majorTomToGroundControl([address], []); + notifications.majorTomToGroundControl([address], [], []); } else if (wallet.getAddress) { setAddressBIP21Encoded(wallet.getAddress()); await notifications.tryToObtainPermissions(); - notifications.majorTomToGroundControl([wallet.getAddress()], []); + notifications.majorTomToGroundControl([wallet.getAddress()], [], []); } }, [wallet]); diff --git a/screen/send/broadcast.js b/screen/send/broadcast.js index d717fda20..f1c81b5e4 100644 --- a/screen/send/broadcast.js +++ b/screen/send/broadcast.js @@ -2,7 +2,6 @@ import React, { useState } from 'react'; import PropTypes from 'prop-types'; import { ActivityIndicator, Linking, StyleSheet, View, KeyboardAvoidingView, Platform, Text, TextInput } from 'react-native'; import ReactNativeHapticFeedback from 'react-native-haptic-feedback'; - import loc from '../../loc'; import { HDSegwitBech32Wallet } from '../../class'; import { @@ -19,6 +18,7 @@ import { import { BlueCurrentTheme } from '../../components/themes'; import BlueElectrum from '../../blue_modules/BlueElectrum'; const bitcoin = require('bitcoinjs-lib'); +const notifications = require('../../blue_modules/notifications'); const BROADCAST_RESULT = Object.freeze({ none: 'Input transaction hash', @@ -44,6 +44,7 @@ const Broadcast = () => { const txid = tx.getId(); setTx(txid); setBroadcastResult(BROADCAST_RESULT.success); + notifications.majorTomToGroundControl([], [], [txid]); } else { setBroadcastResult(BROADCAST_RESULT.error); } diff --git a/screen/send/confirm.js b/screen/send/confirm.js index 7b68e94b9..50a344dfe 100644 --- a/screen/send/confirm.js +++ b/screen/send/confirm.js @@ -23,6 +23,8 @@ const EV = require('../../blue_modules/events'); const currency = require('../../blue_modules/currency'); const BlueElectrum = require('../../blue_modules/BlueElectrum'); const Bignumber = require('bignumber.js'); +const bitcoin = require('bitcoinjs-lib'); +const notifications = require('../../blue_modules/notifications'); export default class Confirm extends Component { constructor(props) { @@ -65,6 +67,8 @@ export default class Confirm extends Component { if (!result) { throw new Error(loc.errors.broadcast); } else { + const txid = bitcoin.Transaction.fromHex(this.state.tx).getId(); + notifications.majorTomToGroundControl([], [], [txid]); EV(EV.enum.REMOTE_TRANSACTIONS_COUNT_CHANGED); // someone should fetch txs let amount = 0; const recipients = this.state.recipients; diff --git a/screen/send/psbtWithHardwareWallet.js b/screen/send/psbtWithHardwareWallet.js index 99c083798..2b10c8476 100644 --- a/screen/send/psbtWithHardwareWallet.js +++ b/screen/send/psbtWithHardwareWallet.js @@ -42,6 +42,7 @@ const BlueElectrum = require('../../blue_modules/BlueElectrum'); /** @type {AppStorage} */ const BlueApp = require('../../BlueApp'); const bitcoin = require('bitcoinjs-lib'); +const notifications = require('../../blue_modules/notifications'); const { height, width } = Dimensions.get('window'); const styles = StyleSheet.create({ @@ -251,9 +252,10 @@ export default class PsbtWithHardwareWallet extends Component { if (result) { EV(EV.enum.REMOTE_TRANSACTIONS_COUNT_CHANGED); // someone should fetch txs this.setState({ success: true, isLoading: false }); + const txDecoded = bitcoin.Transaction.fromHex(this.state.txhex); + const txid = txDecoded.getId(); + notifications.majorTomToGroundControl([], [], [txid]); if (this.state.memo) { - const txDecoded = bitcoin.Transaction.fromHex(this.state.txhex); - const txid = txDecoded.getId(); BlueApp.tx_metadata[txid] = { memo: this.state.memo }; } } else { diff --git a/screen/transactions/CPFP.js b/screen/transactions/CPFP.js index 4bdbeb449..c3014edce 100644 --- a/screen/transactions/CPFP.js +++ b/screen/transactions/CPFP.js @@ -22,6 +22,7 @@ const EV = require('../../blue_modules/events'); const BlueElectrum = require('../../blue_modules/BlueElectrum'); /** @type {AppStorage} */ const BlueApp = require('../../BlueApp'); +const notifications = require('../../blue_modules/notifications'); const styles = StyleSheet.create({ root: { @@ -118,6 +119,7 @@ export default class CPFP extends Component { onSuccessBroadcast() { BlueApp.tx_metadata[this.state.newTxid] = { memo: 'Child pays for parent (CPFP)' }; + notifications.majorTomToGroundControl([], [], [this.state.newTxid]); } async componentDidMount() {