Compare commits
No commits in common. "main" and "v0.0.4" have entirely different histories.
3 changed files with 5 additions and 40 deletions
20
crud.py
20
crud.py
|
|
@ -424,26 +424,6 @@ async def get_user_wallet_settings(user_id: str) -> Optional[UserWalletSettings]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
async def get_user_wallet_settings_by_prefix(
|
|
||||||
user_id_prefix: str,
|
|
||||||
) -> Optional[StoredUserWalletSettings]:
|
|
||||||
"""
|
|
||||||
Get user wallet settings by user ID prefix (for truncated 8-char IDs from Beancount).
|
|
||||||
|
|
||||||
Beancount accounts use truncated user IDs (first 8 chars), but the database
|
|
||||||
stores full UUIDs. This function looks up by prefix to bridge the gap.
|
|
||||||
"""
|
|
||||||
return await db.fetchone(
|
|
||||||
"""
|
|
||||||
SELECT * FROM user_wallet_settings
|
|
||||||
WHERE id LIKE :prefix || '%'
|
|
||||||
LIMIT 1
|
|
||||||
""",
|
|
||||||
{"prefix": user_id_prefix},
|
|
||||||
StoredUserWalletSettings,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
async def update_user_wallet_settings(
|
async def update_user_wallet_settings(
|
||||||
user_id: str, data: UserWalletSettings
|
user_id: str, data: UserWalletSettings
|
||||||
) -> UserWalletSettings:
|
) -> UserWalletSettings:
|
||||||
|
|
|
||||||
|
|
@ -1424,7 +1424,7 @@ window.app = Vue.createApp({
|
||||||
maxAmount: maxAmountSats, // Positive sats amount castle owes
|
maxAmount: maxAmountSats, // Positive sats amount castle owes
|
||||||
maxAmountFiat: maxAmountFiat, // EUR or other fiat amount (positive)
|
maxAmountFiat: maxAmountFiat, // EUR or other fiat amount (positive)
|
||||||
fiatCurrency: fiatCurrency,
|
fiatCurrency: fiatCurrency,
|
||||||
amount: maxAmountSats, // Default to sats since lightning is the default payment method
|
amount: fiatCurrency ? maxAmountFiat : maxAmountSats, // Default to fiat if available
|
||||||
payment_method: 'lightning', // Default to lightning for paying
|
payment_method: 'lightning', // Default to lightning for paying
|
||||||
description: '',
|
description: '',
|
||||||
reference: '',
|
reference: '',
|
||||||
|
|
@ -1456,9 +1456,8 @@ window.app = Vue.createApp({
|
||||||
memo: `Payment from Castle to ${this.payUserDialog.username}`
|
memo: `Payment from Castle to ${this.payUserDialog.username}`
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
console.log(invoiceResponse)
|
|
||||||
|
|
||||||
const paymentRequest = invoiceResponse.data.bolt11
|
const paymentRequest = invoiceResponse.data.payment_request
|
||||||
|
|
||||||
// Pay the invoice from Castle's wallet
|
// Pay the invoice from Castle's wallet
|
||||||
const paymentResponse = await LNbits.api.request(
|
const paymentResponse = await LNbits.api.request(
|
||||||
|
|
|
||||||
20
views_api.py
20
views_api.py
|
|
@ -2113,7 +2113,7 @@ async def api_pay_user(
|
||||||
if "meta" not in entry:
|
if "meta" not in entry:
|
||||||
entry["meta"] = {}
|
entry["meta"] = {}
|
||||||
entry["meta"]["payment-method"] = data.payment_method
|
entry["meta"]["payment-method"] = data.payment_method
|
||||||
entry["meta"]["paid-by"] = auth.user_id
|
entry["meta"]["paid-by"] = wallet.wallet.user
|
||||||
if data.txid:
|
if data.txid:
|
||||||
entry["meta"]["txid"] = data.txid
|
entry["meta"]["txid"] = data.txid
|
||||||
|
|
||||||
|
|
@ -2174,24 +2174,10 @@ async def api_get_user_wallet(
|
||||||
user_id: str,
|
user_id: str,
|
||||||
auth: AuthContext = Depends(require_super_user),
|
auth: AuthContext = Depends(require_super_user),
|
||||||
) -> dict:
|
) -> dict:
|
||||||
"""Get user's wallet settings (super user only)
|
"""Get user's wallet settings (super user only)"""
|
||||||
|
|
||||||
Supports both full UUIDs and truncated 8-char IDs (from Beancount accounts).
|
|
||||||
"""
|
|
||||||
from .crud import get_user_wallet_settings_by_prefix
|
|
||||||
|
|
||||||
# First try exact match
|
|
||||||
user_wallet = await get_user_wallet(user_id)
|
user_wallet = await get_user_wallet(user_id)
|
||||||
|
if not user_wallet:
|
||||||
# If not found and user_id looks like a truncated ID (8 chars), try prefix match
|
|
||||||
if not user_wallet or not user_wallet.user_wallet_id:
|
|
||||||
if len(user_id) <= 8:
|
|
||||||
stored_wallet = await get_user_wallet_settings_by_prefix(user_id)
|
|
||||||
if stored_wallet and stored_wallet.user_wallet_id:
|
|
||||||
user_wallet = stored_wallet
|
|
||||||
user_id = stored_wallet.id # Use the full ID
|
|
||||||
|
|
||||||
if not user_wallet or not user_wallet.user_wallet_id:
|
|
||||||
return {"user_id": user_id, "user_wallet_id": None}
|
return {"user_id": user_id, "user_wallet_id": None}
|
||||||
|
|
||||||
# Get invoice key for the user's wallet (needed to generate invoices)
|
# Get invoice key for the user's wallet (needed to generate invoices)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue