OZExternalSignerManager
public actor OZExternalSignerManager
Manager for external (non-passkey) signers in multi-signature smart-account operations.
Maintains two signer kinds:
- Keypair signers (
addFromSecret(secretKey:)): held in memory only; secret-key material is never persisted. - Wallet signers: surfaced from the live
OZExternalWalletAdapterfor the duration of the running process.
Example:
let address = try await manager.addFromSecret(secretKey: "SCZANGBA5YHT...")
-
Initializes a new
OZExternalSignerManager.Declaration
Swift
public init( networkPassphrase: String, walletAdapter: OZExternalWalletAdapter? = nil, ed25519Adapter: OZExternalEd25519SignerAdapter? = nil )Parameters
networkPassphraseStellar network passphrase. Used as signing context when delegating to wallet adapters.
walletAdapterOptional wallet adapter. When
nil, all wallet-related operations either throwMissingConfigor return empty results.ed25519AdapterOptional adapter for out-of-process Ed25519 signing. When non-
nil, consulted before the in-memory keypair registry for everysignEd25519AuthDigest(verifierAddress:publicKey:authDigest:)call. -
Whether an external wallet adapter is configured.
Returns
truewhen the manager was initialized with a non-nilOZExternalWalletAdapter. Wallet-related operations require this to betrue.Declaration
Swift
public var hasWalletAdapter: Bool { get }
-
addFromSecret(secretKey:Asynchronous) Adds an Ed25519 keypair signer from a raw secret key.
Creates a
KeyPairfrom the provided Stellar secret key (S-address) and stores it in memory. The keypair is never persisted to storage; it is lost when the application terminates or the manager is deinitialized.If a signer with the same G-address already exists (either keypair or wallet), the keypair signer takes precedence and overwrites the existing entry.
Throws
Invalidwhen the secret key is malformed or keypair creation otherwise fails.Declaration
Swift
public func addFromSecret(secretKey: String) async throws -> StringParameters
secretKeyA valid Stellar secret key (S-address, 56 characters).
Return Value
The derived G-address of the signer.
-
canSignFor(address:Asynchronous) Returns true when any keypair or connected-wallet adapter can sign for
address.Declaration
Swift
public func canSignFor(address: String) async -> Bool -
get(address:Asynchronous) Gets information about a specific signer by address.
Checks keypair signers first (which take precedence), then wallet signers.
Declaration
Swift
public func get(address: String) async -> OZExternalSignerInfo?Parameters
addressThe Stellar G-address to look up.
Return Value
The signer info, or
nilwhen no signer exists for this address. -
getAll()AsynchronousLists all managed external signers (both keypair and wallet).
Keypair signers are listed first. When a G-address exists as both a keypair signer and a wallet signer, only the keypair entry is returned (keypair takes precedence).
Declaration
Swift
public func getAll() async -> [OZExternalSignerInfo]Return Value
All managed external signer info objects.
-
hasSigners()AsynchronousReturns whether any external signers are registered (keypair or wallet).
Declaration
Swift
public func hasSigners() async -> BoolReturn Value
truewhen at least one signer is managed.
-
signAuthEntry(address:AsynchronousauthEntry: ) Signs an authorization-entry preimage with the appropriate signer for the given address.
For keypair signers, the preimage XDR is base64-decoded, hashed with SHA-256, and signed directly with the in-memory Ed25519 keypair. For wallet signers, signing is delegated to
signAuthEntry(preimageXdr:options:).Keypair signers take precedence over wallet signers when both exist for the same address; the wallet adapter is only consulted when no keypair signer matches.
Throws
NotFoundwhen no signer is available for the address;SigningFailedwhen the signing operation fails.Declaration
Swift
public func signAuthEntry( address: String, authEntry: String ) async throws -> OZSignAuthEntryResultParameters
addressThe G-address identifying which signer to use.
authEntryBase64-encoded
HashIDPreimageXDR to sign.Return Value
The signing result containing the base64-encoded raw Ed25519 signature and the signer address that produced it.
-
remove(address:Asynchronous) Removes a signer by address.
For keypair signers, removes the keypair from memory. For wallet signers, calls
disconnectByAddress(address:)to release the adapter’s runtime state. Both paths run when present, so an address that is somehow registered as both a keypair and a wallet is fully cleared.Throws
Rethrows any error raised by the adapter.Declaration
Swift
public func remove(address: String) async throwsParameters
addressThe G-address of the signer to remove.
-
removeAll()AsynchronousRemoves all signers. Clears in-memory keypair signers, in-memory Ed25519 keypairs, and disconnects all external wallets. Failures propagate to the caller.
Declaration
Swift
public func removeAll() async throws
-
Registers an Ed25519 signing keypair derived from a Stellar secret key.
Creates a
KeyPairfrom the supplied raw 32-byte Ed25519 secret seed and stores it in memory under the composite(verifierAddress, publicKey)key. The keypair is never persisted to storage and is lost when the application terminates or the manager is deinitialized.If a keypair is already registered for the same
(verifierAddress, publicKey)pair, it is silently overwritten with the new one.Throws
InvalidInputwhenverifierAddressis not a valid contract strkey or whensecretKeyBytesis not exactly 32 bytes;Invalidwhen keypair construction fails.Declaration
Swift
public func addEd25519FromRawKey(secretKeyBytes: Data, verifierAddress: String) throws -> DataParameters
secretKeyBytesRaw 32-byte Ed25519 secret seed. Must be exactly 32 bytes.
verifierAddressContract address (
C…strkey) of the Ed25519 verifier contract under which the signer is registered on-chain.Return Value
The derived 32-byte Ed25519 public key.
-
Returns whether a signing source is available for the given Ed25519 signer.
Checks the adapter first (adapter-first precedence rule). When the adapter returns
trueforcanSignFor(verifierAddress:publicKey:), this method returnstruewithout consulting the in-memory registry. Falls back to checking whether an in-memory keypair is registered for(verifierAddress, publicKey).Declaration
Swift
public func canSignEd25519For(verifierAddress: String, publicKey: Data) -> BoolParameters
verifierAddressContract address (
C…strkey) of the Ed25519 verifier contract.publicKey32-byte Ed25519 public key identifying the signer slot.
Return Value
truewhen a signing source (adapter or in-memory keypair) can sign for this(verifierAddress, publicKey)pair. -
Produces a 64-byte Ed25519 signature over the supplied auth digest.
Resolves the signing source using the adapter-first precedence rule: the adapter is consulted first via
canSignFor(verifierAddress:publicKey:). If the adapter claims it can sign, it is invoked viasignAuthDigest(authDigest:publicKey:). Otherwise the in-memory keypair registry is used. Throws when neither source is available.Throws
InvalidInputwhen no signing source is registered;SigningFailedwhen the adapter or in-memory keypair fails.Declaration
Swift
public func signEd25519AuthDigest( verifierAddress: String, publicKey: Data, authDigest: Data ) async throws -> DataParameters
verifierAddressContract address (
C…strkey) of the Ed25519 verifier contract.publicKey32-byte Ed25519 public key identifying the signer slot.
authDigest32-byte auth digest to sign.
Return Value
64-byte raw Ed25519 signature over
authDigest. -
Removes a registered Ed25519 signer from the in-memory registry.
Clears the keypair stored under
(verifierAddress, publicKey). No-op when no keypair is registered for that pair. The adapter is not affected by this call.Declaration
Swift
public func removeEd25519(verifierAddress: String, publicKey: Data)Parameters
verifierAddressContract address (
C…strkey) of the Ed25519 verifier contract.publicKey32-byte Ed25519 public key identifying the signer slot to remove.
View on GitHub
Install in Dash