works
This commit is contained in:
parent
59ffe8b979
commit
da61ade4d0
6 changed files with 100 additions and 56 deletions
|
|
@ -12,7 +12,8 @@ async def m001_initial(db):
|
||||||
fraction BOOL,
|
fraction BOOL,
|
||||||
maxsats INT,
|
maxsats INT,
|
||||||
coins INT,
|
coins INT,
|
||||||
keyset_id TEXT NOT NULL
|
keyset_id TEXT NOT NULL,
|
||||||
|
issued_sat INT
|
||||||
);
|
);
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@
|
||||||
<q-expansion-item group="api" dense expand-separator label="List TPoS">
|
<q-expansion-item group="api" dense expand-separator label="List TPoS">
|
||||||
<q-card>
|
<q-card>
|
||||||
<q-card-section>
|
<q-card-section>
|
||||||
<code><span class="text-blue">GET</span> /cashu/api/v1/cashus</code>
|
<code><span class="text-blue">GET</span> /cashu/api/v1/mints</code>
|
||||||
<h5 class="text-caption q-mt-sm q-mb-none">Headers</h5>
|
<h5 class="text-caption q-mt-sm q-mb-none">Headers</h5>
|
||||||
<code>{"X-Api-Key": <invoice_key>}</code><br />
|
<code>{"X-Api-Key": <invoice_key>}</code><br />
|
||||||
<h5 class="text-caption q-mt-sm q-mb-none">Body (application/json)</h5>
|
<h5 class="text-caption q-mt-sm q-mb-none">Body (application/json)</h5>
|
||||||
|
|
@ -18,7 +18,7 @@
|
||||||
<code>[<cashu_object>, ...]</code>
|
<code>[<cashu_object>, ...]</code>
|
||||||
<h5 class="text-caption q-mt-sm q-mb-none">Curl example</h5>
|
<h5 class="text-caption q-mt-sm q-mb-none">Curl example</h5>
|
||||||
<code
|
<code
|
||||||
>curl -X GET {{ request.base_url }}cashu/api/v1/cashus -H "X-Api-Key:
|
>curl -X GET {{ request.base_url }}cashu/api/v1/mints -H "X-Api-Key:
|
||||||
<invoice_key>"
|
<invoice_key>"
|
||||||
</code>
|
</code>
|
||||||
</q-card-section>
|
</q-card-section>
|
||||||
|
|
@ -27,7 +27,7 @@
|
||||||
<q-expansion-item group="api" dense expand-separator label="Create a TPoS">
|
<q-expansion-item group="api" dense expand-separator label="Create a TPoS">
|
||||||
<q-card>
|
<q-card>
|
||||||
<q-card-section>
|
<q-card-section>
|
||||||
<code><span class="text-green">POST</span> /cashu/api/v1/cashus</code>
|
<code><span class="text-green">POST</span> /cashu/api/v1/mints</code>
|
||||||
<h5 class="text-caption q-mt-sm q-mb-none">Headers</h5>
|
<h5 class="text-caption q-mt-sm q-mb-none">Headers</h5>
|
||||||
<code>{"X-Api-Key": <invoice_key>}</code><br />
|
<code>{"X-Api-Key": <invoice_key>}</code><br />
|
||||||
<h5 class="text-caption q-mt-sm q-mb-none">Body (application/json)</h5>
|
<h5 class="text-caption q-mt-sm q-mb-none">Body (application/json)</h5>
|
||||||
|
|
@ -43,7 +43,7 @@
|
||||||
>
|
>
|
||||||
<h5 class="text-caption q-mt-sm q-mb-none">Curl example</h5>
|
<h5 class="text-caption q-mt-sm q-mb-none">Curl example</h5>
|
||||||
<code
|
<code
|
||||||
>curl -X POST {{ request.base_url }}cashu/api/v1/cashus -d '{"name":
|
>curl -X POST {{ request.base_url }}cashu/api/v1/mints -d '{"name":
|
||||||
<string>, "currency": <string>}' -H "Content-type:
|
<string>, "currency": <string>}' -H "Content-type:
|
||||||
application/json" -H "X-Api-Key: <admin_key>"
|
application/json" -H "X-Api-Key: <admin_key>"
|
||||||
</code>
|
</code>
|
||||||
|
|
@ -62,7 +62,7 @@
|
||||||
<q-card-section>
|
<q-card-section>
|
||||||
<code
|
<code
|
||||||
><span class="text-pink">DELETE</span>
|
><span class="text-pink">DELETE</span>
|
||||||
/cashu/api/v1/cashus/<cashu_id></code
|
/cashu/api/v1/mints/<cashu_id></code
|
||||||
>
|
>
|
||||||
<h5 class="text-caption q-mt-sm q-mb-none">Headers</h5>
|
<h5 class="text-caption q-mt-sm q-mb-none">Headers</h5>
|
||||||
<code>{"X-Api-Key": <admin_key>}</code><br />
|
<code>{"X-Api-Key": <admin_key>}</code><br />
|
||||||
|
|
@ -71,7 +71,7 @@
|
||||||
<h5 class="text-caption q-mt-sm q-mb-none">Curl example</h5>
|
<h5 class="text-caption q-mt-sm q-mb-none">Curl example</h5>
|
||||||
<code
|
<code
|
||||||
>curl -X DELETE {{ request.base_url
|
>curl -X DELETE {{ request.base_url
|
||||||
}}cashu/api/v1/cashus/<cashu_id> -H "X-Api-Key:
|
}}cashu/api/v1/mints/<cashu_id> -H "X-Api-Key:
|
||||||
<admin_key>"
|
<admin_key>"
|
||||||
</code>
|
</code>
|
||||||
</q-card-section>
|
</q-card-section>
|
||||||
|
|
|
||||||
|
|
@ -271,7 +271,7 @@
|
||||||
LNbits.api
|
LNbits.api
|
||||||
.request(
|
.request(
|
||||||
'GET',
|
'GET',
|
||||||
'/cashu/api/v1/cashus?all_wallets=true',
|
'/cashu/api/v1/mints?all_wallets=true',
|
||||||
this.g.user.wallets[0].inkey
|
this.g.user.wallets[0].inkey
|
||||||
)
|
)
|
||||||
.then(function (response) {
|
.then(function (response) {
|
||||||
|
|
@ -294,7 +294,7 @@
|
||||||
LNbits.api
|
LNbits.api
|
||||||
.request(
|
.request(
|
||||||
'POST',
|
'POST',
|
||||||
'/cashu/api/v1/cashus',
|
'/cashu/api/v1/mints',
|
||||||
_.findWhere(this.g.user.wallets, {id: this.formDialog.data.wallet})
|
_.findWhere(this.g.user.wallets, {id: this.formDialog.data.wallet})
|
||||||
.inkey,
|
.inkey,
|
||||||
data
|
data
|
||||||
|
|
@ -314,13 +314,13 @@
|
||||||
|
|
||||||
LNbits.utils
|
LNbits.utils
|
||||||
.confirmDialog(
|
.confirmDialog(
|
||||||
'Are you sure you want to delete this Mint? It will suck for users.'
|
"Are you sure you want to delete this Mint? This mint's users will not be able to redeem their tokens!"
|
||||||
)
|
)
|
||||||
.onOk(function () {
|
.onOk(function () {
|
||||||
LNbits.api
|
LNbits.api
|
||||||
.request(
|
.request(
|
||||||
'DELETE',
|
'DELETE',
|
||||||
'/cashu/api/v1/cashus/' + cashuId,
|
'/cashu/api/v1/mints/' + cashuId,
|
||||||
_.findWhere(self.g.user.wallets, {id: cashu.wallet}).adminkey
|
_.findWhere(self.g.user.wallets, {id: cashu.wallet}).adminkey
|
||||||
)
|
)
|
||||||
.then(function (response) {
|
.then(function (response) {
|
||||||
|
|
|
||||||
|
|
@ -913,7 +913,7 @@ page_container %}
|
||||||
try {
|
try {
|
||||||
const {data} = await LNbits.api.request(
|
const {data} = await LNbits.api.request(
|
||||||
'GET',
|
'GET',
|
||||||
`/cashu/api/v1/cashu/${this.mintId}/mint?amount=${this.invoiceData.amount}`
|
`/cashu/api/v1/${this.mintId}/mint?amount=${this.invoiceData.amount}`
|
||||||
)
|
)
|
||||||
console.log('### data', data)
|
console.log('### data', data)
|
||||||
|
|
||||||
|
|
@ -940,7 +940,7 @@ page_container %}
|
||||||
try {
|
try {
|
||||||
const {data} = await LNbits.api.request(
|
const {data} = await LNbits.api.request(
|
||||||
'POST',
|
'POST',
|
||||||
`/cashu/api/v1/cashu/${this.mintId}/mint?payment_hash=${invoice.hash}`,
|
`/cashu/api/v1/${this.mintId}/mint?payment_hash=${invoice.hash}`,
|
||||||
'',
|
'',
|
||||||
{
|
{
|
||||||
blinded_messages: []
|
blinded_messages: []
|
||||||
|
|
@ -991,7 +991,7 @@ page_container %}
|
||||||
try {
|
try {
|
||||||
const {data} = await LNbits.api.request(
|
const {data} = await LNbits.api.request(
|
||||||
'POST',
|
'POST',
|
||||||
`/cashu/api/v1/cashu/${this.mintId}/mint?payment_hash=${hash}`,
|
`/cashu/api/v1/${this.mintId}/mint?payment_hash=${hash}`,
|
||||||
'',
|
'',
|
||||||
{
|
{
|
||||||
blinded_messages: blindedMessages
|
blinded_messages: blindedMessages
|
||||||
|
|
@ -1086,7 +1086,7 @@ page_container %}
|
||||||
try {
|
try {
|
||||||
const {data} = await LNbits.api.request(
|
const {data} = await LNbits.api.request(
|
||||||
'POST',
|
'POST',
|
||||||
`/cashu/api/v1/cashu/${this.mintId}/split`,
|
`/cashu/api/v1/${this.mintId}/split`,
|
||||||
'',
|
'',
|
||||||
payload
|
payload
|
||||||
)
|
)
|
||||||
|
|
@ -1221,7 +1221,7 @@ page_container %}
|
||||||
try {
|
try {
|
||||||
const {data} = await LNbits.api.request(
|
const {data} = await LNbits.api.request(
|
||||||
'POST',
|
'POST',
|
||||||
`/cashu/api/v1/cashu/${this.mintId}/melt`,
|
`/cashu/api/v1/${this.mintId}/melt`,
|
||||||
'',
|
'',
|
||||||
payload
|
payload
|
||||||
)
|
)
|
||||||
|
|
@ -1257,7 +1257,7 @@ page_container %}
|
||||||
fetchMintKeys: async function () {
|
fetchMintKeys: async function () {
|
||||||
const {data} = await LNbits.api.request(
|
const {data} = await LNbits.api.request(
|
||||||
'GET',
|
'GET',
|
||||||
`/cashu/api/v1/cashu/${this.mintId}/keys`
|
`/cashu/api/v1/${this.mintId}/keys`
|
||||||
)
|
)
|
||||||
this.keys = data
|
this.keys = data
|
||||||
localStorage.setItem('cashu.keys', JSON.stringify(data))
|
localStorage.setItem('cashu.keys', JSON.stringify(data))
|
||||||
|
|
|
||||||
|
|
@ -47,17 +47,20 @@ from .models import Cashu
|
||||||
# --------- extension imports
|
# --------- extension imports
|
||||||
|
|
||||||
|
|
||||||
LIGHTNING = False
|
LIGHTNING = True
|
||||||
|
|
||||||
########################################
|
########################################
|
||||||
############### LNBITS MINTS ###########
|
############### LNBITS MINTS ###########
|
||||||
########################################
|
########################################
|
||||||
|
|
||||||
# todo: use /mints
|
|
||||||
@cashu_ext.get("/api/v1/cashus", status_code=HTTPStatus.OK)
|
@cashu_ext.get("/api/v1/mints", status_code=HTTPStatus.OK)
|
||||||
async def api_cashus(
|
async def api_cashus(
|
||||||
all_wallets: bool = Query(False), wallet: WalletTypeInfo = Depends(get_key_type)
|
all_wallets: bool = Query(False), wallet: WalletTypeInfo = Depends(get_key_type)
|
||||||
):
|
):
|
||||||
|
"""
|
||||||
|
Get all mints of this wallet.
|
||||||
|
"""
|
||||||
wallet_ids = [wallet.wallet.id]
|
wallet_ids = [wallet.wallet.id]
|
||||||
if all_wallets:
|
if all_wallets:
|
||||||
wallet_ids = (await get_user(wallet.wallet.user)).wallet_ids
|
wallet_ids = (await get_user(wallet.wallet.user)).wallet_ids
|
||||||
|
|
@ -65,8 +68,11 @@ async def api_cashus(
|
||||||
return [cashu.dict() for cashu in await get_cashus(wallet_ids)]
|
return [cashu.dict() for cashu in await get_cashus(wallet_ids)]
|
||||||
|
|
||||||
|
|
||||||
@cashu_ext.post("/api/v1/cashus", status_code=HTTPStatus.CREATED)
|
@cashu_ext.post("/api/v1/mints", status_code=HTTPStatus.CREATED)
|
||||||
async def api_cashu_create(data: Cashu, wallet: WalletTypeInfo = Depends(get_key_type)):
|
async def api_cashu_create(data: Cashu, wallet: WalletTypeInfo = Depends(get_key_type)):
|
||||||
|
"""
|
||||||
|
Create a new mint for this wallet.
|
||||||
|
"""
|
||||||
cashu_id = urlsafe_short_hash()
|
cashu_id = urlsafe_short_hash()
|
||||||
# generate a new keyset in cashu
|
# generate a new keyset in cashu
|
||||||
keyset = await ledger.load_keyset(cashu_id)
|
keyset = await ledger.load_keyset(cashu_id)
|
||||||
|
|
@ -78,12 +84,35 @@ async def api_cashu_create(data: Cashu, wallet: WalletTypeInfo = Depends(get_key
|
||||||
return cashu.dict()
|
return cashu.dict()
|
||||||
|
|
||||||
|
|
||||||
|
@cashu_ext.delete("/api/v1/mints/{cashu_id}")
|
||||||
|
async def api_cashu_delete(
|
||||||
|
cashu_id: str, wallet: WalletTypeInfo = Depends(require_admin_key)
|
||||||
|
):
|
||||||
|
"""
|
||||||
|
Delete an existing cashu mint.
|
||||||
|
"""
|
||||||
|
cashu = await get_cashu(cashu_id)
|
||||||
|
|
||||||
|
if not cashu:
|
||||||
|
raise HTTPException(
|
||||||
|
status_code=HTTPStatus.NOT_FOUND, detail="Cashu mint does not exist."
|
||||||
|
)
|
||||||
|
|
||||||
|
if cashu.wallet != wallet.wallet.id:
|
||||||
|
raise HTTPException(
|
||||||
|
status_code=HTTPStatus.FORBIDDEN, detail="Not your Cashu mint."
|
||||||
|
)
|
||||||
|
|
||||||
|
await delete_cashu(cashu_id)
|
||||||
|
raise HTTPException(status_code=HTTPStatus.NO_CONTENT)
|
||||||
|
|
||||||
|
|
||||||
#######################################
|
#######################################
|
||||||
########### CASHU ENDPOINTS ###########
|
########### CASHU ENDPOINTS ###########
|
||||||
#######################################
|
#######################################
|
||||||
|
|
||||||
|
|
||||||
@cashu_ext.get("/api/v1/cashu/{cashu_id}/keys", status_code=HTTPStatus.OK)
|
@cashu_ext.get("/api/v1/{cashu_id}/keys", status_code=HTTPStatus.OK)
|
||||||
async def keys(cashu_id: str = Query(None)) -> dict[int, str]:
|
async def keys(cashu_id: str = Query(None)) -> dict[int, str]:
|
||||||
"""Get the public keys of the mint"""
|
"""Get the public keys of the mint"""
|
||||||
cashu: Union[Cashu, None] = await get_cashu(cashu_id)
|
cashu: Union[Cashu, None] = await get_cashu(cashu_id)
|
||||||
|
|
@ -96,7 +125,20 @@ async def keys(cashu_id: str = Query(None)) -> dict[int, str]:
|
||||||
return ledger.get_keyset(keyset_id=cashu.keyset_id)
|
return ledger.get_keyset(keyset_id=cashu.keyset_id)
|
||||||
|
|
||||||
|
|
||||||
@cashu_ext.get("/api/v1/cashu/{cashu_id}/mint")
|
@cashu_ext.get("/api/v1/{cashu_id}/keysets", status_code=HTTPStatus.OK)
|
||||||
|
async def keysets(cashu_id: str = Query(None)) -> dict[str, list[str]]:
|
||||||
|
"""Get the public keys of the mint"""
|
||||||
|
cashu: Union[Cashu, None] = await get_cashu(cashu_id)
|
||||||
|
|
||||||
|
if not cashu:
|
||||||
|
raise HTTPException(
|
||||||
|
status_code=HTTPStatus.NOT_FOUND, detail="Mint does not exist."
|
||||||
|
)
|
||||||
|
|
||||||
|
return {"keysets": [cashu.keyset_id]}
|
||||||
|
|
||||||
|
|
||||||
|
@cashu_ext.get("/api/v1/{cashu_id}/mint")
|
||||||
async def request_mint(cashu_id: str = Query(None), amount: int = 0) -> GetMintResponse:
|
async def request_mint(cashu_id: str = Query(None), amount: int = 0) -> GetMintResponse:
|
||||||
"""
|
"""
|
||||||
Request minting of new tokens. The mint responds with a Lightning invoice.
|
Request minting of new tokens. The mint responds with a Lightning invoice.
|
||||||
|
|
@ -134,7 +176,7 @@ async def request_mint(cashu_id: str = Query(None), amount: int = 0) -> GetMintR
|
||||||
return resp
|
return resp
|
||||||
|
|
||||||
|
|
||||||
@cashu_ext.post("/api/v1/cashu/{cashu_id}/mint")
|
@cashu_ext.post("/api/v1/{cashu_id}/mint")
|
||||||
async def mint_coins(
|
async def mint_coins(
|
||||||
data: MintRequest,
|
data: MintRequest,
|
||||||
cashu_id: str = Query(None),
|
cashu_id: str = Query(None),
|
||||||
|
|
@ -157,7 +199,7 @@ async def mint_coins(
|
||||||
if invoice is None:
|
if invoice is None:
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
status_code=HTTPStatus.NOT_FOUND,
|
status_code=HTTPStatus.NOT_FOUND,
|
||||||
detail="Mint does not have this invoice.",
|
detail="Mint does not know this invoice.",
|
||||||
)
|
)
|
||||||
if invoice.issued == True:
|
if invoice.issued == True:
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
|
|
@ -173,27 +215,31 @@ async def mint_coins(
|
||||||
)
|
)
|
||||||
|
|
||||||
status: PaymentStatus = await check_transaction_status(cashu.wallet, payment_hash)
|
status: PaymentStatus = await check_transaction_status(cashu.wallet, payment_hash)
|
||||||
# todo: revert to: status.paid != True:
|
|
||||||
if status.paid != True:
|
if status.paid != True:
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
status_code=HTTPStatus.PAYMENT_REQUIRED, detail="Invoice not paid."
|
status_code=HTTPStatus.PAYMENT_REQUIRED, detail="Invoice not paid."
|
||||||
)
|
)
|
||||||
try:
|
try:
|
||||||
await ledger.crud.update_lightning_invoice(
|
|
||||||
db=ledger.db, hash=payment_hash, issued=True
|
|
||||||
)
|
|
||||||
keyset = ledger.keysets.keysets[cashu.keyset_id]
|
keyset = ledger.keysets.keysets[cashu.keyset_id]
|
||||||
|
|
||||||
promises = await ledger._generate_promises(
|
promises = await ledger._generate_promises(
|
||||||
B_s=data.blinded_messages, keyset=keyset
|
B_s=data.blinded_messages, keyset=keyset
|
||||||
)
|
)
|
||||||
|
assert len(promises), HTTPException(
|
||||||
|
status_code=HTTPStatus.INTERNAL_SERVER_ERROR, detail="No promises returned."
|
||||||
|
)
|
||||||
|
await ledger.crud.update_lightning_invoice(
|
||||||
|
db=ledger.db, hash=payment_hash, issued=True
|
||||||
|
)
|
||||||
|
|
||||||
return promises
|
return promises
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(e)
|
logger.error(e)
|
||||||
raise HTTPException(status_code=HTTPStatus.INTERNAL_SERVER_ERROR, detail=str(e))
|
raise HTTPException(status_code=HTTPStatus.INTERNAL_SERVER_ERROR, detail=str(e))
|
||||||
|
|
||||||
|
|
||||||
@cashu_ext.post("/api/v1/cashu/{cashu_id}/melt")
|
@cashu_ext.post("/api/v1/{cashu_id}/melt")
|
||||||
async def melt_coins(
|
async def melt_coins(
|
||||||
payload: MeltRequest, cashu_id: str = Query(None)
|
payload: MeltRequest, cashu_id: str = Query(None)
|
||||||
) -> GetMeltResponse:
|
) -> GetMeltResponse:
|
||||||
|
|
@ -211,7 +257,7 @@ async def melt_coins(
|
||||||
# TOKENS
|
# TOKENS
|
||||||
assert all([p.id == cashu.keyset_id for p in proofs]), HTTPException(
|
assert all([p.id == cashu.keyset_id for p in proofs]), HTTPException(
|
||||||
status_code=HTTPStatus.BAD_REQUEST,
|
status_code=HTTPStatus.BAD_REQUEST,
|
||||||
detail="Proofs include tokens from other mint.",
|
detail="Proofs include tokens from another mint.",
|
||||||
)
|
)
|
||||||
|
|
||||||
assert all([ledger._verify_proof(p) for p in proofs]), HTTPException(
|
assert all([ledger._verify_proof(p) for p in proofs]), HTTPException(
|
||||||
|
|
@ -248,19 +294,33 @@ async def melt_coins(
|
||||||
return GetMeltResponse(paid=status.paid, preimage=status.preimage)
|
return GetMeltResponse(paid=status.paid, preimage=status.preimage)
|
||||||
|
|
||||||
|
|
||||||
@cashu_ext.post("/api/v1/check")
|
@cashu_ext.post("/api/v1/{cashu_id}/check")
|
||||||
async def check_spendable(payload: CheckRequest) -> Dict[int, bool]:
|
async def check_spendable(
|
||||||
|
payload: CheckRequest, cashu_id: str = Query(None)
|
||||||
|
) -> Dict[int, bool]:
|
||||||
"""Check whether a secret has been spent already or not."""
|
"""Check whether a secret has been spent already or not."""
|
||||||
|
cashu: Union[None, Cashu] = await get_cashu(cashu_id)
|
||||||
|
if cashu is None:
|
||||||
|
raise HTTPException(
|
||||||
|
status_code=HTTPStatus.NOT_FOUND, detail="Mint does not exist."
|
||||||
|
)
|
||||||
return await ledger.check_spendable(payload.proofs)
|
return await ledger.check_spendable(payload.proofs)
|
||||||
|
|
||||||
|
|
||||||
@cashu_ext.post("/api/v1/checkfees")
|
@cashu_ext.post("/api/v1/{cashu_id}/checkfees")
|
||||||
async def check_fees(payload: CheckFeesRequest) -> CheckFeesResponse:
|
async def check_fees(
|
||||||
|
payload: CheckFeesRequest, cashu_id: str = Query(None)
|
||||||
|
) -> CheckFeesResponse:
|
||||||
"""
|
"""
|
||||||
Responds with the fees necessary to pay a Lightning invoice.
|
Responds with the fees necessary to pay a Lightning invoice.
|
||||||
Used by wallets for figuring out the fees they need to supply.
|
Used by wallets for figuring out the fees they need to supply.
|
||||||
This is can be useful for checking whether an invoice is internal (Cashu-to-Cashu).
|
This is can be useful for checking whether an invoice is internal (Cashu-to-Cashu).
|
||||||
"""
|
"""
|
||||||
|
cashu: Union[None, Cashu] = await get_cashu(cashu_id)
|
||||||
|
if cashu is None:
|
||||||
|
raise HTTPException(
|
||||||
|
status_code=HTTPStatus.NOT_FOUND, detail="Mint does not exist."
|
||||||
|
)
|
||||||
invoice_obj = bolt11.decode(payload.pr)
|
invoice_obj = bolt11.decode(payload.pr)
|
||||||
internal_checking_id = await check_internal(invoice_obj.payment_hash)
|
internal_checking_id = await check_internal(invoice_obj.payment_hash)
|
||||||
|
|
||||||
|
|
@ -271,7 +331,7 @@ async def check_fees(payload: CheckFeesRequest) -> CheckFeesResponse:
|
||||||
return CheckFeesResponse(fee=fees_msat / 1000)
|
return CheckFeesResponse(fee=fees_msat / 1000)
|
||||||
|
|
||||||
|
|
||||||
@cashu_ext.post("/api/v1/cashu/{cashu_id}/split")
|
@cashu_ext.post("/api/v1/{cashu_id}/split")
|
||||||
async def split(
|
async def split(
|
||||||
payload: SplitRequest, cashu_id: str = Query(None)
|
payload: SplitRequest, cashu_id: str = Query(None)
|
||||||
) -> PostSplitResponse:
|
) -> PostSplitResponse:
|
||||||
|
|
@ -291,7 +351,8 @@ async def split(
|
||||||
assert outputs, Exception("no outputs provided.")
|
assert outputs, Exception("no outputs provided.")
|
||||||
split_return = None
|
split_return = None
|
||||||
try:
|
try:
|
||||||
split_return = await ledger.split(proofs, amount, outputs, cashu.keyset_id)
|
keyset = ledger.keysets.keysets[cashu.keyset_id]
|
||||||
|
split_return = await ledger.split(proofs, amount, outputs, keyset)
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
HTTPException(
|
HTTPException(
|
||||||
status_code=HTTPStatus.BAD_REQUEST,
|
status_code=HTTPStatus.BAD_REQUEST,
|
||||||
|
|
@ -318,24 +379,6 @@ async def split(
|
||||||
# return cashu.dict()
|
# return cashu.dict()
|
||||||
|
|
||||||
|
|
||||||
# @cashu_ext.delete("/api/v1s/{cashu_id}")
|
|
||||||
# async def api_cashu_delete(
|
|
||||||
# cashu_id: str, wallet: WalletTypeInfo = Depends(require_admin_key)
|
|
||||||
# ):
|
|
||||||
# cashu = await get_cashu(cashu_id)
|
|
||||||
|
|
||||||
# if not cashu:
|
|
||||||
# raise HTTPException(
|
|
||||||
# status_code=HTTPStatus.NOT_FOUND, detail="Cashu does not exist."
|
|
||||||
# )
|
|
||||||
|
|
||||||
# if cashu.wallet != wallet.wallet.id:
|
|
||||||
# raise HTTPException(status_code=HTTPStatus.FORBIDDEN, detail="Not your Cashu.")
|
|
||||||
|
|
||||||
# await delete_cashu(cashu_id)
|
|
||||||
# raise HTTPException(status_code=HTTPStatus.NO_CONTENT)
|
|
||||||
|
|
||||||
|
|
||||||
# ########################################
|
# ########################################
|
||||||
# #################????###################
|
# #################????###################
|
||||||
# ########################################
|
# ########################################
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,7 @@ protobuf = "^4.21.6"
|
||||||
Cerberus = "^1.3.4"
|
Cerberus = "^1.3.4"
|
||||||
async-timeout = "^4.0.2"
|
async-timeout = "^4.0.2"
|
||||||
pyln-client = "0.11.1"
|
pyln-client = "0.11.1"
|
||||||
cashu = "0.4.2"
|
cashu = {path = "../cashu"}
|
||||||
|
|
||||||
|
|
||||||
[tool.poetry.dev-dependencies]
|
[tool.poetry.dev-dependencies]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue