refactor: 🚧 Fixed bugs, improved logging
parent
60ea5968ed
commit
7f1de7cc77
17
main.js
17
main.js
|
@ -1,7 +1,8 @@
|
|||
import dotenv from 'dotenv'
|
||||
import express, { Express, Request, Response } from 'express'
|
||||
import Wallet from 'monero-wallet-rpc-js'
|
||||
(async () => {
|
||||
const dotenv = require('dotenv')
|
||||
const express = require('express')
|
||||
const Wallet = require('monero-wallet-rpc-js')
|
||||
|
||||
;(async () => {
|
||||
|
||||
dotenv.config()
|
||||
const WALLET_ACCOUNT_INDEX = Number(process.env.WALLET_ACCOUNT_INDEX)
|
||||
|
@ -15,9 +16,10 @@ import Wallet from 'monero-wallet-rpc-js'
|
|||
filename: process.env.WALLET_FILENAME,
|
||||
password: process.env.WALLET_PASSWORD,
|
||||
address: process.env.WALLET_ADDRESS,
|
||||
viewKey: process.env.WALLET_VIEWKEY,
|
||||
restoreHeight: process.env.WALLET_RESTORE_HEIGHT,
|
||||
viewkey: process.env.WALLET_VIEWKEY,
|
||||
restore_height: process.env.WALLET_RESTORE_HEIGHT,
|
||||
})
|
||||
console.log(`Opened wallet "${process.env.WALLET_FILENAME}".`)
|
||||
} catch (err) {
|
||||
console.error(`Failed to open wallet: ${err}`)
|
||||
}
|
||||
|
@ -31,12 +33,13 @@ import Wallet from 'monero-wallet-rpc-js'
|
|||
await wallet.rpc('auto_refresh', {
|
||||
enable:true, period:WALLET_REFRESH_SEC,
|
||||
})
|
||||
console.log(`Auto-refreshing wallet every ${process.env.WALLET_REFRESH_SEC} seconds. `)
|
||||
} catch (err) {
|
||||
console.error(`Failed to set auto_refresh to ${process.env.WALLET_REFRESH_SEC}: ${err}`)
|
||||
}
|
||||
|
||||
try {
|
||||
console.log(`Wallet height: ${await wallet.getHeight()}`)
|
||||
console.log(`Wallet synced to block ${await wallet.getHeight()}.`)
|
||||
} catch (err) {
|
||||
console.error(`Failed to get blockchain height: ${err}`)
|
||||
}
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
{
|
||||
"name": "pago",
|
||||
"version": "1.1.1",
|
||||
"version": "1.1.2",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "pago",
|
||||
"version": "1.1.1",
|
||||
"version": "1.1.2",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"dotenv": "^16.4.5",
|
||||
"express": "^4.19.2",
|
||||
"monero-wallet-rpc-js": "^1.2.9",
|
||||
"monero-wallet-rpc-js": "^1.2.17",
|
||||
"socket.io": "^4.7.5"
|
||||
}
|
||||
},
|
||||
|
@ -625,9 +625,9 @@
|
|||
}
|
||||
},
|
||||
"node_modules/monero-wallet-rpc-js": {
|
||||
"version": "1.2.9",
|
||||
"resolved": "https://registry.npmjs.org/monero-wallet-rpc-js/-/monero-wallet-rpc-js-1.2.9.tgz",
|
||||
"integrity": "sha512-NU+2d21beM300MjOiq76eUrma2SugAZqz0CHIg4vuMTdxgZhBy15p5Akz5NBeWBtuEVBQ8CB2yZLIeC22Wy6jg==",
|
||||
"version": "1.2.17",
|
||||
"resolved": "https://registry.npmjs.org/monero-wallet-rpc-js/-/monero-wallet-rpc-js-1.2.17.tgz",
|
||||
"integrity": "sha512-PSe2k8CpLlXF+Jn7Bj5fczsQ8+frv2ojmb4oBjA9XooPCjD76y3OyM/iXaXnnDAKs7+cPTQAUojng8AO+lUyKw==",
|
||||
"dependencies": {
|
||||
"axios": "^1.6.8"
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
{
|
||||
"name": "pago",
|
||||
"version": "1.1.1",
|
||||
"version": "1.1.3",
|
||||
"description": "Lightweight monero payment gateway",
|
||||
"main": "index.js",
|
||||
"main": "main.js",
|
||||
"scripts": {
|
||||
"start": "node main.js"
|
||||
},
|
||||
|
@ -18,7 +18,7 @@
|
|||
"dependencies": {
|
||||
"dotenv": "^16.4.5",
|
||||
"express": "^4.19.2",
|
||||
"monero-wallet-rpc-js": "^1.2.9",
|
||||
"monero-wallet-rpc-js": "^1.2.17",
|
||||
"socket.io": "^4.7.5"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,8 +13,6 @@ MAIL_HOST='smtp'
|
|||
MAIL_URI="smtp://${MAIL_HOST}:2500"
|
||||
|
||||
## Monero ##
|
||||
# Wallet filename
|
||||
WALLET_FILENAME='pago'
|
||||
# Wallet password (Change this!)
|
||||
WALLET_PASSWORD='6vzyEYNW0uGPuIx'
|
||||
# Main wallet address (Change this!)
|
||||
|
@ -25,6 +23,8 @@ WALLET_VIEWKEY='a23474fe2d3ef001b7f0d311d7bb10eb149bbf9c0e206f7f31cc91ab58781809
|
|||
WALLET_RESTORE_HEIGHT=3133069
|
||||
# Which wallet account to use for payments
|
||||
WALLET_ACCOUNT_INDEX=1
|
||||
# Wallet filename
|
||||
WALLET_FILENAME='pago'
|
||||
# Wallet RPC
|
||||
WALLET_RPC_URI='http://pago_wallet:18082'
|
||||
# Interval to rescan for transactions
|
||||
|
|
Loading…
Reference in New Issue