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