Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cashu wallet #1816

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions components/use-indexeddb.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useState, useEffect, useCallback, useRef } from 'react'
import { useState, useEffect, useCallback, useRef, useMemo } from 'react'

export function getDbName (userId, name) {
return `app:storage:${userId ?? ''}${name ? `:${name}` : ''}`
Expand Down Expand Up @@ -294,7 +294,7 @@ function useIndexedDB ({ dbName, storeName, options = DEFAULT_OPTIONS, indices =
})
}, [queueOperation, storeName])

return { add, get, getAll, set, remove, clear, getByIndex, getAllByIndex, getPage, error, notSupported }
return useMemo(() => ({ add, get, getAll, set, remove, clear, getByIndex, getAllByIndex, getPage, error, notSupported }), [add, get, getAll, set, remove, clear, getByIndex, getAllByIndex, getPage, error, notSupported])
}

export default useIndexedDB
31 changes: 30 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -821,6 +821,34 @@ services:
CONNECT: "localhost:${LNBITS_WEB_PORT}"
TORDIR: "/app/.tor"
cpu_shares: "${CPU_SHARES_LOW}"
cashu:
image: cashubtc/nutshell:0.16.4
container_name: cashu
profiles:
- wallets
restart: unless-stopped
ports:
- "3338:3338"
depends_on:
lnd:
condition: service_healthy
restart: true
environment:
- MINT_LISTEN_HOST=0.0.0.0
- MINT_LISTEN_PORT=3338
- MINT_INFO_NAME="SN Cashu Test Mint"
- MINT_PRIVATE_KEY=TEST_PRIVATE_KEY
- MINT_BACKEND_BOLT11_SAT=LndRPCWallet
- MINT_LND_RPC_ENDPOINT=lnd:10009
- MINT_LND_RPC_CERT=/app/.lnd/tls.cert
- MINT_LND_RPC_MACAROON=/app/.lnd/data/chain/bitcoin/regtest/admin.macaroon
command: ["poetry", "run", "mint"]
volumes:
- lnd:/app/.lnd
- cashu:/app/.cashu
labels:
CONNECT: "localhost:3338"
cpu_shares: "${CPU_SHARES_LOW}"
volumes:
db:
os:
Expand All @@ -833,4 +861,5 @@ volumes:
nwc_send:
nwc_recv:
tordata:
eclair:
eclair:
cashu:
4 changes: 4 additions & 0 deletions lib/validate.js
Original file line number Diff line number Diff line change
Expand Up @@ -515,3 +515,7 @@ export const deviceSyncSchema = object().shape({
return true
})
})

export const mintQuoteSchema = object({
amount: intValidator.required('required').positive('must be positive')
})
170 changes: 163 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"@apollo/server": "^4.11.0",
"@as-integrations/next": "^3.1.0",
"@auth/prisma-adapter": "^2.7.0",
"@cashu/cashu-ts": "^2.1.0",
"@graphql-tools/schema": "^10.0.6",
"@lightninglabs/lnc-web": "^0.3.2-alpha",
"@noble/curves": "^1.6.0",
Expand Down
43 changes: 23 additions & 20 deletions pages/_app.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { HasNewNotesProvider } from '@/components/use-has-new-notes'
import { WebLnProvider } from '@/wallets/webln/client'
import { AccountProvider } from '@/components/account'
import { WalletsProvider } from '@/wallets/index'
import { CashuProvider } from '@/wallets/cashu/client'

const PWAPrompt = dynamic(() => import('react-ios-pwa-prompt'), { ssr: false })

Expand Down Expand Up @@ -117,26 +118,28 @@ export default function MyApp ({ Component, pageProps: { ...props } }) {
<HasNewNotesProvider>
<LoggerProvider>
<WebLnProvider>
<ServiceWorkerProvider>
<AccountProvider>
<PriceProvider price={price}>
<LightningProvider>
<ToastProvider>
<ShowModalProvider>
<BlockHeightProvider blockHeight={blockHeight}>
<ChainFeeProvider chainFee={chainFee}>
<ErrorBoundary>
<Component ssrData={ssrData} {...otherProps} />
{!router?.query?.disablePrompt && <PWAPrompt copyBody='This website has app functionality. Add it to your home screen to use it in fullscreen and receive notifications. In Safari:' promptOnVisit={2} />}
</ErrorBoundary>
</ChainFeeProvider>
</BlockHeightProvider>
</ShowModalProvider>
</ToastProvider>
</LightningProvider>
</PriceProvider>
</AccountProvider>
</ServiceWorkerProvider>
<CashuProvider>
<ServiceWorkerProvider>
<AccountProvider>
<PriceProvider price={price}>
<LightningProvider>
<ToastProvider>
<ShowModalProvider>
<BlockHeightProvider blockHeight={blockHeight}>
<ChainFeeProvider chainFee={chainFee}>
<ErrorBoundary>
<Component ssrData={ssrData} {...otherProps} />
{!router?.query?.disablePrompt && <PWAPrompt copyBody='This website has app functionality. Add it to your home screen to use it in fullscreen and receive notifications. In Safari:' promptOnVisit={2} />}
</ErrorBoundary>
</ChainFeeProvider>
</BlockHeightProvider>
</ShowModalProvider>
</ToastProvider>
</LightningProvider>
</PriceProvider>
</AccountProvider>
</ServiceWorkerProvider>
</CashuProvider>
</WebLnProvider>
</LoggerProvider>
</HasNewNotesProvider>
Expand Down
17 changes: 16 additions & 1 deletion pages/wallets/[wallet].js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { canReceive, canSend, isConfigured } from '@/wallets/common'
import { SSR } from '@/lib/constants'
import WalletButtonBar from '@/components/wallet-buttonbar'
import { useWalletConfigurator } from '@/wallets/config'
import { useCallback, useMemo } from 'react'
import { Fragment, useCallback, useMemo } from 'react'
import { useMe } from '@/components/me'
import validateWallet from '@/wallets/validate'
import { ValidationError } from 'yup'
Expand Down Expand Up @@ -101,6 +101,7 @@ export default function WalletSettings () {
>
<SendWarningBanner walletDef={wallet.def} />
{wallet && <WalletFields wallet={wallet} />}
{wallet && <WalletComponents wallet={wallet} />}
<CheckboxGroup name='enabled'>
<Checkbox
disabled={!isConfigured(wallet)}
Expand Down Expand Up @@ -185,3 +186,17 @@ function WalletFields ({ wallet }) {
return null
})
}

function WalletComponents ({ wallet }) {
if (!canSend({ def: wallet.def, config: wallet.config })) return null

return (
<div className='d-flex align-items-center justify-content-end column-gap-3'>
{
wallet.def.components?.map((Component, i) => {
return (<Fragment key={i}><Component wallet={wallet} /></Fragment>)
})
}
</div>
)
}
2 changes: 1 addition & 1 deletion pages/withdraw.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ export function InvWithdrawal () {
)
}

function InvoiceScanner ({ fieldName }) {
export function InvoiceScanner ({ fieldName }) {
const showModal = useShowModal()
const [,, helpers] = useField(fieldName)
const toaster = useToast()
Expand Down
Loading
Loading