nwc: fix bug where private nwc zaps weren't getting tracked properly

It was using the wrapper zap request id instead of the inner id. Fix
this type error by creating a ZapRequestId wrapper that makes sure it
uses the proper request id.
This commit is contained in:
William Casarin
2023-05-14 10:48:44 -07:00
parent e472e559a5
commit b1fee253b4
6 changed files with 80 additions and 21 deletions

View File

@@ -105,10 +105,10 @@ class PendingZap {
let type: ZapType
private(set) var state: PendingZapState
init(amount_msat: Int64, target: ZapTarget, request: ZapRequest, type: ZapType, state: PendingZapState) {
init(amount_msat: Int64, target: ZapTarget, request: MakeZapRequest, type: ZapType, state: PendingZapState) {
self.amount_msat = amount_msat
self.target = target
self.request = request
self.request = request.private_inner_request
self.type = type
self.state = state
}
@@ -125,6 +125,21 @@ class PendingZap {
}
}
struct ZapRequestId: Equatable {
let reqid: String
init(from_zap: Zapping) {
self.reqid = from_zap.request.id
}
init(from_makezap: MakeZapRequest) {
self.reqid = from_makezap.private_inner_request.ev.id
}
init(from_pending: PendingZap) {
self.reqid = from_pending.request.ev.id
}
}
enum Zapping {
case zap(Zap)