nip60: wallet.PayBolt11()

This commit is contained in:
fiatjaf
2025-01-29 14:54:55 -03:00
parent 26597452c5
commit 7c04b497ec
4 changed files with 207 additions and 67 deletions

View File

@@ -37,18 +37,42 @@ func LoadStash(
kr nostr.Keyer,
pool *nostr.SimplePool,
relays []string,
) *WalletStash {
return loadStashFromPool(ctx, kr, pool, relays, false)
}
func LoadStashWithHistory(
ctx context.Context,
kr nostr.Keyer,
pool *nostr.SimplePool,
relays []string,
) *WalletStash {
return loadStashFromPool(ctx, kr, pool, relays, true)
}
func loadStashFromPool(
ctx context.Context,
kr nostr.Keyer,
pool *nostr.SimplePool,
relays []string,
withHistory bool,
) *WalletStash {
pk, err := kr.GetPublicKey(ctx)
if err != nil {
return nil
}
kinds := []int{37375, 7375}
if withHistory {
kinds = append(kinds, 7375)
}
eoseChan := make(chan struct{})
events := pool.SubManyNotifyEOSE(
ctx,
relays,
nostr.Filters{
{Kinds: []int{37375, 7375, 7376}, Authors: []string{pk}},
{Kinds: kinds, Authors: []string{pk}},
{Kinds: []int{5}, Tags: nostr.TagMap{"k": []string{"7375"}}, Authors: []string{pk}},
},
eoseChan,