Show preimage of confirmed withdrawals (#1106)
* Show preimage of confirmed withdrawals * Assign preimage in one-liner
This commit is contained in:
parent
13eda4c120
commit
95b03c4bbf
|
@ -1,4 +1,4 @@
|
|||
import { getIdentity, createHodlInvoice, createInvoice, decodePaymentRequest, payViaPaymentRequest, cancelHodlInvoice, getInvoice as getInvoiceFromLnd, getNode, authenticatedLndGrpc, deletePayment } from 'ln-service'
|
||||
import { getIdentity, createHodlInvoice, createInvoice, decodePaymentRequest, payViaPaymentRequest, cancelHodlInvoice, getInvoice as getInvoiceFromLnd, getNode, authenticatedLndGrpc, deletePayment, getPayment } from 'ln-service'
|
||||
import { GraphQLError } from 'graphql'
|
||||
import crypto from 'crypto'
|
||||
import serialize from './serial'
|
||||
|
@ -45,8 +45,7 @@ export async function getInvoice (parent, { id }, { me, models, lnd }) {
|
|||
|
||||
try {
|
||||
if (inv.confirmedAt) {
|
||||
const lnInv = await getInvoiceFromLnd({ id: inv.hash, lnd })
|
||||
inv.confirmedPreimage = lnInv.secret
|
||||
inv.confirmedPreimage = (await getInvoiceFromLnd({ id: inv.hash, lnd })).secret
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('error fetching invoice from LND', err)
|
||||
|
@ -55,7 +54,7 @@ export async function getInvoice (parent, { id }, { me, models, lnd }) {
|
|||
return inv
|
||||
}
|
||||
|
||||
export async function getWithdrawl (parent, { id }, { me, models }) {
|
||||
export async function getWithdrawl (parent, { id }, { me, models, lnd }) {
|
||||
if (!me) {
|
||||
throw new GraphQLError('you must be logged in', { extensions: { code: 'FORBIDDEN' } })
|
||||
}
|
||||
|
@ -77,6 +76,14 @@ export async function getWithdrawl (parent, { id }, { me, models }) {
|
|||
throw new GraphQLError('not ur withdrawal', { extensions: { code: 'FORBIDDEN' } })
|
||||
}
|
||||
|
||||
try {
|
||||
if (wdrwl.status === 'CONFIRMED') {
|
||||
wdrwl.preimage = (await getPayment({ id: wdrwl.hash, lnd })).payment.secret
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('error fetching payment from LND', err)
|
||||
}
|
||||
|
||||
return wdrwl
|
||||
}
|
||||
|
||||
|
|
|
@ -86,6 +86,7 @@ export default gql`
|
|||
satsFeePaid: Int
|
||||
status: String
|
||||
autoWithdraw: Boolean!
|
||||
preimage: String
|
||||
}
|
||||
|
||||
type Fact {
|
||||
|
|
|
@ -31,6 +31,7 @@ export const WITHDRAWL = gql`
|
|||
satsFeePaid
|
||||
status
|
||||
autoWithdraw
|
||||
preimage
|
||||
}
|
||||
}`
|
||||
|
||||
|
|
|
@ -112,7 +112,7 @@ function LoadWithdrawl () {
|
|||
</div>
|
||||
<InvoiceStatus variant={variant} status={status} />
|
||||
<div className='w-100 mt-3'>
|
||||
<Bolt11Info bolt11={data.withdrawl.bolt11}>
|
||||
<Bolt11Info bolt11={data.withdrawl.bolt11} preimage={data.withdrawl.preimage}>
|
||||
<PrivacyOption wd={data.withdrawl} />
|
||||
</Bolt11Info>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue