Fix request listener output

This commit is contained in:
Riccardo Balbo 2024-07-25 11:40:11 +00:00
commit fa241f91f8
2 changed files with 12 additions and 11 deletions

View file

@ -96,7 +96,7 @@ class NWCServiceProvider:
""" """
return self.supported_methods return self.supported_methods
def addRequestListener(self, method: str, l: Callable[["NWCServiceProvider", str, Dict], List[Tuple[Dict, Dict]]]): def addRequestListener(self, method: str, l: Callable[["NWCServiceProvider", str, Dict], List[Tuple[Dict, Dict, List]]]):
""" """
Adds a request listener for a specific method. Adds a request listener for a specific method.

View file

@ -94,7 +94,7 @@ async def _process_invoice(wallet_id:str, pubkey:str, invoice:str, amount_msats:
} }
async def _on_pay_invoice(sp: NWCServiceProvider, pubkey: str, payload: Dict) -> List[Tuple[Dict, Dict]]: async def _on_pay_invoice(sp: NWCServiceProvider, pubkey: str, payload: Dict) -> List[Tuple[Dict, Dict, List]]:
nwc = await get_nwc(pubkey, None, False, True) nwc = await get_nwc(pubkey, None, False, True)
error = await _check(nwc, "pay_invoice", payload) error = await _check(nwc, "pay_invoice", payload)
if error: if error:
@ -118,7 +118,7 @@ async def _on_pay_invoice(sp: NWCServiceProvider, pubkey: str, payload: Dict) ->
return [(out,None, [])] return [(out,None, [])]
async def _on_multi_pay_invoice(sp: NWCServiceProvider, pubkey: str, payload: Dict) -> List[Tuple[Dict, Dict]]: async def _on_multi_pay_invoice(sp: NWCServiceProvider, pubkey: str, payload: Dict) -> List[Tuple[Dict, Dict, List]]:
nwc = await get_nwc(pubkey, None, False, True) nwc = await get_nwc(pubkey, None, False, True)
error = await _check(nwc, "multi_pay_invoice", payload) error = await _check(nwc, "multi_pay_invoice", payload)
if error: if error:
@ -149,9 +149,10 @@ async def _on_multi_pay_invoice(sp: NWCServiceProvider, pubkey: str, payload: Di
"preimage": res.get("preimage"), "preimage": res.get("preimage"),
}, },
None, None,
{ [
"d": id if id else res.get("payment_hash"), ["d", id if id else res.get("payment_hash")]
}) ]
)
results.append(r) results.append(r)
except Exception as e: except Exception as e:
results.append((None, { results.append((None, {
@ -162,7 +163,7 @@ async def _on_multi_pay_invoice(sp: NWCServiceProvider, pubkey: str, payload: Di
return results return results
async def _on_make_invoice(sp: NWCServiceProvider, pubkey: str, payload: Dict) -> List[Tuple[Dict, Dict]]: async def _on_make_invoice(sp: NWCServiceProvider, pubkey: str, payload: Dict) -> List[Tuple[Dict, Dict, List]]:
nwc = await get_nwc(pubkey, None, False, True) nwc = await get_nwc(pubkey, None, False, True)
error = await _check(nwc, "make_invoice", payload) error = await _check(nwc, "make_invoice", payload)
if error: if error:
@ -203,7 +204,7 @@ async def _on_make_invoice(sp: NWCServiceProvider, pubkey: str, payload: Dict) -
return [(res, None, [])] return [(res, None, [])]
async def _on_lookup_invoice(sp: NWCServiceProvider, pubkey: str, payload: Dict) -> List[Tuple[Dict, Dict]]: async def _on_lookup_invoice(sp: NWCServiceProvider, pubkey: str, payload: Dict) -> List[Tuple[Dict, Dict, List]]:
nwc = await get_nwc(pubkey, None, False, True) nwc = await get_nwc(pubkey, None, False, True)
error = await _check(nwc, "lookup_invoice", payload) error = await _check(nwc, "lookup_invoice", payload)
if error: if error:
@ -243,7 +244,7 @@ async def _on_lookup_invoice(sp: NWCServiceProvider, pubkey: str, payload: Dict)
return [(res, None, [])] return [(res, None, [])]
async def _on_list_transactions(sp: NWCServiceProvider, pubkey: str, payload: Dict) -> List[Tuple[Dict, Dict]]: async def _on_list_transactions(sp: NWCServiceProvider, pubkey: str, payload: Dict) -> List[Tuple[Dict, Dict, List]]:
nwc = await get_nwc(pubkey, None, False, True) nwc = await get_nwc(pubkey, None, False, True)
error = await _check(nwc, "list_transactions", payload) error = await _check(nwc, "list_transactions", payload)
if error: if error:
@ -295,7 +296,7 @@ async def _on_list_transactions(sp: NWCServiceProvider, pubkey: str, payload: Di
}, None, [])] }, None, [])]
async def _on_get_balance(sp: NWCServiceProvider, pubkey: str, payload: Dict) -> List[Tuple[Dict, Dict]]: async def _on_get_balance(sp: NWCServiceProvider, pubkey: str, payload: Dict) -> List[Tuple[Dict, Dict, List]]:
nwc = await get_nwc(pubkey, None, False, True) nwc = await get_nwc(pubkey, None, False, True)
error = await _check(nwc, "get_balance", payload) error = await _check(nwc, "get_balance", payload)
if error: if error:
@ -311,7 +312,7 @@ async def _on_get_balance(sp: NWCServiceProvider, pubkey: str, payload: Dict) ->
}, None, [])] }, None, [])]
async def _on_get_info(sp: NWCServiceProvider, pubkey: str, payload: Dict) -> List[Tuple[Dict, Dict]]: async def _on_get_info(sp: NWCServiceProvider, pubkey: str, payload: Dict) -> List[Tuple[Dict, Dict, List]]:
nwc = await get_nwc(pubkey, None, False, True) nwc = await get_nwc(pubkey, None, False, True)
error = await _check(nwc, "get_info", payload) error = await _check(nwc, "get_info", payload)
if error: if error: