Skip to content
This repository has been archived by the owner on Oct 14, 2020. It is now read-only.

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeRow committed Jun 9, 2020
1 parent 04f2478 commit e9b5194
Show file tree
Hide file tree
Showing 59 changed files with 76 additions and 57 deletions.
7 changes: 7 additions & 0 deletions autoload.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

require_once __DIR__ . '/src/NanoBlock.php';
require_once __DIR__ . '/src/NanoCLI.php';
require_once __DIR__ . '/src/NanoRPC.php';
require_once __DIR__ . '/src/NanoRPCExt.php';
require_once __DIR__ . '/src/NanoTool.php';
31 changes: 28 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,33 @@
{
"name" : "mikerow/php4nano",
"description" : "PHP libraries and tools for the Nano currency",
"type" : "library",
"description" : "PHP libraries and tools for the Nano currency",
"keywords" : [
"nano",
"raiblocks",
"raiblockscommunity",
"node",
"crypto",
"currency",
"coin",
"protocol",
"RPC",
"CLI",
"tools",
"blocks",
"library",
"libraries",
"class",
"classes"
],
"homepage" : "https://github.com/mikerow/php4nano",
"license" : "MIT",
"authors" : [{
"name" : "Mike Row",
"nano" : "nano_1mikerow9bqzyqo4ejra6ugr1srerq1egwmacerquch3dz1wry7mkrz4768m",
"role" : "Developer"
}
],
"require" : {
"php-64bit" : "^7.0.0",
"ext-curl" : "*",
Expand All @@ -11,11 +36,11 @@
"ext-openssl" : "*"
},
"suggest" : {
"ext-blake2" : "https://github.com/strawbrary/php-blake2"
"ext-blake2" : "Install the blake2 extension in order to speed up some functions, https://github.com/strawbrary/php-blake2"
},
"autoload" : {
"psr-4" : {
"php4nano\\" : "lib/"
"php4nano\\" : "src/"
}
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 0 additions & 3 deletions lib/NanoBlock.php → src/NanoBlock.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@

namespace php4nano;

require_once __DIR__ . '/NanoTool.php';

use \Exception as Exception;
use php4nano\NanoTool as NanoTool;

class NanoBlock
{
Expand Down
File renamed without changes.
File renamed without changes.
15 changes: 8 additions & 7 deletions lib/NanoRPCExt.php → src/NanoRPCExt.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@

namespace php4nano;

require_once __DIR__ . '/NanoTool.php';
require_once __DIR__ . '/NanoRPC.php';

use \Exception as Exception;

class NanoRPCExt extends NanoRPC
Expand Down Expand Up @@ -76,7 +73,8 @@ public function wallet_sweep(array $args)
foreach ($wallet_balances['balances'] as $account => $balances) {
if ($account == $destination) {
$return['balances'][$account] = [
'warning' => 'Skipped self send'
'notice' => 'Skipped self send',
'amount' => $balances['balance']
];
continue;
}
Expand All @@ -99,7 +97,8 @@ public function wallet_sweep(array $args)

if ($send['block'] == self::EMPTY32) {
$return['balances'][$account] = [
'error' => 'Bad send'
'error' => 'Bad send',
'amount' => $balances['balance']
];
}
}
Expand Down Expand Up @@ -211,7 +210,8 @@ public function wallet_send(array $args)
foreach ($selected_accounts as $account => $balance) {
if ($account == $destination) {
$return['balances'][$account] = [
'warning' => 'Skipped self send'
'notice' => 'Skipped self send',
'amount' => $balances['balance']
];
continue;
}
Expand All @@ -234,7 +234,8 @@ public function wallet_send(array $args)

if ($send['block'] == self::EMPTY32) {
$return['balances'][$account] = [
'error' => 'Bad send'
'error' => 'Bad send',
'amount' => $balances['balance']
];
}
}
Expand Down
11 changes: 5 additions & 6 deletions lib/NanoTool.php → src/NanoTool.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@

namespace php4nano;

require_once __DIR__ . '/../lib3/Salt/autoload.php';
require_once __DIR__ . '/../lib3/Util.php';
require_once __DIR__ . '/../lib/Salt/autoload.php';
require_once __DIR__ . '/../lib/Util.php';

use \Exception as Exception;
use \Util as Util;
use \Uint as Uint;
use \SplFixedArray as SplFixedArray;
use \Blake2b as Blake2b;
Expand Down Expand Up @@ -342,7 +341,7 @@ public static function mnem2hex(array $words): string
throw new Exception("Words array count is not 12 or 24");
}

$bip39_words = json_decode(file_get_contents(__DIR__ . '/../lib3/BIP39/BIP39_en.json'), true);
$bip39_words = json_decode(file_get_contents(__DIR__ . '/../lib/BIP39/BIP39_en.json'), true);
$mnem_count = count($words);
$bits = [];
$hex = [];
Expand Down Expand Up @@ -385,7 +384,7 @@ public static function hex2mnem(string $hex): array
throw new Exception("Invalid hexadecimal string: $hex");
}

$bip39_words = json_decode(file_get_contents(__DIR__ . '/../lib3/BIP39/BIP39_en.json'), true);
$bip39_words = json_decode(file_get_contents(__DIR__ . '/../lib/BIP39/BIP39_en.json'), true);
$hex_lenght = strlen($hex);
$bits = [];
$mnemonic = [];
Expand Down Expand Up @@ -417,7 +416,7 @@ public static function mnem2mseed(array $words, string $passphrase = ''): string
throw new Exception("Words array count is less than 1");
}

$bip39_words = json_decode(file_get_contents(__DIR__ . '/../lib3/BIP39/BIP39_en.json'), true);
$bip39_words = json_decode(file_get_contents(__DIR__ . '/../lib/BIP39/BIP39_en.json'), true);

foreach ($words as $index => $value) {
$word = array_search($value, $bip39_words);
Expand Down
4 changes: 1 addition & 3 deletions test/NanoBlock/change.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
<?php

require_once __DIR__ . '/../../lib/NanoTool.php';
require_once __DIR__ . '/../../lib/NanoBlock.php';
require_once __DIR__ . '/../../lib/NanoRPCExt.php';
require_once __DIR__ . '/../../autoload.php';

use php4nano\NanoTool as NanoTool;

Expand Down
4 changes: 1 addition & 3 deletions test/NanoBlock/open.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
<?php

require_once __DIR__ . '/../../lib/NanoTool.php';
require_once __DIR__ . '/../../lib/NanoBlock.php';
require_once __DIR__ . '/../../lib/NanoRPCExt.php';
require_once __DIR__ . '/../../autoload.php';

use php4nano\NanoTool as NanoTool;

Expand Down
4 changes: 1 addition & 3 deletions test/NanoBlock/receive.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
<?php

require_once __DIR__ . '/../../lib/NanoTool.php';
require_once __DIR__ . '/../../lib/NanoBlock.php';
require_once __DIR__ . '/../../lib/NanoRPCExt.php';
require_once __DIR__ . '/../../autoload.php';

use php4nano\NanoTool as NanoTool;

Expand Down
4 changes: 1 addition & 3 deletions test/NanoBlock/send.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
<?php

require_once __DIR__ . '/../../lib/NanoTool.php';
require_once __DIR__ . '/../../lib/NanoBlock.php';
require_once __DIR__ . '/../../lib/NanoRPCExt.php';
require_once __DIR__ . '/../../autoload.php';

use php4nano\NanoTool as NanoTool;

Expand Down
2 changes: 1 addition & 1 deletion test/NanoCLI.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

require_once __DIR__ . '/../lib/NanoCLI.php';
require_once __DIR__ . '/../autoload.php';

$nanocli = new php4nano\NanoCLI('/home/nano/nano_node');

Expand Down
2 changes: 1 addition & 1 deletion test/NanoRPC.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

require_once __DIR__ . '/../lib/NanoRPC.php';
require_once __DIR__ . '/../autoload.php';

$nanorpc = new php4nano\NanoRPC();

Expand Down
2 changes: 1 addition & 1 deletion test/NanoRPCExt.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

require_once __DIR__ . '/../lib/NanoRPCExt.php';
require_once __DIR__ . '/../autoload.php';

$nanorpc = new php4nano\NanoRPCExt();

Expand Down
6 changes: 2 additions & 4 deletions test/NanoTool/account2public.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
<?php

require_once __DIR__ . '/../../lib/NanoTool.php';
require_once __DIR__ . '/../../autoload.php';

use php4nano\NanoTool as NanoTool;

echo NanoTool::account2public('nano_3ieu9rjq8uyd3h1taykfb3s14g5p6mnu73hep4iox8w91hew3147eejgogxx');

echo PHP_EOL;
var_dump(NanoTool::account2public('nano_3ieu9rjq8uyd3h1taykfb3s14g5p6mnu73hep4iox8w91hew3147eejgogxx'));

var_dump(NanoTool::account2public('nano_3ieu9rjq8uyd3h1taykfb3s14g5p6mnu73hep4iox8w91hew3147eejgogxx', false));
2 changes: 1 addition & 1 deletion test/NanoTool/arr2bin.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

require_once __DIR__ . '/../../lib/NanoTool.php';
require_once __DIR__ . '/../../autoload.php';

use php4nano\NanoTool as NanoTool;

Expand Down
2 changes: 1 addition & 1 deletion test/NanoTool/bin2arr.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

require_once __DIR__ . '/../../lib/NanoTool.php';
require_once __DIR__ . '/../../autoload.php';

use php4nano\NanoTool as NanoTool;

Expand Down
2 changes: 1 addition & 1 deletion test/NanoTool/den2den.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

require_once __DIR__ . '/../../lib/NanoTool.php';
require_once __DIR__ . '/../../autoload.php';

use php4nano\NanoTool as NanoTool;

Expand Down
2 changes: 1 addition & 1 deletion test/NanoTool/den2raw.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

require_once __DIR__ . '/../../lib/NanoTool.php';
require_once __DIR__ . '/../../autoload.php';

use php4nano\NanoTool as NanoTool;

Expand Down
2 changes: 1 addition & 1 deletion test/NanoTool/getBlockId.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

require_once __DIR__ . '/../../lib/NanoTool.php';
require_once __DIR__ . '/../../autoload.php';

use php4nano\NanoTool as NanoTool;

Expand Down
2 changes: 1 addition & 1 deletion test/NanoTool/getWork.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

require_once __DIR__ . '/../../lib/NanoTool.php';
require_once __DIR__ . '/../../autoload.php';

use php4nano\NanoTool as NanoTool;

Expand Down
2 changes: 1 addition & 1 deletion test/NanoTool/hex2mnem.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

require_once __DIR__ . '/../../lib/NanoTool.php';
require_once __DIR__ . '/../../autoload.php';

use php4nano\NanoTool as NanoTool;

Expand Down
2 changes: 1 addition & 1 deletion test/NanoTool/keys.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

require_once __DIR__ . '/../../lib/NanoTool.php';
require_once __DIR__ . '/../../autoload.php';

use php4nano\NanoTool as NanoTool;

Expand Down
2 changes: 1 addition & 1 deletion test/NanoTool/mnem2hex.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

require_once __DIR__ . '/../../lib/NanoTool.php';
require_once __DIR__ . '/../../autoload.php';

use php4nano\NanoTool as NanoTool;

Expand Down
2 changes: 1 addition & 1 deletion test/NanoTool/mnem2mseed.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

require_once __DIR__ . '/../../lib/NanoTool.php';
require_once __DIR__ . '/../../autoload.php';

use php4nano\NanoTool as NanoTool;

Expand Down
2 changes: 1 addition & 1 deletion test/NanoTool/mseed2keys.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

require_once __DIR__ . '/../../lib/NanoTool.php';
require_once __DIR__ . '/../../autoload.php';

use php4nano\NanoTool as NanoTool;

Expand Down
2 changes: 1 addition & 1 deletion test/NanoTool/multDiff.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

require_once __DIR__ . '/../../lib/NanoTool.php';
require_once __DIR__ . '/../../autoload.php';

use php4nano\NanoTool as NanoTool;

Expand Down
2 changes: 1 addition & 1 deletion test/NanoTool/private2public.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

require_once __DIR__ . '/../../lib/NanoTool.php';
require_once __DIR__ . '/../../autoload.php';

use php4nano\NanoTool as NanoTool;

Expand Down
2 changes: 1 addition & 1 deletion test/NanoTool/public2account.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

require_once __DIR__ . '/../../lib/NanoTool.php';
require_once __DIR__ . '/../../autoload.php';

use php4nano\NanoTool as NanoTool;

Expand Down
2 changes: 1 addition & 1 deletion test/NanoTool/raw2den.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

require_once __DIR__ . '/../../lib/NanoTool.php';
require_once __DIR__ . '/../../autoload.php';

use php4nano\NanoTool as NanoTool;

Expand Down
2 changes: 1 addition & 1 deletion test/NanoTool/seed2keys.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

require_once __DIR__ . '/../../lib/NanoTool.php';
require_once __DIR__ . '/../../autoload.php';

use php4nano\NanoTool as NanoTool;

Expand Down
2 changes: 1 addition & 1 deletion test/NanoTool/signMsg.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

require_once __DIR__ . '/../../lib/NanoTool.php';
require_once __DIR__ . '/../../autoload.php';

use php4nano\NanoTool as NanoTool;

Expand Down
2 changes: 1 addition & 1 deletion test/NanoTool/validSign.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

require_once __DIR__ . '/../../lib/NanoTool.php';
require_once __DIR__ . '/../../autoload.php';

use php4nano\NanoTool as NanoTool;

Expand Down
2 changes: 1 addition & 1 deletion test/NanoTool/validWork.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

require_once __DIR__ . '/../../lib/NanoTool.php';
require_once __DIR__ . '/../../autoload.php';

use php4nano\NanoTool as NanoTool;

Expand Down

0 comments on commit e9b5194

Please sign in to comment.