private static function savecoins($coins) { $old = storage::load(); if (!$old) { $old = array(); } foreach ($coins as $val => $ccs) { foreach ($ccs as $id => $coin) { $old[$val][$id] = $coin; } } if (storage::save($old)) { return true; } return false; }
public static function spentcoins($coins, $account) { if (!is_array($coins)) { return false; } $old = storage::load($account); if (!$old) { return false; } foreach ($coins as $id => $coin) { $val = $coin['value']; if (array_key_exists($id, $old[$val])) { unset($old[$val][$id]); } } $ret = storage::save($old, $account); $ret = $ret ? 1 : 0; return $ret; }
public static function log(&$in) { list($oid, $t) = each($in); if (!is_array($t) || !isset($t['order id'])) { $t = $in; $oid = $t['order id']; } if (isset($t['coins'])) { unset($t['coins']); } if (isset($t['change'])) { unset($t['change']); } $acc = Tools::address($t['client']); $acm = Tools::address($t['merchant']); $ac = $acc['account']; $am = $acm['account']; $tr[$oid] = $t; if (account::exists($ac) || $ac == config::$accountId) { $oldc = storage::load("{$ac}.transaction"); if (!$oldc) { $oldc = array(); } $oldc[$oid] = $tr[$oid]; storage::save($oldc, "{$ac}.transaction"); } if (account::exists($am) || $am == config::$accountId) { $oldm = storage::load("{$am}.transaction"); if (!$oldm) { $oldm = array(); } $oldm[$oid] = $tr[$oid]; storage::save($oldm, "{$am}.transaction"); } }
public static function log(&$t) { if (isset($t['coins'])) { unset($t['coins']); } if (isset($t['change'])) { unset($t['change']); } $tid = $t['acknowledgement']['id']; $tr[$tid] = $t; $old = storage::load('__Transactions__.lg'); if (!$old) { $old = array(); } $new = array_merge($old, $tr); storage::save($new, '__Transactions__.lg'); }
public static function spentcoins($coins) { global $reusespentecash; if (isset($reusespentecash) && $reusespentecash) { return false; } if (!is_array($coins)) { return false; } self::balance($wal); if (!is_array($wal)) { return false; } foreach ($coins as $id => $coin) { $val = $coin['value']; if (array_key_exists($id, $wal[$val][$id])) { unset($wal[$val][$id]); } } $ret = storage::save($wal); $ret = $ret ? 1 : 0; return $ret; }
public static function spentcoins($coins, $account) { if (!is_array($coins) || $account != config::$accountId && !account::exists($account)) { return false; } if (!is_array($coins)) { return false; } $dest = strtolower($account) == strtolower(config::$accountId) ? config::$walfile : $account; $old = storage::load($dest); if (!$old) { return false; } foreach ($coins as $id => $coin) { $val = $coin['value']; if (array_key_exists($id, $old[$val])) { unset($old[$val][$id]); } } $ret = storage::save($old, $dest); $ret = $ret ? 1 : 0; return $ret; }