Javascript wrapper for monero-wallet-rpc calls
 
Go to file
Keith Irwin 69c9b19c10
fix: 🐛 Fix getBalance() call
2024-04-22 08:08:17 -06:00
README.md docs: 📝 Improved docs 2024-04-21 13:44:11 -06:00
main.js fix: 🐛 Fix getBalance() call 2024-04-22 08:08:17 -06:00
package-lock.json feat: 🎉 Created basic functionality 2024-04-20 14:25:00 -06:00
package.json fix: 🐛 Fix getBalance() call 2024-04-22 08:08:17 -06:00

README.md

monero-wallet-rpc-js

Simple wrapper for monero-wallet-rpc calls.

import Wallet from 'monero-wallet-rpc-js'
(async () => {

	// Load wallet
	let wallet; try {
		wallet = new Wallet({
			url: 'http://localhost:18082',
			filename: 'mywallet',
			password: 'secretpassword',
			address: '4....',
			viewKey: 'XXXXXXX...',
			spendKey: 'XXXXXXX...',
			restoreHeight: '573936',
		})
	} catch (err) {
		console.error(`Failed to open wallet: ${err}`)
	}

	// Save wallet
	await wallet.store()

	// Auto-save wallet
	const AUTOSAVE_SEC = 10
	setInterval(await wallet.store(), AUTOSAVE_SEC)

	// Wrapped methods
	console.log(await wallet.getHeight()) // 3132418
	// Some return objects
	// See https://www.getmonero.org/resources/developer-guides/wallet-rpc.html#get_balance
	let bal = await wallet.getBalance()
	console.log(`Balance: ${bal.balance}
	             Unlocked: ${bal.unlocked_balance}`)

	// Arbitrary RPC call
	console.log((await wallet.rpc('get_address', {
			account_index: 2
		})).address)