untested hf
This commit is contained in:
@@ -43,6 +43,31 @@ class Block
|
|||||||
|
|
||||||
$msg = '';
|
$msg = '';
|
||||||
|
|
||||||
|
$mn_reward_rate=0.33;
|
||||||
|
|
||||||
|
// hf
|
||||||
|
if($height>212000){
|
||||||
|
$votes=[];
|
||||||
|
$r=$db->run("SELECT id,val FROM votes");
|
||||||
|
foreach($r as $vote){
|
||||||
|
$votes[$vote['id']]=$vote['val'];
|
||||||
|
}
|
||||||
|
// emission cut by 30%
|
||||||
|
if($votes['emission30']==1){
|
||||||
|
$reward=round($reward*0.7);
|
||||||
|
}
|
||||||
|
// 50% to masternodes
|
||||||
|
if($votes['masternodereward50']==1){
|
||||||
|
$mn_reward_rate=0.5;
|
||||||
|
}
|
||||||
|
// minimum reward to always be 50 aro
|
||||||
|
if($votes['endless50reward']==1&&$reward<50){
|
||||||
|
$reward=50;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if ($height>=80458) {
|
if ($height>=80458) {
|
||||||
//reward the masternode
|
//reward the masternode
|
||||||
|
|
||||||
@@ -52,7 +77,7 @@ class Block
|
|||||||
);
|
);
|
||||||
_log("MN Winner: $mn_winner", 2);
|
_log("MN Winner: $mn_winner", 2);
|
||||||
if ($mn_winner!==false) {
|
if ($mn_winner!==false) {
|
||||||
$mn_reward=round(0.33*$reward, 8);
|
$mn_reward=round($mn_reward_rate*$reward, 8);
|
||||||
$reward=round($reward-$mn_reward, 8);
|
$reward=round($reward-$mn_reward, 8);
|
||||||
$reward=number_format($reward, 8, ".", "");
|
$reward=number_format($reward, 8, ".", "");
|
||||||
$mn_reward=number_format($mn_reward, 8, ".", "");
|
$mn_reward=number_format($mn_reward, 8, ".", "");
|
||||||
@@ -674,17 +699,41 @@ class Block
|
|||||||
|
|
||||||
// reward transaction and signature
|
// reward transaction and signature
|
||||||
$reward = $this->reward($height, $data);
|
$reward = $this->reward($height, $data);
|
||||||
|
$mn_reward_rate=0.33;
|
||||||
|
global $db;
|
||||||
|
// hf
|
||||||
|
if($height>212000){
|
||||||
|
$votes=[];
|
||||||
|
$r=$db->run("SELECT id,val FROM votes");
|
||||||
|
foreach($r as $vote){
|
||||||
|
$votes[$vote['id']]=$vote['val'];
|
||||||
|
}
|
||||||
|
// emission cut by 30%
|
||||||
|
if($votes['emission30']==1){
|
||||||
|
$reward=round($reward*0.7);
|
||||||
|
}
|
||||||
|
// 50% to masternodes
|
||||||
|
if($votes['masternodereward50']==1){
|
||||||
|
$mn_reward_rate=0.5;
|
||||||
|
}
|
||||||
|
|
||||||
|
// minimum reward to always be 50 aro
|
||||||
|
if($votes['endless50reward']==1&&$reward<50){
|
||||||
|
$reward=50;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
if ($height>=80458) {
|
if ($height>=80458) {
|
||||||
//reward the masternode
|
//reward the masternode
|
||||||
global $db;
|
|
||||||
$mn_winner=$db->single(
|
$mn_winner=$db->single(
|
||||||
"SELECT public_key FROM masternode WHERE status=1 AND blacklist<:current AND height<:start ORDER by last_won ASC, public_key ASC LIMIT 1",
|
"SELECT public_key FROM masternode WHERE status=1 AND blacklist<:current AND height<:start ORDER by last_won ASC, public_key ASC LIMIT 1",
|
||||||
[":current"=>$height, ":start"=>$height-360]
|
[":current"=>$height, ":start"=>$height-360]
|
||||||
);
|
);
|
||||||
_log("MN Winner: $mn_winner", 2);
|
_log("MN Winner: $mn_winner", 2);
|
||||||
if ($mn_winner!==false) {
|
if ($mn_winner!==false) {
|
||||||
$mn_reward=round(0.33*$reward, 8);
|
$mn_reward=round($mn_reward_rate*$reward, 8);
|
||||||
$reward=round($reward-$mn_reward, 8);
|
$reward=round($reward-$mn_reward, 8);
|
||||||
$reward=number_format($reward, 8, ".", "");
|
$reward=number_format($reward, 8, ".", "");
|
||||||
$mn_reward=number_format($mn_reward, 8, ".", "");
|
$mn_reward=number_format($mn_reward, 8, ".", "");
|
||||||
|
|||||||
@@ -220,6 +220,26 @@ if ($dbversion = 10) {
|
|||||||
$dbversion++;
|
$dbversion++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($dbversion = 11) {
|
||||||
|
$db->run("ALTER TABLE `transactions` ADD INDEX(`version`); ");
|
||||||
|
$db->run("ALTER TABLE `transactions` ADD INDEX(`message`); ");
|
||||||
|
$db->run("
|
||||||
|
CREATE TABLE `logs` (
|
||||||
|
`id` int(11) NOT NULL,
|
||||||
|
`transaction` varbinary(128) NOT NULL,
|
||||||
|
`json` text DEFAULT NULL
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1;");
|
||||||
|
$db->run("ALTER TABLE `logs`
|
||||||
|
ADD PRIMARY KEY (`id`),
|
||||||
|
ADD KEY `transaction` (`transaction`);");
|
||||||
|
$db->run("ALTER TABLE `logs` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;");
|
||||||
|
|
||||||
|
$db->run("ALTER TABLE `masternode` ADD `vote_key` VARCHAR(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL AFTER `status`; ");
|
||||||
|
|
||||||
|
$dbversion++;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// update the db version to the latest one
|
// update the db version to the latest one
|
||||||
if ($dbversion != $_config['dbversion']) {
|
if ($dbversion != $_config['dbversion']) {
|
||||||
|
|||||||
@@ -4,6 +4,30 @@ use Arionum\Blacklist;
|
|||||||
|
|
||||||
class Transaction
|
class Transaction
|
||||||
{
|
{
|
||||||
|
public function add_log($x, $log)
|
||||||
|
{
|
||||||
|
global $db;
|
||||||
|
//$json=["table"=>"masternode", "key"=>"public_key","id"=>$x['public_key'], "vals"=>['ip'=>$current_ip] ];
|
||||||
|
$db->run("INSERT into logs SET transaction=:id, json=:json", [':id'=>$x['id'], ":json"=>json_encode($log)]);
|
||||||
|
}
|
||||||
|
public function reverse_log($x)
|
||||||
|
{
|
||||||
|
global $db;
|
||||||
|
$r=$db->run("SELECT json, id FROM logs WHERE transaction=:id ORDER by id DESC", [":id"=>$x['id']]);
|
||||||
|
foreach ($r as $json) {
|
||||||
|
$old=json_decode($json['json'], true);
|
||||||
|
if ($old!==false&&is_array($old)) {
|
||||||
|
//making sure there's no sql injection here, as the table name and keys are sanitized to A-Za-z0-9_
|
||||||
|
$table=san($old['table']);
|
||||||
|
$key=san($old['key'], '_');
|
||||||
|
$id=san($old['id'], '_');
|
||||||
|
foreach ($old['vals'] as $v=>$l) {
|
||||||
|
$v=san($v, '_');
|
||||||
|
$db->run("UPDATE `$table` SET `$v`=:val WHERE `$key`=:keyid", [":keyid"=>$id, ":val"=>$l]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
// reverse and remove all transactions from a block
|
// reverse and remove all transactions from a block
|
||||||
public function reverse($block)
|
public function reverse($block)
|
||||||
{
|
{
|
||||||
@@ -104,6 +128,10 @@ class Transaction
|
|||||||
_log("Update masternode balance failed", 3);
|
_log("Update masternode balance failed", 3);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
} elseif ($x['version']==104) {
|
||||||
|
$this->reverse_log($x);
|
||||||
|
} elseif ($x['version']==105) {
|
||||||
|
$db->run("UPDATE masternode SET vote_key=NULL WHERE public_key=:public_key", [":public_key"=>$x['public_key']]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// internal masternode history
|
// internal masternode history
|
||||||
@@ -128,8 +156,10 @@ class Transaction
|
|||||||
$db->run("DELETE FROM assets_balance WHERE asset=:id", [":id"=>$x['src']]);
|
$db->run("DELETE FROM assets_balance WHERE asset=:id", [":id"=>$x['src']]);
|
||||||
} elseif ($x['version']==51) {
|
} elseif ($x['version']==51) {
|
||||||
$t=json_decode($x['message'], true);
|
$t=json_decode($x['message'], true);
|
||||||
$db->run("UPDATE assets_balance SET balance=balance-:balance WHERE account=:account and asset=:asset",
|
$db->run(
|
||||||
[":account"=>$x['dst'], ":asset"=>san($t[0]), ":balance"=>intval($t[1])]);
|
"UPDATE assets_balance SET balance=balance-:balance WHERE account=:account and asset=:asset",
|
||||||
|
[":account"=>$x['dst'], ":asset"=>san($t[0]), ":balance"=>intval($t[1])]
|
||||||
|
);
|
||||||
$db->run("UPDATE assets_balance SET balance=balance+:balance WHERE account=:account and asset=:asset", [":account"=>$x['src'], ":asset"=>san($t[0]), ":balance"=>intval($t[1])]);
|
$db->run("UPDATE assets_balance SET balance=balance+:balance WHERE account=:account and asset=:asset", [":account"=>$x['src'], ":asset"=>san($t[0]), ":balance"=>intval($t[1])]);
|
||||||
} elseif ($x['version']==52) {
|
} elseif ($x['version']==52) {
|
||||||
$t=json_decode($x['message'], true);
|
$t=json_decode($x['message'], true);
|
||||||
@@ -149,11 +179,9 @@ class Transaction
|
|||||||
$db->run("UPDATE accounts SET balance=balance+:val WHERE id=:id", [":id"=>$x['src'], ":val"=>$val]);
|
$db->run("UPDATE accounts SET balance=balance+:val WHERE id=:id", [":id"=>$x['src'], ":val"=>$val]);
|
||||||
}
|
}
|
||||||
$db->run("DELETE FROM assets_market WHERE id=:id", [':id'=>$x['id']]);
|
$db->run("DELETE FROM assets_market WHERE id=:id", [':id'=>$x['id']]);
|
||||||
|
|
||||||
} elseif ($x['version']==53) {
|
} elseif ($x['version']==53) {
|
||||||
$order=$db->row("SELECT * FROM assets_market WHERE id=:id AND account=:account AND status=2", [":id"=>san($x['message']), ":account"=>$x['src']]);
|
$order=$db->row("SELECT * FROM assets_market WHERE id=:id AND account=:account AND status=2", [":id"=>san($x['message']), ":account"=>$x['src']]);
|
||||||
if($order)
|
if ($order) {
|
||||||
{
|
|
||||||
$remaining=$order['val']-$order['val_done'];
|
$remaining=$order['val']-$order['val_done'];
|
||||||
if ($remaining>0) {
|
if ($remaining>0) {
|
||||||
if ($order['type']=="ask") {
|
if ($order['type']=="ask") {
|
||||||
@@ -169,7 +197,6 @@ class Transaction
|
|||||||
$db->run("UPDATE assets_market SET status=0 WHERE id=:id", [":id"=>san($x['message'])]);
|
$db->run("UPDATE assets_market SET status=0 WHERE id=:id", [":id"=>san($x['message'])]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} elseif ($x['version']==54||$x['version']==57) {
|
} elseif ($x['version']==54||$x['version']==57) {
|
||||||
//nothing to be done
|
//nothing to be done
|
||||||
} elseif ($x['version']==55) {
|
} elseif ($x['version']==55) {
|
||||||
@@ -189,7 +216,6 @@ class Transaction
|
|||||||
$db->run("UPDATE assets_balance SET balance=balance-:balance WHERE account=:account AND asset=:asset", [":account"=>$bid['account'], ":asset"=>$bid['asset'], ":balance"=>$use]);
|
$db->run("UPDATE assets_balance SET balance=balance-:balance WHERE account=:account AND asset=:asset", [":account"=>$bid['account'], ":asset"=>$bid['asset'], ":balance"=>$use]);
|
||||||
$aro=$x['val'];
|
$aro=$x['val'];
|
||||||
$db->run("UPDATE accounts SET balance=balance-:balance WHERE id=:id", [":balance"=>$aro, ":id"=>$ask['account']]);
|
$db->run("UPDATE accounts SET balance=balance-:balance WHERE id=:id", [":balance"=>$aro, ":id"=>$ask['account']]);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -430,12 +456,24 @@ class Transaction
|
|||||||
$db->run("INSERT into masternode SET `public_key`=:public_key, `height`=:height, `ip`=:ip, `status`=1", [":public_key"=>$x['public_key'], ":height"=>$height, ":ip"=>$message]);
|
$db->run("INSERT into masternode SET `public_key`=:public_key, `height`=:height, `ip`=:ip, `status`=1", [":public_key"=>$x['public_key'], ":height"=>$height, ":ip"=>$message]);
|
||||||
} else {
|
} else {
|
||||||
if ($x['version']==101) {
|
if ($x['version']==101) {
|
||||||
|
// pause masternode
|
||||||
$db->run("UPDATE masternode SET status=0 WHERE public_key=:public_key", [':public_key'=>$x['public_key']]);
|
$db->run("UPDATE masternode SET status=0 WHERE public_key=:public_key", [':public_key'=>$x['public_key']]);
|
||||||
} elseif ($x['version']==102) {
|
} elseif ($x['version']==102) {
|
||||||
|
// reactivate pasternode
|
||||||
$db->run("UPDATE masternode SET status=1 WHERE public_key=:public_key", [':public_key'=>$x['public_key']]);
|
$db->run("UPDATE masternode SET status=1 WHERE public_key=:public_key", [':public_key'=>$x['public_key']]);
|
||||||
} elseif ($x['version']==103) {
|
} elseif ($x['version']==103) {
|
||||||
|
// release and cancel the masternode
|
||||||
$db->run("DELETE FROM masternode WHERE public_key=:public_key", [':public_key'=>$x['public_key']]);
|
$db->run("DELETE FROM masternode WHERE public_key=:public_key", [':public_key'=>$x['public_key']]);
|
||||||
$db->run("UPDATE accounts SET balance=balance+100000 WHERE public_key=:public_key", [':public_key'=>$x['public_key']]);
|
$db->run("UPDATE accounts SET balance=balance+100000 WHERE public_key=:public_key", [':public_key'=>$x['public_key']]);
|
||||||
|
} elseif ($x['version']==104) {
|
||||||
|
// update ip
|
||||||
|
$current_ip=$db->single("SELECT ip FROM masternode WHERE public_key=:public_key", [":public_key"=>$x['public_key']]);
|
||||||
|
$json=["table"=>"masternode", "key"=>"public_key","id"=>$x['public_key'], "vals"=>['ip'=>$current_ip] ];
|
||||||
|
$this->add_log($x, $json);
|
||||||
|
$db->run("UPDATE masternode SET ip=:ip WHERE public_key=:public_key", [':ip'=>$message, ":public_key"=>$x['public_key']]);
|
||||||
|
} elseif ($x['version']==105) {
|
||||||
|
// add vote key
|
||||||
|
$db->run("UPDATE masternode SET vote_key=:vote_key WHERE public_key=:public_key AND vote_key is NULL", [':vote_key'=>san($x['message']), ":public_key"=>$x['public_key']]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -459,8 +497,10 @@ class Transaction
|
|||||||
} elseif ($x['version']==51) {
|
} elseif ($x['version']==51) {
|
||||||
// send asset
|
// send asset
|
||||||
$t=json_decode($x['message'], true);
|
$t=json_decode($x['message'], true);
|
||||||
$db->run("INSERT into assets_balance SET account=:account, asset=:asset, balance=:balance ON DUPLICATE KEY UPDATE balance=balance+:balance2",
|
$db->run(
|
||||||
[":account"=>$x['dst'], ":asset"=>san($t[0]), ":balance"=>intval($t[1]), ":balance2"=>intval($t[1])]);
|
"INSERT into assets_balance SET account=:account, asset=:asset, balance=:balance ON DUPLICATE KEY UPDATE balance=balance+:balance2",
|
||||||
|
[":account"=>$x['dst'], ":asset"=>san($t[0]), ":balance"=>intval($t[1]), ":balance2"=>intval($t[1])]
|
||||||
|
);
|
||||||
$db->run("UPDATE assets_balance SET balance=balance-:balance WHERE account=:account and asset=:asset", [":account"=>$x['src'], ":asset"=>san($t[0]), ":balance"=>intval($t[1])]);
|
$db->run("UPDATE assets_balance SET balance=balance-:balance WHERE account=:account and asset=:asset", [":account"=>$x['src'], ":asset"=>san($t[0]), ":balance"=>intval($t[1])]);
|
||||||
} elseif ($x['version']==52) {
|
} elseif ($x['version']==52) {
|
||||||
// market order
|
// market order
|
||||||
@@ -499,8 +539,7 @@ class Transaction
|
|||||||
} elseif ($x['version']==53) {
|
} elseif ($x['version']==53) {
|
||||||
// cancel order
|
// cancel order
|
||||||
$order=$db->row("SELECT * FROM assets_market WHERE id=:id AND account=:account AND status=0", [":id"=>san($x['message']), ":account"=>$x['src']]);
|
$order=$db->row("SELECT * FROM assets_market WHERE id=:id AND account=:account AND status=0", [":id"=>san($x['message']), ":account"=>$x['src']]);
|
||||||
if($order)
|
if ($order) {
|
||||||
{
|
|
||||||
$remaining=$order['val']-$order['val_done'];
|
$remaining=$order['val']-$order['val_done'];
|
||||||
if ($remaining>0) {
|
if ($remaining>0) {
|
||||||
if ($order['type']=="ask") {
|
if ($order['type']=="ask") {
|
||||||
@@ -516,8 +555,6 @@ class Transaction
|
|||||||
$db->run("UPDATE assets_market SET status=2 WHERE id=:id", [":id"=>san($x['message'])]);
|
$db->run("UPDATE assets_market SET status=2 WHERE id=:id", [":id"=>san($x['message'])]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} elseif ($x['version']==54||$x['version']==57) {
|
} elseif ($x['version']==54||$x['version']==57) {
|
||||||
//distribute dividends - only from asset wallet and only to other holders
|
//distribute dividends - only from asset wallet and only to other holders
|
||||||
|
|
||||||
@@ -546,9 +583,10 @@ class Transaction
|
|||||||
"message" => '',
|
"message" => '',
|
||||||
];
|
];
|
||||||
$res=$this->add($block, $height, $new);
|
$res=$this->add($block, $height, $new);
|
||||||
if(!$res) return false;
|
if (!$res) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} elseif ($x['version']==55) {
|
} elseif ($x['version']==55) {
|
||||||
// increase max supply
|
// increase max supply
|
||||||
$plus=intval($x['message']);
|
$plus=intval($x['message']);
|
||||||
@@ -630,6 +668,8 @@ class Transaction
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//masternode transactions
|
//masternode transactions
|
||||||
|
|
||||||
if ($x['version']>=100&&$x['version']<110&&$height>=80000) {
|
if ($x['version']>=100&&$x['version']<110&&$height>=80000) {
|
||||||
@@ -680,6 +720,55 @@ class Transaction
|
|||||||
_log("The masternode start height is less than 32400 blocks! $height - $mn[height]", 3);
|
_log("The masternode start height is less than 32400 blocks! $height - $mn[height]", 3);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
} elseif ($x['version']==104) {
|
||||||
|
//only once per month (every 10800 blocks)
|
||||||
|
$res=$db->single("SELECT COUNT(1) FROM transactions WHERE public_key=:public_key AND version=104 AND height>:height", [':public_key'=>$x['public_key'], ":height"=>$height-10800]);
|
||||||
|
if ($res!=0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} elseif ($x['version']==105) {
|
||||||
|
// already using this ip
|
||||||
|
if ($message==$mn['ip']) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// valid ips
|
||||||
|
$message=$x['message'];
|
||||||
|
$message=preg_replace("/[^0-9\.]/", "", $message);
|
||||||
|
if (!filter_var($message, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE)) {
|
||||||
|
_log("The Masternode IP is invalid", 3);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// making sure the ip is not already in use
|
||||||
|
global $db;
|
||||||
|
$existing=$db->single("SELECT COUNT(1) FROM masternode WHERE ip=:ip", [":ip"=>$message]);
|
||||||
|
if ($existing!=0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// masternode votes
|
||||||
|
elseif ($x['version']==106) {
|
||||||
|
// value always 0
|
||||||
|
if ($x['val']!=0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// one vote to each mn per 10800 blocks
|
||||||
|
$res=$db->single("SELECT COUNT(1) FROM transactions WHERE dst=:dst AND version=106 AND public_key=:id AND height>:height", [':dst'=>$x['dst'], ":id"=>$x['public_key'], ":height"=>$height-10800]);
|
||||||
|
if ($res>0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// masternode blockchain votes
|
||||||
|
elseif ($x['version']==107) {
|
||||||
|
// value always 0
|
||||||
|
if ($x['val']!=0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// one vote to each mn per 32400 blocks
|
||||||
|
$res=$db->single("SELECT COUNT(1) FROM transactions WHERE message=:message AND version=107 AND public_key=:id AND height>:height", [':message'=>$x['message'], ":id"=>$x['public_key'], ":height"=>$height-32400]);
|
||||||
|
if ($res>0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -771,8 +860,6 @@ class Transaction
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
// make sure the dividend only function is not bypassed after height X
|
// make sure the dividend only function is not bypassed after height X
|
||||||
if (($x['version']==1||$x['version']==2)&&$height>11111) {
|
if (($x['version']==1||$x['version']==2)&&$height>11111) {
|
||||||
@@ -781,7 +868,6 @@ class Transaction
|
|||||||
_log("This asset wallet cannot send funds directly", 3);
|
_log("This asset wallet cannot send funds directly", 3);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -842,8 +928,6 @@ class Transaction
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
if ($blockasset['id']==$src && $blockasset['price']>0 && $blockasset['price']!=$asset[1]) {
|
if ($blockasset['id']==$src && $blockasset['price']>0 && $blockasset['price']!=$asset[1]) {
|
||||||
// In case the asset has fixed price, the asset wallet cannot sell on a different price (to prevent abuse by the owner)
|
// In case the asset has fixed price, the asset wallet cannot sell on a different price (to prevent abuse by the owner)
|
||||||
@@ -955,11 +1039,27 @@ class Transaction
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if ($x['version']==106) {
|
||||||
|
// the masternode votes are using a different signature
|
||||||
|
$vote_key=$db->single("SELECT vote_key FROM masternode WHERE public_key=:public_key", [':public_key'=>$x['public_key']]);
|
||||||
|
if (empty($vote_key)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!$acc->check_signature($info, $x['signature'], $vote_key)) {
|
||||||
|
_log("$x[id] - Invalid vote key signature - $info");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
//verify the ecdsa signature
|
//verify the ecdsa signature
|
||||||
if (!$acc->check_signature($info, $x['signature'], $x['public_key'])) {
|
if (!$acc->check_signature($info, $x['signature'], $x['public_key'])) {
|
||||||
_log("$x[id] - Invalid signature - $info");
|
_log("$x[id] - Invalid signature - $info");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -658,7 +658,12 @@ if ($current['height'] < $largest_height && $largest_height > 1) {
|
|||||||
if (empty($alias)) {
|
if (empty($alias)) {
|
||||||
$alias="A";
|
$alias="A";
|
||||||
}
|
}
|
||||||
$rec=$db->single("SELECT SUM(val) FROM transactions WHERE (dst=:id or dst=:alias) AND (height<80000 OR (version!=100 AND version!=103)) and version<111", [":id"=>$x['id'], ":alias"=>$alias]);
|
$rec=$db->single("SELECT SUM(val) FROM transactions WHERE (dst=:id or dst=:alias) AND (height<80000 OR version!=100) and version<111", [":id"=>$x['id'], ":alias"=>$alias]);
|
||||||
|
$releases=$db->single("SELECT COUNT(1) FROM transactions WHERE dst=:id AND version=103", [":id"=>$x['id']]);
|
||||||
|
if ($releases>0) { //masternode releases
|
||||||
|
$rec+=$releases*100000;
|
||||||
|
}
|
||||||
|
|
||||||
$spent=$db->single("SELECT SUM(val+fee) FROM transactions WHERE public_key=:pub AND version>0", [":pub"=>$x['public_key']]);
|
$spent=$db->single("SELECT SUM(val+fee) FROM transactions WHERE public_key=:pub AND version>0", [":pub"=>$x['public_key']]);
|
||||||
if ($spent==false) {
|
if ($spent==false) {
|
||||||
$spent=0;
|
$spent=0;
|
||||||
|
|||||||
9
util.php
9
util.php
@@ -472,7 +472,11 @@ elseif ($cmd == 'get-address') {
|
|||||||
if (empty($alias)) {
|
if (empty($alias)) {
|
||||||
$alias="A";
|
$alias="A";
|
||||||
}
|
}
|
||||||
$rec=$db->single("SELECT SUM(val) FROM transactions WHERE (dst=:id or dst=:alias) AND (height<80000 OR (version!=100 AND version!=103)) and version<111", [":id"=>$x['id'], ":alias"=>$alias]);
|
$rec=$db->single("SELECT SUM(val) FROM transactions WHERE (dst=:id or dst=:alias) AND (height<80000 OR version!=100) and version<111", [":id"=>$x['id'], ":alias"=>$alias]);
|
||||||
|
$releases=$db->single("SELECT COUNT(1) FROM transactions WHERE dst=:id AND version=103", [":id"=>$x['id']]);
|
||||||
|
if ($releases>0) { //masternode releases
|
||||||
|
$rec+=$releases*100000;
|
||||||
|
}
|
||||||
$spent=$db->single("SELECT SUM(val+fee) FROM transactions WHERE public_key=:pub AND version>0", [":pub"=>$x['public_key']]);
|
$spent=$db->single("SELECT SUM(val+fee) FROM transactions WHERE public_key=:pub AND version>0", [":pub"=>$x['public_key']]);
|
||||||
if ($spent==false) {
|
if ($spent==false) {
|
||||||
$spent=0;
|
$spent=0;
|
||||||
@@ -555,7 +559,6 @@ elseif ($cmd == 'get-address') {
|
|||||||
}
|
}
|
||||||
$response = peer_post($peer."/peer.php?q=submitBlock", $data, 60, true);
|
$response = peer_post($peer."/peer.php?q=submitBlock", $data, 60, true);
|
||||||
var_dump($response);
|
var_dump($response);
|
||||||
|
|
||||||
} elseif ($cmd == "recheck-external-blocks") {
|
} elseif ($cmd == "recheck-external-blocks") {
|
||||||
$peer=trim($argv[2]);
|
$peer=trim($argv[2]);
|
||||||
if (!filter_var($peer, FILTER_VALIDATE_URL)) {
|
if (!filter_var($peer, FILTER_VALIDATE_URL)) {
|
||||||
@@ -590,8 +593,6 @@ elseif ($cmd == 'get-address') {
|
|||||||
echo "Block $i -> ok\n";
|
echo "Block $i -> ok\n";
|
||||||
$b=$c;
|
$b=$c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
echo "Invalid command\n";
|
echo "Invalid command\n";
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user