Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Qubic Core client

An intermediate tool to communicate to qubic core node.

> [![MultiPlatformBuild](https://github.com/qubic/qubic-cli/actions/workflows/cmake-multi-platform.yml/badge.svg?branch=main)](https://github.com/qubic/qubic-cli/actions/workflows/cmake-multi-platform.yml)
> [MultiPlatformBuild](https://github.com/qubic/qubic-cli/actions/workflows/cmake-multi-platform.yml)

```
./qubic-cli [basic config] [command] [command extra parameters]
Expand Down Expand Up @@ -468,6 +468,16 @@ Commands:
Get information about a locked order by nonce.
-qsbisorderfilled <ORDER_HASH_HEX>
Check if an order hash has already been filled in QSB (64 hex chars).
-qsbcomputeorderhash <FROM_ID> <TO_ID> <AMOUNT> <RELAYER_FEE> <DEST_CHAIN> <NET_IN> <NET_OUT> <NONCE>
Compute canonical order hash for Unlock verification. Use with -qsbisorderfilled to verify an unlock.
-qsbgetoracles
List all oracle accounts (bulk enumeration).
-qsbgetpausers
List all pauser accounts (bulk enumeration).
-qsbgetlockedorders [OFFSET] [LIMIT]
List locked orders (paginated). Default offset=0, limit=64.
-qsbgetfilledorders [OFFSET] [LIMIT]
List filled order hashes (paginated). Default offset=0, limit=64.

[TESTING COMMANDS]
-testqpifunctionsoutput
Expand All @@ -485,6 +495,7 @@ enabled.
### BUILD

On Linux or MacOS, make sure `cmake` and `make` commands are installed and then run:

```
mkdir build;
cd build;
Expand All @@ -494,7 +505,6 @@ cmake --build .;

On Windows, use the CMake GUI to create a Visual Studio project and then build the executable in Visual Studio.


### USAGE

#### Basic usage
Expand All @@ -504,6 +514,7 @@ To get current tick of a node:
`./qubic-cli -nodeip 127.0.0.1 -getcurrenttick`

example return:

```
Tick: 10660587
Epoch: 82
Expand All @@ -515,6 +526,7 @@ Dump publickey, privatekey and identity:
`./qubic-cli -seed aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa -showkeys`

example return:

```
Seed: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
Private key: 62506d370a4e9f42720269c0c973a544de0b6559bda46d1d8dd2fcda9fe4fada
Expand Down Expand Up @@ -597,7 +609,6 @@ To represent the `GetWinners_output` struct, we use the following format string

***Supported data types:*** `sint8`, `uint8`, `sint16`, `uint16`, `sint32`, `uint32`, `sint64`, `uint64`, `id`, `Array`, `Struct`


**Invoke a contract procedure:**

Example — creating a multisig vault with 2 owners and threshold = 2:
Expand All @@ -620,3 +631,4 @@ Example — how to get current players of the `RandomLottery` contract
More information, please read the help. `./qubic-cli -help`

#### NOTE: PROPER ACTIONS are needed if you use this tool as a replacement for qubic wallet. Please use it with caution.

89 changes: 89 additions & 0 deletions argparser.h
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,8 @@ void print_help()
printf("\t\tLock QU to bridge to Solana. <AMOUNT> is the amount to lock, <RELAYER_FEE> is the fee for relayer (must be < AMOUNT>), <TO_ADDRESS_HEX> is the Solana recipient address as 128 hex characters (64 bytes), <NETWORK_OUT> is the destination network ID, <NONCE> is a unique order nonce.\n");
printf("\t-qsboverridelock <NONCE> <TO_ADDRESS_HEX> <RELAYER_FEE>\n");
printf("\t\tOverride a previously locked order. <NONCE> is the nonce of the locked order, <TO_ADDRESS_HEX> is the new Solana recipient address (128 hex chars), <RELAYER_FEE> is the new relayer fee.\n");
printf("\t-qsbcancellock <NONCE>\n");
printf("\t\tCancel a locked order and refund QU to sender. Only the original sender can cancel. <NONCE> is the nonce of the locked order.\n");
printf("\t-qsbunlock <ORDER_DATA> <NUM_SIGNATURES> <SIGNATURES>\n");
printf("\t\tUnlock funds from Solana (requires oracle signatures). This is a complex operation - use invokecontractprocedure for full control.\n");
printf("\t-qsbtransferadmin <NEW_ADMIN_IDENTITY>\n");
Expand All @@ -519,6 +521,16 @@ void print_help()
printf("\t\tGet information about a locked order by nonce.\n");
printf("\t-qsbisorderfilled <ORDER_HASH_HEX>\n");
printf("\t\tCheck if an order hash has already been filled in QSB (64 hex chars).\n");
printf("\t-qsbcomputeorderhash <FROM_ID> <TO_ID> <AMOUNT> <RELAYER_FEE> <DEST_CHAIN> <NET_IN> <NET_OUT> <NONCE>\n");
printf("\t\tCompute canonical order hash for verification.\n");
printf("\t-qsbgetoracles\n");
printf("\t\tList all oracle accounts.\n");
printf("\t-qsbgetpausers\n");
printf("\t\tList all pauser accounts.\n");
printf("\t-qsbgetlockedorders [OFFSET] [LIMIT]\n");
printf("\t\tList locked orders (paginated, default offset=0 limit=64).\n");
printf("\t-qsbgetfilledorders [OFFSET] [LIMIT]\n");
printf("\t\tList filled order hashes (paginated, default offset=0 limit=64).\n");

printf("\n[TESTING COMMANDS]\n");
printf("\t-testqpifunctionsoutput\n");
Expand Down Expand Up @@ -2739,6 +2751,15 @@ void parseArgument(int argc, char** argv)
CHECK_OVER_PARAMETERS
break;
}
if (strcmp(argv[i], "-qsbcancellock") == 0)
{
CHECK_NUMBER_OF_PARAMETERS(1)
g_cmd = QSB_CANCEL_LOCK_CMD;
g_qsb_nonce = (uint32_t)charToNumber(argv[i + 1]);
i += 2;
CHECK_OVER_PARAMETERS
break;
}
if (strcmp(argv[i], "-qsbtransferadmin") == 0)
{
CHECK_NUMBER_OF_PARAMETERS(1)
Expand Down Expand Up @@ -2846,6 +2867,74 @@ void parseArgument(int argc, char** argv)
CHECK_OVER_PARAMETERS
break;
}
if (strcmp(argv[i], "-qsbcomputeorderhash") == 0)
{
CHECK_NUMBER_OF_PARAMETERS(8)
g_cmd = QSB_COMPUTE_ORDER_HASH_CMD;
g_qsb_computeOrderFromId = argv[i + 1];
g_qsb_computeOrderToId = argv[i + 2];
g_qsb_computeOrderAmount = (uint64_t)charToNumber(argv[i + 3]);
g_qsb_computeOrderRelayerFee = (uint64_t)charToNumber(argv[i + 4]);
g_qsb_computeOrderDestChain = (uint32_t)charToNumber(argv[i + 5]);
g_qsb_computeOrderNetIn = (uint32_t)charToNumber(argv[i + 6]);
g_qsb_computeOrderNetOut = (uint32_t)charToNumber(argv[i + 7]);
g_qsb_computeOrderNonce = (uint32_t)charToNumber(argv[i + 8]);
i += 9;
CHECK_OVER_PARAMETERS
break;
}
if (strcmp(argv[i], "-qsbgetoracles") == 0)
{
g_cmd = QSB_GET_ORACLES_CMD;
++i;
CHECK_OVER_PARAMETERS
break;
}
if (strcmp(argv[i], "-qsbgetpausers") == 0)
{
g_cmd = QSB_GET_PAUSERS_CMD;
++i;
CHECK_OVER_PARAMETERS
break;
}
if (strcmp(argv[i], "-qsbgetlockedorders") == 0)
{
g_cmd = QSB_GET_LOCKED_ORDERS_CMD;
g_qsb_viewOffset = 0;
g_qsb_viewLimit = 64;
if (i + 1 < argc && argv[i + 1][0] != '-')
{
g_qsb_viewOffset = (uint32_t)charToNumber(argv[i + 1]);
++i;
if (i + 1 < argc && argv[i + 1][0] != '-')
{
g_qsb_viewLimit = (uint32_t)charToNumber(argv[i + 1]);
++i;
}
}
++i;
CHECK_OVER_PARAMETERS
break;
}
if (strcmp(argv[i], "-qsbgetfilledorders") == 0)
{
g_cmd = QSB_GET_FILLED_ORDERS_CMD;
g_qsb_viewOffset = 0;
g_qsb_viewLimit = 64;
if (i + 1 < argc && argv[i + 1][0] != '-')
{
g_qsb_viewOffset = (uint32_t)charToNumber(argv[i + 1]);
++i;
if (i + 1 < argc && argv[i + 1][0] != '-')
{
g_qsb_viewLimit = (uint32_t)charToNumber(argv[i + 1]);
++i;
}
}
++i;
CHECK_OVER_PARAMETERS
break;
}

/*****************************************
***** SHAREHOLDER PROPOSAL COMMANDS *****
Expand Down
7 changes: 6 additions & 1 deletion connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -417,4 +417,9 @@ template QSB_GetConfig_output QubicConnection::receivePacketWithHeaderAs<QSB_Get
template QSB_IsOracle_output QubicConnection::receivePacketWithHeaderAs<QSB_IsOracle_output>();
template QSB_IsPauser_output QubicConnection::receivePacketWithHeaderAs<QSB_IsPauser_output>();
template QSB_GetLockedOrder_output QubicConnection::receivePacketWithHeaderAs<QSB_GetLockedOrder_output>();
template QSB_IsOrderFilled_output QubicConnection::receivePacketWithHeaderAs<QSB_IsOrderFilled_output>();
template QSB_IsOrderFilled_output QubicConnection::receivePacketWithHeaderAs<QSB_IsOrderFilled_output>();
template QSB_ComputeOrderHash_output QubicConnection::receivePacketWithHeaderAs<QSB_ComputeOrderHash_output>();
template QSB_GetOracles_output QubicConnection::receivePacketWithHeaderAs<QSB_GetOracles_output>();
template QSB_GetPausers_output QubicConnection::receivePacketWithHeaderAs<QSB_GetPausers_output>();
template QSB_GetLockedOrders_output QubicConnection::receivePacketWithHeaderAs<QSB_GetLockedOrders_output>();
template QSB_GetFilledOrders_output QubicConnection::receivePacketWithHeaderAs<QSB_GetFilledOrders_output>();
12 changes: 11 additions & 1 deletion global.h
Original file line number Diff line number Diff line change
Expand Up @@ -272,4 +272,14 @@ uint32_t g_qsb_bpsFee = 0;
uint32_t g_qsb_protocolFee = 0;
char* g_qsb_viewIdentity = nullptr;
uint32_t g_qsb_viewNonce = 0;
char* g_qsb_orderHashHex = nullptr;
char* g_qsb_orderHashHex = nullptr;
uint32_t g_qsb_viewOffset = 0;
uint32_t g_qsb_viewLimit = 64;
char* g_qsb_computeOrderFromId = nullptr;
char* g_qsb_computeOrderToId = nullptr;
uint64_t g_qsb_computeOrderAmount = 0;
uint64_t g_qsb_computeOrderRelayerFee = 0;
uint32_t g_qsb_computeOrderDestChain = 0;
uint32_t g_qsb_computeOrderNetIn = 0;
uint32_t g_qsb_computeOrderNetOut = 0;
uint32_t g_qsb_computeOrderNonce = 0;
43 changes: 43 additions & 0 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1306,6 +1306,13 @@ int run(int argc, char* argv[])
g_qsb_toAddressHex, g_qsb_relayerFee, g_offsetScheduledTick);
break;
}
case QSB_CANCEL_LOCK_CMD:
{
sanityCheckNode(g_nodeIp, g_nodePort);
sanityCheckSeed(g_seed);
qsbCancelLock(g_nodeIp, g_nodePort, g_seed, g_qsb_nonce, g_offsetScheduledTick);
break;
}
case QSB_TRANSFER_ADMIN_CMD:
{
sanityCheckNode(g_nodeIp, g_nodePort);
Expand Down Expand Up @@ -1389,6 +1396,42 @@ int run(int argc, char* argv[])
qsbIsOrderFilled(g_nodeIp, g_nodePort, g_qsb_orderHashHex);
break;
}
case QSB_COMPUTE_ORDER_HASH_CMD:
{
sanityCheckNode(g_nodeIp, g_nodePort);
sanityCheckIdentity(g_qsb_computeOrderFromId);
sanityCheckIdentity(g_qsb_computeOrderToId);
qsbComputeOrderHash(g_nodeIp, g_nodePort,
g_qsb_computeOrderFromId, g_qsb_computeOrderToId,
g_qsb_computeOrderAmount, g_qsb_computeOrderRelayerFee,
g_qsb_computeOrderDestChain, g_qsb_computeOrderNetIn,
g_qsb_computeOrderNetOut, g_qsb_computeOrderNonce);
break;
}
case QSB_GET_ORACLES_CMD:
{
sanityCheckNode(g_nodeIp, g_nodePort);
qsbGetOracles(g_nodeIp, g_nodePort);
break;
}
case QSB_GET_PAUSERS_CMD:
{
sanityCheckNode(g_nodeIp, g_nodePort);
qsbGetPausers(g_nodeIp, g_nodePort);
break;
}
case QSB_GET_LOCKED_ORDERS_CMD:
{
sanityCheckNode(g_nodeIp, g_nodePort);
qsbGetLockedOrders(g_nodeIp, g_nodePort, g_qsb_viewOffset, g_qsb_viewLimit);
break;
}
case QSB_GET_FILLED_ORDERS_CMD:
{
sanityCheckNode(g_nodeIp, g_nodePort);
qsbGetFilledOrders(g_nodeIp, g_nodePort, g_qsb_viewOffset, g_qsb_viewLimit);
break;
}
case SHAREHOLDER_SET_PROPOSAL:
sanityCheckNode(g_nodeIp, g_nodePort);
sanityCheckSeed(g_seed);
Expand Down
Loading