Skip to content

Retrieving getZapMethods twice returns empty map (ndk 3.0-beta) #363

@digitalbase

Description

@digitalbase

I've been working on a nasty bug where the zapper is unable to get lud16 or lud06 information the 2nd time.

A script to reproduce the problem

#!/usr/bin/env tsx

import { NDK } from "./ndk";

debug.enable("*");

import debug from "debug";
import { NDKUser } from "./user";
import { NDKZapper } from "./zapper";

const hexpubkey = "8aa70f4433129dadb71330ac89f62b534caa200a9f3ee349a0f4a5593073d1a6";

async function run() {
    const ndk = new NDK({
        // debug: new Debug("*"),
        explicitRelayUrls: ["wss://relay.damus.io", "wss://nos.lol"],
    });

    await ndk.connect();

    const target = new NDKUser({ hexpubkey });

    const zapper = new NDKZapper(target, 100, "msat", {
        comment: "test",
        ndk,
    });

    const zapMethodMap = await zapper.getZapMethods(ndk, hexpubkey);

    console.log(zapMethodMap);

    const zapMethodMap2 = await zapper.getZapMethods(ndk, hexpubkey);

    console.log(zapMethodMap2);
}

run().catch(console.error);

First time the zapMethodMap has what is expected (including lud16 info), 2nd time it's empty. To debug this further i've added a PR that adds some debugging capabilities to fetchUser etc #362

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions