create accounts/subaddresses, chunked address style, fix canSend for subaddresses

This commit is contained in:
2026-05-26 13:33:28 +08:00
parent 34602a4bfa
commit 2139d5e6ff
7 changed files with 259 additions and 12 deletions
+2
View File
@@ -180,6 +180,8 @@ export type MoneroRpcRequests = {
moneroListWallets: { params: {}; response: string[] }
moneroTransfer: { params: { address: string; amount: string; priority?: number; accountIndex?: number }; response: MoneroSendResult }
moneroSweepAll: { params: { address: string; priority?: number; accountIndex?: number }; response: MoneroSendResult }
moneroCreateAccount: { params: { label?: string }; response: { index: number; address: string } }
moneroCreateSubaddress: { params: { accountIndex: number; label?: string }; response: { index: number; address: string } }
moneroGetTransferDetails: { params: { txid: string }; response: MoneroTransferDetails | null }
moneroGetFeeEstimate: { params: {}; response: MoneroFeeEstimate | null }
}
@@ -308,6 +308,23 @@ export const MoneroWallet = () => {
return result
}
const createAccount = async (label?: string) => {
if (!electrobun.rpc) throw new Error('RPC not available')
const result = await electrobun.rpc.request.moneroCreateAccount({ label })
await refresh()
return result
}
const createSubaddress = async (accountIndex: number, label?: string) => {
if (!electrobun.rpc) throw new Error('RPC not available')
const result = await electrobun.rpc.request.moneroCreateSubaddress({
accountIndex,
label,
})
await refresh()
return result
}
return {
get accountType() {
return accountType
@@ -412,6 +429,8 @@ export const MoneroWallet = () => {
refresh,
send,
sendAll,
createAccount,
createSubaddress,
}
}