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 @@
}, },
"require": { "require": {
"yggverse/titan-ii": "^1.0", "yggverse/titan-ii": "^1.0",
"kevachat/kevacoin": "^1.7", "kevachat/kevacoin": "dev-main",
"clitor-is-protocol/kevacoin": "^1.0", "clitor-is-protocol/kevacoin": "^1.0",
"yggverse/cache": "^0.4" "yggverse/cache": "^0.4"
} }

5
example/config.json

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

8
src/controller/room.php

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

14
src/crontab.php

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

Loading…
Cancel
Save