README.md

AvocadoughKit #

Make an AT Protocol identity a Bitcoin payment address.

@alice.bsky.social → DID → PDS → xyz.avocadough.payment.endpoint → Lightning address → invoice

This package is the shared identity-to-payment layer consumed by Avocadough (send & receive by handle) and Effem (boost a podcaster by identity). It depends only on CoreATProtocol and is settlement-agnostic: the xyz.avocadough.payment.endpoint lexicon advertises Lightning addresses today, with BOLT12 offers and Cashu mints as zero-schema-change additions later.

Lexicon and protocol documentation: https://avocadough.xyz/developers.

Pieces #

  • PaymentEndpointRecord — the xyz.avocadough.payment.endpoint lexicon record (see Lexicons/). One canonical record per identity (rkey: self) holding an ordered list of PaymentMethods.
  • PaymentTarget.classify(_:) — classifies free-form input: @handle, bare handle, DID, Lightning address, BOLT11 invoice, LNURL, with or without a lightning: scheme.
  • PaymentTargetResolver — resolves any classified input to ordered ResolvedPaymentMethods. The AT path composes CoreATProtocol's IdentityResolver with an unauthenticated ATRepoService.getRecord against the identity's own PDS; raw Lightning inputs pass through. No session needed.
  • PaymentEndpointPublisher — writes/reads/removes the signed-in user's endpoint record (authenticated session required).
  • LNURLPayService — turns a Lightning address into a payable BOLT11 invoice (LUD-06/16, comments per LUD-12, verify per LUD-21).

Usage #

// Pay an identity (no auth needed)
let target = try await PaymentTargetResolver().resolve("@alice.bsky.social")
if let address = target.preferredLightningAddress,
   let lightningAddress = LightningAddress(address) {
    let invoice = try await LNURLPayService().invoice(for: lightningAddress, amountMsat: 21_000)
    // pay invoice.pr with any Lightning wallet (e.g. NostrKit's WalletConnectManager)
}

// Become payable (authenticated session)
try await PaymentEndpointPublisher().publish(lightningAddress: "thomas@getalby.com", repo: did)