diff --git a/backends/LND.ts b/backends/LND.ts index dcc3a35fb..1c6280a98 100644 --- a/backends/LND.ts +++ b/backends/LND.ts @@ -327,10 +327,10 @@ export default class LND { getPayments = (data?: any) => this.getRequest( `/v1/payments?include_incomplete=true${ - data && data?.indexOffSet - ? `&index_offset=${data?.indexOffSet}` + data && data?.maxPayments + ? `&max_payments=${data.maxPayments}` : '' - }` + }${data?.reversed ? `&reversed=${data.reversed}` : ''}` ); getNewAddress = (data: any) => this.getRequest('/v1/newaddress', data); diff --git a/backends/LightningNodeConnect.ts b/backends/LightningNodeConnect.ts index 8d540173c..cc27c8ba3 100644 --- a/backends/LightningNodeConnect.ts +++ b/backends/LightningNodeConnect.ts @@ -175,9 +175,10 @@ export default class LightningNodeConnect { .listPayments({ include_incomplete: true, ...(data && - data?.indexOffSet && { - index_offset: data.indexOffSet - }) + data?.maxPayments && { + max_payments: data.maxPayments + }), + ...(data && data?.reversed && { reversed: data?.reversed }) }) .then((data: lnrpc.ListPaymentsResponse) => snakeize(data)); getNewAddress = async (data: any) => diff --git a/stores/PaymentsStore.ts b/stores/PaymentsStore.ts index ea5cd385f..d328fe4b7 100644 --- a/stores/PaymentsStore.ts +++ b/stores/PaymentsStore.ts @@ -10,7 +10,6 @@ export default class PaymentsStore { @observable error = false; @observable error_msg: string; @observable payments: Array = []; - @observable last_index_offset: number; settingsStore: SettingsStore; channelsStore: ChannelsStore; @@ -31,15 +30,15 @@ export default class PaymentsStore { }; @action - public getPayments = async (indexOffSet: any = undefined) => { + public getPayments = async ( + maxPayments: any = undefined, + reversed: boolean = false + ) => { this.loading = true; try { - if (!indexOffSet) { - console.log('Fetching all payments..'); - } else console.log('Fetching the last payment', indexOffSet); - const data = await BackendUtils.getPayments({ - indexOffSet + maxPayments, + reversed }); const payments = data.payments; this.payments = payments @@ -49,7 +48,6 @@ export default class PaymentsStore { (payment: any) => new Payment(payment, this.channelsStore.nodes) ); - this.last_index_offset = data.last_index_offset; this.loading = false; return this.payments; } catch (error) { diff --git a/views/SendingLightning.tsx b/views/SendingLightning.tsx index 9478d7ef2..a5189ff6b 100644 --- a/views/SendingLightning.tsx +++ b/views/SendingLightning.tsx @@ -97,9 +97,8 @@ export default class SendingLightning extends React.Component< fetchPayments = async () => { const { PaymentsStore, TransactionsStore } = this.props; - const { last_index_offset } = PaymentsStore; try { - const payments = await PaymentsStore.getPayments(last_index_offset); + const payments = await PaymentsStore.getPayments(5, true); const matchingPayment = payments.find( (payment: any) => payment.payment_preimage === diff --git a/views/Wallet/Wallet.tsx b/views/Wallet/Wallet.tsx index 0115ef90c..bb145ba10 100644 --- a/views/Wallet/Wallet.tsx +++ b/views/Wallet/Wallet.tsx @@ -71,7 +71,6 @@ import SyncStore from '../../stores/SyncStore'; import UnitsStore from '../../stores/UnitsStore'; import UTXOsStore from '../../stores/UTXOsStore'; import ContactStore from '../../stores/ContactStore'; -import PaymentsStore from '../../stores/PaymentsStore'; import NotesStore from '../../stores/NotesStore'; import Bitcoin from '../../assets/images/SVG/Bitcoin.svg'; @@ -97,7 +96,6 @@ interface WalletProps { PosStore: PosStore; UTXOsStore: UTXOsStore; ContactStore: ContactStore; - PaymentsStore: PaymentsStore; ModalStore: ModalStore; SyncStore: SyncStore; LSPStore: LSPStore; @@ -123,7 +121,6 @@ interface WalletState { 'PosStore', 'UTXOsStore', 'ContactStore', - 'PaymentsStore', 'ModalStore', 'SyncStore', 'LSPStore', @@ -305,7 +302,6 @@ export default class Wallet extends React.Component { ChannelsStore, UTXOsStore, ContactStore, - PaymentsStore, SettingsStore, PosStore, FiatStore, @@ -357,7 +353,6 @@ export default class Wallet extends React.Component { ChannelBackupStore.reset(); UTXOsStore.reset(); ContactStore.loadContacts(); - PaymentsStore.getPayments(); NotesStore.loadNoteKeys(); }