Dockerfile account creation with funds

This commit is contained in:
nannal
2021-05-30 01:45:55 +03:00
parent b161f0892e
commit 06339ca86c
6 changed files with 2136 additions and 18 deletions

View File

@@ -1,3 +1,5 @@
const { config } = require("javalon")
mongo = require("../mongoHelp.js")
config = require("../config.js")
@@ -15,10 +17,7 @@ function checkPayment(){
if (userArr.length != 1){
console.log("UserArray too long, this could indicate duplicate IDs which would be bad")
} else {
console.log(element.txs[0].data.amount , userArr[0].price)
if (element.txs[0].data.memo == userArr[0]._id && element.txs[0].data.amount >= userArr[0].price && userArr[0].status == "Inactive" ){
id = userArr[0]._id
tx = {
type: 0,
data: {
@@ -32,8 +31,23 @@ function checkPayment(){
console.log(err)
} else {
userArr[0].status = "Active"
mongo.update(config.database, "users", {_id: id}, userArr[0])
mongo.update(config.database, "users", {_id: userArr[0]._id}, userArr[0])
console.log(res)
tx2 = {
type: 3,
data: {
amount: Math.floor(config.fee)/2,
name: userArr[0].username
}
}
signedTx2 = javalon.sign(config.accountCreator.privKey,config.accountCreator.username, tx2)
javalon.sendTransaction(signedTx2, function(err, res) {
if (err){
console.log(err)
} else {
console.log(res)
}
})
}
})
}