1
0
forked from GRIN/grim
Files
goblin/src/nostr/mod.rs
T
2ro 51d1675ad6 goblin: unlock-all / listen-all identities with instant switch (Build 145)
Reworks the multi-identity model. When the wallet is unlocked, EVERY held
identity's nsec is decrypted into memory (unlock_all_identities), and the
service listens for gift wraps addressed to ALL of them at once, each redeeming
into the one shared balance. Switching is now an instant, purely-local change of
which identity is presented and used for sending — no password, no service
teardown, no catch-up.

How receives stay deduped across all identities: a SINGLE gift-wrap subscription
with a multi-pubkey filter (OR over #p) and a SINGLE sequential notification
handler. Each wrap is p-tagged to exactly one identity, so it arrives once and is
processed once through the unchanged processed-set — dedup is exactly as safe as
the single-identity path, with no concurrent wrap processing. handle_wrap opens
each wrap by trying each held key until one succeeds; that key is the recipient
identity, recorded as the tx's recipient_pubkey. publish_identity now advertises
every held identity's DM-relay list (and profile, if named), each signed with its
own key, on the shared relay set.

NostrService holds all identities (recv) plus the active keys/identity (swapped
in place on switch); the switch-sync signals (is_switch_syncing/switch_received
and the "Syncing/Caught up/You were paid while away" flow) are removed — there is
nothing to catch up. The password modal remains only for add/import; the Build
144 import button and modal-position fixes are kept. init/add/import/rotate
rebuild the service with all identities; a plain switch does not.

Per-identity Tor-circuit isolation is deferred: all identities share the wallet
relay set for now.
2026-07-05 20:37:49 -04:00

52 lines
1.3 KiB
Rust

// Copyright 2026 The Goblin Developers
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//! Nostr payment-messaging subsystem: contacts are nostr users, slatepacks
//! travel as NIP-17 private DMs (NIP-44 encrypted, NIP-59 gift-wrapped) over
//! relays reached through the in-process Nym mixnet client.
mod types;
pub use types::*;
pub mod config;
pub use config::{AcceptPolicy, NostrConfig};
pub mod pool;
pub mod relays;
mod store;
pub use store::NostrStore;
mod identity;
pub use identity::{IdentitySource, NostrIdentity};
pub mod identities;
pub use identities::{HeldError, HeldIdentities, MAX_IDENTITIES, catchup_since};
pub mod protocol;
pub use protocol::*;
pub mod wrapv3;
pub mod ingest;
pub use ingest::*;
mod client;
pub use client::{HeldIdentityKeys, NostrProfile, NostrService, send_phase};
pub mod avatar;
pub mod nip05;
pub mod payuri;