Browse Source

add pool account and profit address support

main
ghost 10 months ago
parent
commit
6e4ec40f9f
  1. 2
      composer.json
  2. 5
      example/config.json
  3. 8
      src/controller/room.php
  4. 14
      src/crontab.php

2
composer.json

@ -10,7 +10,7 @@ @@ -10,7 +10,7 @@
},
"require": {
"yggverse/titan-ii": "^1.0",
"kevachat/kevacoin": "^1.7",
"kevachat/kevacoin": "dev-main",
"clitor-is-protocol/kevacoin": "^1.0",
"yggverse/cache": "^0.4"
}

5
example/config.json

@ -8,6 +8,10 @@ @@ -8,6 +8,10 @@
"port":9992,
"username":"",
"password":""
},
"profit":
{
"address":""
}
},
"gemini":
@ -75,6 +79,7 @@ @@ -75,6 +79,7 @@
},
"pool":
{
"account":"pool",
"timeout":3600,
"confirmations":1
},

8
src/controller/room.php

@ -329,8 +329,8 @@ class Room @@ -329,8 +329,8 @@ class Room
public function post(string $namespace, ?string $mention, int $session, string $message, ?string &$address = null): null|int|string
{
// Validate funds available yet
if (1 > $this->_kevacoin->getBalance())
// Validate funds available
if ($this->_kevacoin->getBalance($this->_config->kevachat->post->pool->account, $this->_config->kevachat->post->pool->confirmations))
{
return null;
}
@ -404,7 +404,9 @@ class Room @@ -404,7 +404,9 @@ class Room
':sent' => 0,
':expired' => 0,
':cost' => $this->_config->kevachat->post->cost->kva,
':address' => $address = $this->_kevacoin->getNewAddress(),
':address' => $address = $this->_kevacoin->getNewAddress(
$this->_config->kevachat->post->pool->account
),
':namespace' => $namespace,
':key' => sprintf('%s@anon', $time),
':value' => $message

14
src/crontab.php

@ -143,11 +143,11 @@ foreach ($database->query('SELECT * FROM `pool` WHERE `sent` = 0 AND `expired` = @@ -143,11 +143,11 @@ foreach ($database->query('SELECT * FROM `pool` WHERE `sent` = 0 AND `expired` =
if ($kevacoin->getReceivedByAddress($pool->address, $config->kevachat->post->pool->confirmations) >= $pool->cost)
{
// Check physical wallet balance
if ($kevacoin->getBalance() <= $pool->cost)
if ($kevacoin->getBalance($config->kevachat->post->pool->account, $config->kevachat->post->pool->confirmations) < $pool->cost)
{
exit(
sprintf(
_('[%s] [error] Insufficient wallet funds!'),
_('[%s] [error] Insufficient pool funds!'),
date('c')
) . PHP_EOL
);
@ -170,6 +170,16 @@ foreach ($database->query('SELECT * FROM `pool` WHERE `sent` = 0 AND `expired` = @@ -170,6 +170,16 @@ foreach ($database->query('SELECT * FROM `pool` WHERE `sent` = 0 AND `expired` =
// Send to blockchain
if ($txid = $kevacoin->kevaPut($pool->namespace, $pool->key, $pool->value))
{
// Send this amount to profit address if provided
if ($config->kevacoin->profit->address)
{
$kevacoin->sendFrom(
$pool->address,
$config->kevacoin->profit->address,
$pool->cost
);
}
// Update status
$database->query(
sprintf(

Loading…
Cancel
Save