keychain vault + secrets cache + env separated keychains

This commit is contained in:
2026-08-02 11:38:19 +08:00
parent 23ef77ece6
commit 50a7771d97
6 changed files with 108 additions and 35 deletions
+3 -6
View File
@@ -11,6 +11,7 @@ import type {
XrpTxEntry,
XrpWalletInfo,
} from '../../../lib/rpc-schema'
import { getSecret, setSecret } from '../secrets-cache'
const SERVER = 'wss://s1.ripple.com'
const RIPPLE_EPOCH = 946684800
@@ -54,7 +55,7 @@ export function walletForSigning(secret: string): Wallet {
}
export async function getXrpWalletList(): Promise<XrpWalletInfo[]> {
const raw = await Bun.secrets.get({ service: SERVICE, name: WALLET_LIST_KEY })
const raw = await getSecret(SERVICE, WALLET_LIST_KEY)
if (!raw) return []
try {
return JSON.parse(raw)
@@ -66,11 +67,7 @@ export async function getXrpWalletList(): Promise<XrpWalletInfo[]> {
export async function saveXrpWalletList(
wallets: XrpWalletInfo[],
): Promise<void> {
await Bun.secrets.set({
service: SERVICE,
name: WALLET_LIST_KEY,
value: JSON.stringify(wallets),
})
await setSecret(SERVICE, WALLET_LIST_KEY, JSON.stringify(wallets))
}
export async function getBalance(address: string): Promise<XrpBalance> {