Javascript wrapper for monero-wallet-rpc calls
 
Go to file
Keith Irwin d3564b10e9
feat: Added getTransfersByTxid()
2024-04-22 20:40:43 -06:00
README.md fix: 🐛 Fix generating wallet 2024-04-22 12:26:22 -06:00
main.js feat: Added getTransfersByTxid() 2024-04-22 20:40:43 -06:00
package-lock.json feat: 🎉 Created basic functionality 2024-04-20 14:25:00 -06:00
package.json feat: Added getTransfersByTxid() 2024-04-22 20:40:43 -06:00

README.md

monero-wallet-rpc-js

Simple wrapper for monero-wallet-rpc calls.

import Wallet from 'monero-wallet-rpc-js'

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

(async (wallet) => {

	// 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)

	// Save and close wallet
	await wallet.close()

})(loadedWallet)