Lightning Zaps

Added initial lightning zaps/tipping integration

Changelog-Added: Receive Lightning Zaps
This commit is contained in:
William Casarin
2023-01-16 12:57:31 -08:00
parent 135432e03c
commit 006f8d79e0
31 changed files with 962 additions and 81 deletions

View File

@@ -38,6 +38,26 @@ func insert_uniq_by_pubkey(events: inout [NostrEvent], new_ev: NostrEvent, cmp:
return true
}
func insert_uniq_sorted_zap(zaps: inout [Zap], new_zap: Zap) -> Bool {
var i: Int = 0
for zap in zaps {
// don't insert duplicate events
if new_zap.event.id == zap.event.id {
return false
}
if new_zap.invoice.amount > zap.invoice.amount {
zaps.insert(new_zap, at: i)
return true
}
i += 1
}
zaps.append(new_zap)
return true
}
func insert_uniq_sorted_event(events: inout [NostrEvent], new_ev: NostrEvent, cmp: (NostrEvent, NostrEvent) -> Bool) -> Bool {
var i: Int = 0