mirror of
https://github.com/aljazceru/nutshell.git
synced 2025-12-22 11:24:19 +01:00
fix melt requiring outputs
This commit is contained in:
@@ -365,7 +365,7 @@ class PostMeltRequest(BaseModel):
|
|||||||
quote: str = Field(..., max_length=settings.mint_max_request_length) # quote id
|
quote: str = Field(..., max_length=settings.mint_max_request_length) # quote id
|
||||||
inputs: List[Proof] = Field(..., max_items=settings.mint_max_request_length)
|
inputs: List[Proof] = Field(..., max_items=settings.mint_max_request_length)
|
||||||
outputs: Union[List[BlindedMessage], None] = Field(
|
outputs: Union[List[BlindedMessage], None] = Field(
|
||||||
..., max_items=settings.mint_max_request_length
|
None, max_items=settings.mint_max_request_length
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -379,7 +379,7 @@ class PostMeltRequest_deprecated(BaseModel):
|
|||||||
proofs: List[Proof] = Field(..., max_items=settings.mint_max_request_length)
|
proofs: List[Proof] = Field(..., max_items=settings.mint_max_request_length)
|
||||||
pr: str = Field(..., max_length=settings.mint_max_request_length)
|
pr: str = Field(..., max_length=settings.mint_max_request_length)
|
||||||
outputs: Union[List[BlindedMessage], None] = Field(
|
outputs: Union[List[BlindedMessage], None] = Field(
|
||||||
..., max_items=settings.mint_max_request_length
|
None, max_items=settings.mint_max_request_length
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -186,6 +186,44 @@ async def test_melt_internal(ledger: Ledger, wallet: Wallet):
|
|||||||
assert result["paid"] is True
|
assert result["paid"] is True
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.asyncio
|
||||||
|
async def test_melt_internal_no_change_outputs(ledger: Ledger, wallet: Wallet):
|
||||||
|
# Clients without NUT-08 will not send change outputs
|
||||||
|
# internal invoice
|
||||||
|
invoice = await wallet.request_mint(64)
|
||||||
|
pay_if_regtest(invoice.bolt11)
|
||||||
|
await wallet.mint(64, id=invoice.id)
|
||||||
|
assert wallet.balance == 64
|
||||||
|
|
||||||
|
# create invoice to melt to
|
||||||
|
invoice = await wallet.request_mint(64)
|
||||||
|
|
||||||
|
invoice_payment_request = invoice.bolt11
|
||||||
|
|
||||||
|
quote = await wallet.melt_quote(invoice_payment_request)
|
||||||
|
assert quote.amount == 64
|
||||||
|
assert quote.fee_reserve == 0
|
||||||
|
|
||||||
|
inputs_payload = [p.to_dict() for p in wallet.proofs]
|
||||||
|
|
||||||
|
# outputs for change
|
||||||
|
secrets, rs, derivation_paths = await wallet.generate_n_secrets(1)
|
||||||
|
outputs, rs = wallet._construct_outputs([2], secrets, rs)
|
||||||
|
|
||||||
|
response = httpx.post(
|
||||||
|
f"{BASE_URL}/melt",
|
||||||
|
json={
|
||||||
|
"pr": invoice_payment_request,
|
||||||
|
"proofs": inputs_payload,
|
||||||
|
},
|
||||||
|
timeout=None,
|
||||||
|
)
|
||||||
|
assert response.status_code == 200, f"{response.url} {response.status_code}"
|
||||||
|
result = response.json()
|
||||||
|
assert result.get("preimage") is not None
|
||||||
|
assert result["paid"] is True
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
@pytest.mark.skipif(
|
@pytest.mark.skipif(
|
||||||
is_fake,
|
is_fake,
|
||||||
|
|||||||
Reference in New Issue
Block a user