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 { GraphQLError } from 'graphql'
|
||||||
import crypto from 'crypto'
|
import crypto from 'crypto'
|
||||||
import serialize from './serial'
|
import serialize from './serial'
|
||||||
|
@ -45,8 +45,7 @@ export async function getInvoice (parent, { id }, { me, models, lnd }) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (inv.confirmedAt) {
|
if (inv.confirmedAt) {
|
||||||
const lnInv = await getInvoiceFromLnd({ id: inv.hash, lnd })
|
inv.confirmedPreimage = (await getInvoiceFromLnd({ id: inv.hash, lnd })).secret
|
||||||
inv.confirmedPreimage = lnInv.secret
|
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('error fetching invoice from LND', err)
|
console.error('error fetching invoice from LND', err)
|
||||||
|
@ -55,7 +54,7 @@ export async function getInvoice (parent, { id }, { me, models, lnd }) {
|
||||||
return inv
|
return inv
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getWithdrawl (parent, { id }, { me, models }) {
|
export async function getWithdrawl (parent, { id }, { me, models, lnd }) {
|
||||||
if (!me) {
|
if (!me) {
|
||||||
throw new GraphQLError('you must be logged in', { extensions: { code: 'FORBIDDEN' } })
|
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' } })
|
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
|
return wdrwl
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -86,6 +86,7 @@ export default gql`
|
||||||
satsFeePaid: Int
|
satsFeePaid: Int
|
||||||
status: String
|
status: String
|
||||||
autoWithdraw: Boolean!
|
autoWithdraw: Boolean!
|
||||||
|
preimage: String
|
||||||
}
|
}
|
||||||
|
|
||||||
type Fact {
|
type Fact {
|
||||||
|
|
|
@ -31,6 +31,7 @@ export const WITHDRAWL = gql`
|
||||||
satsFeePaid
|
satsFeePaid
|
||||||
status
|
status
|
||||||
autoWithdraw
|
autoWithdraw
|
||||||
|
preimage
|
||||||
}
|
}
|
||||||
}`
|
}`
|
||||||
|
|
||||||
|
|
|
@ -112,7 +112,7 @@ function LoadWithdrawl () {
|
||||||
</div>
|
</div>
|
||||||
<InvoiceStatus variant={variant} status={status} />
|
<InvoiceStatus variant={variant} status={status} />
|
||||||
<div className='w-100 mt-3'>
|
<div className='w-100 mt-3'>
|
||||||
<Bolt11Info bolt11={data.withdrawl.bolt11}>
|
<Bolt11Info bolt11={data.withdrawl.bolt11} preimage={data.withdrawl.preimage}>
|
||||||
<PrivacyOption wd={data.withdrawl} />
|
<PrivacyOption wd={data.withdrawl} />
|
||||||
</Bolt11Info>
|
</Bolt11Info>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue