Add Monero send page with transfer RPC and account selection

This commit is contained in:
2026-05-24 19:43:32 +08:00
parent 30d8abf26b
commit cc32fdb20f
7 changed files with 280 additions and 1 deletions
+17
View File
@@ -712,6 +712,23 @@ const rpc = BrowserView.defineRPC<RPC>({
)
return wallets
},
moneroTransfer: async ({ address, amount, priority, accountIndex }) => {
console.log('[rpc] moneroTransfer:', {
address,
amount,
priority,
})
if (!moneroManager)
throw new Error('Monero wallet RPC not started')
const result = await moneroManager.transfer(
address,
BigInt(amount),
priority ?? 0,
accountIndex ?? 0,
)
console.log('[rpc] moneroTransfer complete:', result.txHash)
return result
},
evmCreateWallet: async ({ name, phrase, passwordHash }) => {
console.log('[rpc] evmCreateWallet:', name)
const id = crypto.randomUUID()
+24
View File
@@ -337,6 +337,30 @@ export class MoneroWalletManager {
}
}
async transfer(
address: string,
amount: bigint,
priority: number = 0,
accountIndex: number = 0,
): Promise<{ txHash: string; fee: string; amount: string }> {
if (!this.wallet) throw new Error('Wallet RPC not started')
console.log(`[monero] transfer: ${address} amount=${amount.toString()} priority=${priority} account=${accountIndex}`)
const result = await this.rawRpc('transfer', {
destinations: [{ address, amount: amount.toString() }],
priority,
account_index: accountIndex,
get_tx_key: true,
get_tx_hex: false,
get_tx_metadata: false,
})
console.log(`[monero] transfer result: tx_hash=${result.tx_hash} fee=${result.fee} amount=${result.amount}`)
return {
txHash: result.tx_hash,
fee: result.fee?.toString() ?? '0',
amount: result.amount?.toString() ?? amount.toString(),
}
}
async isWalletOpen(): Promise<boolean> {
if (!this.wallet) return false
try {