Skip to content

Commit

Permalink
add sat amounts to invoices
Browse files Browse the repository at this point in the history
  • Loading branch information
huumn committed Aug 10, 2023
1 parent e668b1f commit ea9c405
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 3 deletions.
3 changes: 2 additions & 1 deletion api/resolvers/wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,8 @@ export default {
},

Invoice: {
satsReceived: i => msatsToSats(i.msatsReceived)
satsReceived: i => msatsToSats(i.msatsReceived),
satsRequested: i => msatsToSats(i.msatsRequested)
},

Fact: {
Expand Down
1 change: 1 addition & 0 deletions api/typeDefs/wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export default gql`
cancelled: Boolean!
confirmedAt: Date
satsReceived: Int
satsRequested: Int!
nostr: JSONObject
hmac: String
}
Expand Down
2 changes: 1 addition & 1 deletion components/invoice.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export function Invoice ({ invoice, onConfirmation, successVerb }) {

return (
<>
<Qr webLn={webLn} value={invoice.bolt11} statusVariant={variant} status={status} />
<Qr webLn={webLn} value={invoice.bolt11} description={numWithUnits(invoice.satsRequested)} statusVariant={variant} status={status} />
<div className='w-100'>
{nostr
? <AccordianItem
Expand Down
3 changes: 2 additions & 1 deletion components/qr.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import InvoiceStatus from './invoice-status'
import { requestProvider } from 'webln'
import { useEffect } from 'react'

export default function Qr ({ asIs, value, webLn, statusVariant, status }) {
export default function Qr ({ asIs, value, webLn, statusVariant, description, status }) {
const qrValue = asIs ? value : 'lightning:' + value.toUpperCase()

useEffect(() => {
Expand All @@ -28,6 +28,7 @@ export default function Qr ({ asIs, value, webLn, statusVariant, status }) {
className='h-auto mw-100' value={qrValue} renderAs='svg' size={300}
/>
</a>
{description && <div className='mt-1 fst-italic text-center text-muted'>{description}</div>}
<div className='mt-3 w-100'>
<CopyInput type='text' placeholder={value} readOnly noForm />
</div>
Expand Down
1 change: 1 addition & 0 deletions fragments/wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export const INVOICE = gql`
id
hash
bolt11
satsRequested
satsReceived
cancelled
confirmedAt
Expand Down

0 comments on commit ea9c405

Please sign in to comment.