1
- import {
2
- getPayments ,
3
- getInvoices ,
4
- getForwards as getLnForwards ,
5
- getWalletInfo ,
6
- getClosedChannels ,
7
- } from 'ln-service' ;
8
- import { compareDesc , subDays } from 'date-fns' ;
1
+ import { getPayments , getInvoices } from 'ln-service' ;
2
+ import { compareDesc } from 'date-fns' ;
9
3
import { sortBy } from 'underscore' ;
10
4
import { ContextType } from 'server/types/apiTypes' ;
11
5
import { requestLimiter } from 'server/helpers/rateLimiter' ;
@@ -15,12 +9,7 @@ import {
15
9
GetPaymentsType ,
16
10
InvoiceType ,
17
11
PaymentType ,
18
- GetForwardsType ,
19
- GetWalletInfoType ,
20
- GetClosedChannelsType ,
21
12
} from 'server/types/ln-service.types' ;
22
- import { logger } from 'server/helpers/logger' ;
23
- import { getNodeFromChannel } from './helpers' ;
24
13
25
14
type TransactionType = InvoiceType | PaymentType ;
26
15
type TransactionWithType = { isTypeOf : string } & TransactionType ;
@@ -105,89 +94,10 @@ export const transactionResolvers = {
105
94
resume,
106
95
} ;
107
96
} ,
108
-
109
- getForwardsPastDays : async (
110
- _ : undefined ,
111
- { days } : { days : number } ,
112
- context : ContextType
113
- ) => {
114
- await requestLimiter ( context . ip , 'getForwardsPastDays' ) ;
115
-
116
- const { lnd } = context ;
117
-
118
- const today = new Date ( ) ;
119
- const startDate = subDays ( today , days ) ;
120
-
121
- const walletInfo = await to < GetWalletInfoType > ( getWalletInfo ( { lnd } ) ) ;
122
-
123
- const closedChannels = await to < GetClosedChannelsType > (
124
- getClosedChannels ( { lnd } )
125
- ) ;
126
-
127
- const forwardsList = await to < GetForwardsType > (
128
- getLnForwards ( {
129
- lnd,
130
- after : startDate ,
131
- before : today ,
132
- } )
133
- ) ;
134
-
135
- let forwards = forwardsList . forwards ;
136
- let next = forwardsList . next ;
137
-
138
- let finishedFetching = false ;
139
-
140
- if ( ! next || ! forwards || forwards . length <= 0 ) {
141
- finishedFetching = true ;
142
- }
143
-
144
- while ( ! finishedFetching ) {
145
- if ( next ) {
146
- const moreForwards = await to < GetForwardsType > (
147
- getLnForwards ( { lnd, token : next } )
148
- ) ;
149
- forwards = [ ...forwards , ...moreForwards . forwards ] ;
150
- next = moreForwards . next ;
151
- } else {
152
- finishedFetching = true ;
153
- }
154
- }
155
-
156
- const final = forwards . map ( f => ( {
157
- ...f ,
158
- lnd,
159
- public_key : walletInfo . public_key ,
160
- closed_channels : closedChannels . channels || [ ] ,
161
- } ) ) ;
162
-
163
- logger . debug (
164
- `Got a total of ${ final . length } forwards for the past ${ days } days`
165
- ) ;
166
-
167
- return sortBy ( final , 'created_at' ) . reverse ( ) ;
168
- } ,
169
97
} ,
170
98
Transaction : {
171
99
__resolveType ( parent : TransactionWithType ) {
172
100
return parent . isTypeOf ;
173
101
} ,
174
102
} ,
175
- Forward : {
176
- incoming_node ( parent : any ) {
177
- return getNodeFromChannel (
178
- parent . lnd ,
179
- parent . incoming_channel ,
180
- parent . public_key ,
181
- parent . closed_channels
182
- ) ;
183
- } ,
184
- outgoing_node ( parent : any ) {
185
- return getNodeFromChannel (
186
- parent . lnd ,
187
- parent . outgoing_channel ,
188
- parent . public_key ,
189
- parent . closed_channels
190
- ) ;
191
- } ,
192
- } ,
193
103
} ;
0 commit comments