Add wallet pubkey to existing session

We need to also know the wallets pubkey if dapp is to connect to an
existing session.
This commit is contained in:
Dagur Valberg Johannsson 2026-03-10 18:33:36 +01:00
parent 0e54217929
commit d3a1a36163
No known key found for this signature in database
GPG key ID: FD701804AEE88107
3 changed files with 24 additions and 15 deletions

View file

@ -30,6 +30,7 @@ export interface DappRelayOptions {
existingCredentials?: {
privateKey: string;
secret: string;
walletPublicKey: string;
};
}
@ -104,6 +105,13 @@ export function initiateDappRelay(
let keyExchanged = false;
let walletPublicKeyNostr: Uint8Array | null = null;
if (options.existingCredentials) {
walletPublicKeyNostr = hexToBin(
options.existingCredentials.walletPublicKey,
);
keyExchanged = true;
}
const wrappedCallback: RelayStatusCallback = (
payload: RelayUpdatePayload,
) => {

View file

@ -29,6 +29,10 @@ program
"Existing dapp private key (64 hex chars) — for reconnection testing",
)
.option("--secret <hex>", "Existing secret (hex) — for reconnection testing")
.option(
"--wallet-public-key <hex>",
"Wallet's Nostr public key (hex) — for reconnection testing",
)
.option(
"--sign",
"Send a dummy sign request after wallet is ready (tests approval flow)",

View file

@ -180,6 +180,7 @@ export async function runDappMode(options: {
relay: string;
privateKey?: string;
secret?: string;
walletPublicKey?: string;
sign?: boolean;
}): Promise<void> {
const state = makeState();
@ -217,8 +218,12 @@ export async function runDappMode(options: {
{
explicitRelayUrls: [options.relay],
existingCredentials:
options.privateKey && options.secret
? { privateKey: options.privateKey, secret: options.secret }
options.privateKey && options.secret && options.walletPublicKey
? {
privateKey: options.privateKey,
secret: options.secret,
walletPublicKey: options.walletPublicKey,
}
: undefined,
},
);
@ -234,19 +239,11 @@ export async function runDappMode(options: {
encodeURIComponent(dappRelay.uri),
),
);
if (options.privateKey) {
console.log(
chalk.dim(
`\nReconnect:\n wiz-test dapp --private-key ${options.privateKey} --secret ${dappRelay.credentials.secret}`,
),
);
} else {
console.log(
chalk.dim(
`\nReconnect:\n wiz-test dapp --private-key ${dappRelay.credentials.privateKey} --secret ${dappRelay.credentials.secret}`,
),
);
}
console.log(
chalk.dim(
`\nReconnect (after key exchange):\n wiz-test dapp --private-key ${options.privateKey ?? dappRelay.credentials.privateKey} --secret ${dappRelay.credentials.secret} --wallet-public-key <WALLET_PUBKEY>`,
),
);
console.log();
const keySpinner = ora("Waiting for wallet to connect...").start();