add pool account and profit address support

This commit is contained in:
ghost 2024-02-18 06:21:04 +02:00
parent fb506cbfd7
commit 6e4ec40f9f
4 changed files with 23 additions and 6 deletions

View File

@ -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"
}

View File

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

View File

@ -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
':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

View File

@ -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` =
// 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(