diff --git a/docs/XDAGJ_RPC.md b/docs/XDAGJ_RPC.md index 181a706f..cfad504e 100644 --- a/docs/XDAGJ_RPC.md +++ b/docs/XDAGJ_RPC.md @@ -1,21 +1,23 @@ -| Function name | parameter | example | describe | -|-----------------------------------|----------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------| -| **xdag_getBlockByHash** | BlockHash(String, int) | Req:
curl http://127.0.0.1:10001/ -s -X POST -H "Content-Type: application/json" --data "{\"jsonrpc\":\"2.0\",\"method\":\"xdag_getBlockByHash\",\"params\":[\"55Tffne2cwGSDRJU3kouvZfRNjk19ZaE7\",\"1\"],\"id\":1}"
Resp:
{"jsonrpc":"2.0","id":1,"result":{"height":0,"balance":"6912.000000000","blockTime":1689139840000,"timeStamp":1729679196160,"state":"Accepted","hash":null,"address":"55Tffne2cwGSDRJU3kouvZfRNjk19ZaE7","remark":null,"diff":null,"type":"Wallet","flags":null,"totalPage":1,"refs":null,"transactions":[{"direction":0,"hashlow":"0000000000000000bf32a3dcbf86f0f581fa813ed00ff86a3e5358d1a1c5c61c","address":"HMbFodFYUz5q+A/QPoH6gfXwhr/cozK/","amount":"640.000000000","time":1690418353515,"remark":"old balance to new address\u0000\u0000\u0000\u0000\u0000\u0000"]}}} | Enter blockhash & page to return the block information | -| **xdag_getBlockByHash** | BlockHash(String, int, String, String) | Req:
curl http://127.0.0.1:10001/ -s -X POST -H "Content-Type: application/json" --data "{\"jsonrpc\":\"2.0\",\"method\":\"xdag_getBlockByHash\",\"params\":[\"Y988dNXpwuwNl3OeL1e3dEJ/d9ths8ho\",\"1\",\"2023-7-27 12:30:10\",\"2023-7-27 13:05:20\"],\"id\":1}"
Resp:
{"jsonrpc":"2.0","id":1,"result":{"height":2653389,"balance":"64.000000000","blockTime":1690433215999,"timeStamp":1731003613183,"state":"Main","hash":"aa66fae386b3cf9868c8b361db777f4274b7572f9e73970decc2e9d5743cdf63","address":"Y988dNXpwuwNl3OeL1e3dEJ/d9ths8ho","remark":"XdagJ_Test02","diff":"0xcdf6e05670013e7d15c4b9324f3","type":"Main","flags":"3f","totalPage":1,"refs":[{"direction":2,"address":"Y988dNXpwuwNl3OeL1e3dEJ/d9ths8ho","hashlow":"000000000000000068c8b361db777f4274b7572f9e73970decc2e9d5743cdf63","amount":"0.000000000"},{"direction":1,"address":"pagdyv2jCPcPqxwBnV5BibEDFnIlTkZ6","hashlow":"00000000000000007a464e25721603b189415e9d011cab0ff708a3fdca1da8a5","amount":"0.000000000"}],"transactions":[{"direction":2,"hashlow":"000000000000000068c8b361db777f4274b7572f9e73970decc2e9d5743cdf63","address":"Y988dNXpwuwNl3OeL1e3dEJ/d9ths8ho","amount":"64.000000000","time":1690433215999,"remark":"XdagJ_Test02"]}}} | Enter blockhash & page & start time & end time to return the block information | -| **xdag_getBlockByHash** | BlockHash(String, int, String, String) | Req:
curl http://127.0.0.1:10001/ -s -X POST -H "Content-Type: application/json" --data "{\"jsonrpc\":\"2.0\",\"method\":\"xdag_getBlockByHash\",\"params\":[\"55Tffne2cwGSDRJU3kouvZfRNjk19ZaE7\",\"1\",\"1690418353515\",\"1690433215999\"],\"id\":1}"
Resp:
{"jsonrpc":"2.0","id":1,"result":{"height":0,"balance":"6912.000000000","blockTime":1689139840000,"timeStamp":1729679196160,"state":"Accepted","hash":null,"address":"55Tffne2cwGSDRJU3kouvZfRNjk19ZaE7","remark":null,"diff":null,"type":"Wallet","flags":null,"totalPage":1,"refs":null,"transactions":[{"direction":0,"hashlow":"0000000000000000bf32a3dcbf86f0f581fa813ed00ff86a3e5358d1a1c5c61c","address":"HMbFodFYUz5q+A/QPoH6gfXwhr/cozK/","amount":"640.000000000","time":1690418353515,"remark":"old balance to new address\u0000\u0000\u0000\u0000\u0000\u0000"]}}} | Enter blockhash & page & start timestamp & end timestamp to return the block information | -| **xdag_getBlockByNumber** | BlockHeight (String) | Req:
curl http://127.0.0.1:10001/ -s -X POST -H "Content-Type: application/json" --data "{\"jsonrpc\":\"2.0\",\"method\":\"xdag_blockNumber\",\"params\":[],\"id\":1}"
Resp:
{"jsonrpc":"2.0","id":1,"result":{"height":6,"balance":"0.000000000","blockTime":1652541375999,"timeStamp":1692202369023,"state":"Main","hash":"b6d9ae965c74b53ae521e9149fade12d82366ed3b6aed65282100c6e8e59c5d9","address":"2cVZjm4MEIJS1q620242gi3hrZ8U6SHl","remark":"XdagJ","diff":"0x23e5005c0a","type":"Main","flags":"3f","refs":[{"direction":2,"address":"2cVZjm4MEIJS1q620242gi3hrZ8U6SHl","hashlow":"0000000000000000e521e9149fade12d82366ed3b6aed65282100c6e8e59c5d9","amount":"0.000000000"},{"direction":1,"address":"K/SSa8tdBR68IPdf7ArdWVNbJonW+kkR","hashlow":"00000000000000001149fad689265b5359dd0aec5ff720bc1e055dcb6b92f42b","amount":"0.000000000"},{"direction":1,"address":"3asjCLlpKDXzRzHjrS5FjlHJtNkpziLt","hashlow":"0000000000000000ed22ce29d9b4c9518e452eade33147f3352869b90823abdd","amount":"0.000000000"}],"transactions":[{"direction":2,"hashlow":"0000000000000000e521e9149fade12d82366ed3b6aed65282100c6e8e59c5d9","address":"2cVZjm4MEIJS1q620242gi3hrZ8U6SHl","amount":"1024.000000000","time":1652541375999,"remark":"XdagJ"},{"direction":1,"hashlow":"0000000000000000da8fe5e906dd98d34b64fb26139d1b8845acd9b461b2a8e5","address":"5aiyYbTZrEWIG50TJvtkS9OY3Qbp5Y/a","amount":"1024.000000000","time":1652544234518,"remark":""}]}} | Enter block height to return block information | -| **xdag_blockNumber** | Null | Req:
curl http://127.0.0.1:10001/ -s -X POST -H "Content-Type: application/json" --data "{\"jsonrpc\":\"2.0\",\"method\":\"xdag_blockNumber\",\"params\":[],\"id\":1}"
Resp:
{"jsonrpc":"2.0","id":1,"result":"5"} | Used to return the current main block height | -| **xdag_coinbase** | Null | Req:
curl http://127.0.0.1:10001/ -s -X POST -H "Content-Type: application/json" --data "{\"jsonrpc\":\"2.0\",\"method\":\"xdag_coinbase\",\"params\":[],\"id\":1}"
Resp:
{"jsonrpc":"2.0","id":1,"result":"K5q0ews/ma110QLUzePetOdU+EwYKrud"} | Used to return the current pool miner | -| **xdag_getBalance** | Address (String) | Req:
curl http://127.0.0.1:10001/ -s -X POST -H "Content-Type: application/json" --data "{\"jsonrpc\":\"2.0\",\"method\":\"xdag_getBalance\",\"params\":[\"K5q0ews/ma110QLUzePetOdU+EwYKrud\"],\"id\":1}"
Resp:
{"jsonrpc":"2.0","id":1,"result":"1024.000000000"} | Enter an address to return the balance of the address | -| **xdag_getTotalBalance** | Null | Req:
curl http://127.0.0.1:10001/ -s -X POST -H "Content-Type: application/json" --data "{\"jsonrpc\":\"2.0\",\"method\":\"xdag_getTotalBalance\",\"params\":[],\"id\":1}"
Resp:
{"jsonrpc":"2.0","id":1,"result":"5120.000000000"} | Used to return the current balance of this pool | -| **xdag_getStatus** | Null | Req:
curl http://127.0.0.1:10001/ -s -X POST -H "Content-Type: application/json" --data "{\"jsonrpc\":\"2.0\",\"method\":\"xdag_getStatus\",\"params\":[],\"id\":1}"
Resp:
{"jsonrpc":"2.0","id":1,"result":{"nblock":"410","totalNblocks":"410","nmain":"355","totalNmain":"355","curDiff":"0x8cdcc571bb0","netDiff":"0x8cdcc571bb0","hashRateOurs":"4.6310760077049364E-15","hashRateTotal":"4.6310760077049364E-15","ourSupply":"363520.000000000","netSupply":"363520.000000000"}} | Used to return the status of the XDAG network | -| **xdag_personal_sendTransaction** | From(String);
"from can be null, because it is pool default".
To(String);
Value(String); Remark(String); | Req:
curl http://127.0.0.1:10001/ -s -X POST -H "Content-Type: application/json" --data "{\"jsonrpc\":\"2.0\",\"method\":\"xdag_personal_sendTransaction\",\"params\":[{\"to\":\"K5q0ews/ma110QLUzePetOdU+EwYKrud\",\"value\": \"100\",\"remark\":\"test\"},\"password\"],\"id\":1}" #replace password
Resp:
{"jsonrpc":"2.0","id":1,"result":["vdRhmOwyMnZGWa175jIeGM8wRKxFD4R8","5OzeDiBqW3B6mtTeETgtR3WaVMKtB4+1","XUpG7kNvo+Ry0NYdPXSZCosaKdA2DfyR","byoUkvt9Y3jOLHjNpoiAJiwNT5ERSo+D","/7Fbib4Q/hONloUxX0lFNr28zEGdzOFp","9ECM/iCC9llyMfESZqDujftpkACcvR3R","eYi9z1vmNHNQqsXyXnzeq/gUlS7//WhQ","srN4XT6jPIrBWZ+OZZRydE/0bqZavjQZ","iXekUXBKRhuPWou7ChFZAmyrHEOfFVuI","LHhaVsyA8BSdumNlxTJ4o5j+I1IyeXj2"]} | Used to transfer from pool to other address | -| **xdag_getRewardByNumber** | Height | Req:
curl http://127.0.0.1:10001/ -s -X POST -H "Content-Type: application/json" --data "{\"jsonrpc\":\"2.0\",\"method\":\"xdag_getRewardByNumber\",\"params\":[\"1000\"],\"id\":1}"
Resp:
{"jsonrpc":"2.0","id":1,"result":"1024.000000000"} | Used to return the reward of some height | -| **xdag_sendRawTransaction** | BlockData(String)
"raw data of the block" | Req:
curl http://127.0.0.1:10001/ -s -X POST -H "Content-Type: application/json" --data "
{\"jsonrpc\":\"2.0\",\"method\":\"xdag_sendRawTransaction\",\"params\":
[\"00000000000000002863550000000000feffed9d7d01000000000000000000005d453264dfe0f2dcd0b09fff8db233af668bf7aa873176470000000064000000defb03f1a99ce1498f19afa5b0c752d5409bb2fdc4e087e10000000064000000506bc1dc099358e5137292f4efdd57e400f29ba5132aa5d12b18dac1c1f6aaba12dfa82f55245fb4a8a8ddbbe2eb970f80347741ff0907e8844630004981eb230a329c87c
2736c8067e7a15190587502e5bf761e4f919aaf84ce62b3f1f5cffc0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000(TxBlockRawDate)\"],\"id\":1}"
Resp:
{"jsonrpc":"2.0","id":1,"result":"MWdnWaYpLMwlazfFwmk4onmNE82JVFTB(BlockHash)"} | Used to send transactions | -| **xdag_netType** | Null | Req:
curl http://127.0.0.1:10001/ -s -X POST -H "Content-Type: application/json" --data "{\"jsonrpc\":\"2.0\",\"method\":\"xdag_netType\",\"params\":[],\"id\":1}"
Resp:
{"jsonrpc":"2.0","id":1,"result":"testnet"} | Used to return the net type xdag running for | -| **xdag_netConnectionList** | Null | Req:
curl http://127.0.0.1:10001/ -s -X POST -H "Content-Type: application/json" --data "{\"jsonrpc\":\"2.0\",\"method\":\"xdag_netConnectionList\",\"params\":[],\"id\":1}"
Resp:
{"jsonrpc":"2.0","id":1,"result":[{"nodeAddress":"localhost:8002","connectTime":1654431183389,"inBound":1744,"outBound":1101},{"nodeAddress":"localhost:61179","connectTime":1654431099718,"inBound":7949,"outBound":5623}]}Used to return the net conn list | Used to return the net connect list | -| **xdag_poolConfig** | Null | Req:
curl http://127.0.0.1:10001/ -s -X POST -H "Content-Type: application/json" --data "{\"jsonrpc\":\"2.0\",\"method\":\"xdag_poolConfig\",\"params\":[],\"id\":1}"
Resp:
{"jsonrpc":"2.0","id":1,"result":{"poolIp":"127.0.0.1","poolPort":7001,"nodeIp":"127.0.0.1","nodePort":8001,"globalMinerLimit":8192,"maxConnectMinerPerIp":256,"maxMinerPerAccount":256,"poolFeeRation":"5.0","poolRewardRation":"5.0","poolDirectRation":"5.0","poolFundRation":"5.0"}} | Used to get pool config | -| **xdag_updatePoolConfig** | poolRewardRation(String) poolDirectRation(String) poolFundRation(String) poolFeeRation(String) | Req:
curl http://127.0.0.1:10001/ -s -X POST -H "Content-Type: application/json" --data "{\"jsonrpc\":\"2.0\",\"method\":\"xdag_updatePoolConfig\",\"params\":[{\"poolFeeRation\":\"12\",\"poolRewardRation\":\"11\",\"poolDirectRation\":\"13\",\"poolFundRation\":\"14.2\"},\"password\"],\"id\":1}"
Resp:
{"jsonrpc":"2.0","id":1,"result":"Success"} | Used to update award configuration | +| Function name | parameter | example | describe | +|-----------------------------------|-------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------| +| **xdag_getBlockByHash** | BlockHash(String), Page(String) | Req:
curl http://127.0.0.1:10001/ -s -X POST -H "Content-Type: application/json" --data "{\"jsonrpc\":\"2.0\",\"method\":\"xdag_getBlockByHash\",\"params\":[\"55Tffne2cwGSDRJU3kouvZfRNjk19ZaE7\",\"1\"],\"id\":1}"
Resp:
{"jsonrpc":"2.0","id":1,"result":{"height":0,"balance":"6912.000000000","blockTime":1689139840000,"timeStamp":1729679196160,"state":"Accepted","hash":null,"address":"55Tffne2cwGSDRJU3kouvZfRNjk19ZaE7","remark":null,"diff":null,"type":"Wallet","flags":null,"totalPage":1,"refs":null,"transactions":[{"direction":0,"hashlow":"0000000000000000bf32a3dcbf86f0f581fa813ed00ff86a3e5358d1a1c5c61c","address":"HMbFodFYUz5q+A/QPoH6gfXwhr/cozK/","amount":"640.000000000","time":1690418353515,"remark":"old balance to new address\u0000\u0000\u0000\u0000\u0000\u0000"]}}} | Enter blockhash & page to return the block information | +| **xdag_getBlockByHash** | BlockHash(String), Page(String), startTime(String), endTime(String) | Req:
curl http://127.0.0.1:10001/ -s -X POST -H "Content-Type: application/json" --data "{\"jsonrpc\":\"2.0\",\"method\":\"xdag_getBlockByHash\",\"params\":[\"Y988dNXpwuwNl3OeL1e3dEJ/d9ths8ho\",\"1\",\"2023-7-27 12:30:10\",\"2023-7-27 13:05:20\"],\"id\":1}"
Resp:
{"jsonrpc":"2.0","id":1,"result":{"height":2653389,"balance":"64.000000000","blockTime":1690433215999,"timeStamp":1731003613183,"state":"Main","hash":"aa66fae386b3cf9868c8b361db777f4274b7572f9e73970decc2e9d5743cdf63","address":"Y988dNXpwuwNl3OeL1e3dEJ/d9ths8ho","remark":"XdagJ_Test02","diff":"0xcdf6e05670013e7d15c4b9324f3","type":"Main","flags":"3f","totalPage":1,"refs":[{"direction":2,"address":"Y988dNXpwuwNl3OeL1e3dEJ/d9ths8ho","hashlow":"000000000000000068c8b361db777f4274b7572f9e73970decc2e9d5743cdf63","amount":"0.000000000"},{"direction":1,"address":"pagdyv2jCPcPqxwBnV5BibEDFnIlTkZ6","hashlow":"00000000000000007a464e25721603b189415e9d011cab0ff708a3fdca1da8a5","amount":"0.000000000"}],"transactions":[{"direction":2,"hashlow":"000000000000000068c8b361db777f4274b7572f9e73970decc2e9d5743cdf63","address":"Y988dNXpwuwNl3OeL1e3dEJ/d9ths8ho","amount":"64.000000000","time":1690433215999,"remark":"XdagJ_Test02"]}}} | Enter blockhash & page & start time & end time to return the block information | +| **xdag_getBlockByHash** | BlockHash(String), Page(String), startTime(String), endTime(String) | Req:
curl http://127.0.0.1:10001/ -s -X POST -H "Content-Type: application/json" --data "{\"jsonrpc\":\"2.0\",\"method\":\"xdag_getBlockByHash\",\"params\":[\"55Tffne2cwGSDRJU3kouvZfRNjk19ZaE7\",\"1\",\"1690418353515\",\"1690433215999\"],\"id\":1}"
Resp:
{"jsonrpc":"2.0","id":1,"result":{"height":0,"balance":"6912.000000000","blockTime":1689139840000,"timeStamp":1729679196160,"state":"Accepted","hash":null,"address":"55Tffne2cwGSDRJU3kouvZfRNjk19ZaE7","remark":null,"diff":null,"type":"Wallet","flags":null,"totalPage":1,refs":null,"transactions":[{"direction":0,"hashlow":"0000000000000000bf32a3dcbf86f0f581fa813ed00ff86a3e5358d1a1c5c61c","address":"HMbFodFYUz5q+A/QPoH6gfXwhr/cozK/","amount":"640.000000000","time":1690418353515,"remark":"old balance to new address\u0000\u0000\u0000\u0000\u0000\u0000"]}}} | Enter blockhash & page & start timestamp & end timestamp to return the block information | +| **xdag_getBlockByHash** | BlockHash(String), 0
"Set Page = 0, thereby avoiding querying MySQL to retrieve tx". | Req:
curl http://127.0.0.1:10001/ -s -X POST -H "Content-Type: application/json" --data "{\"jsonrpc\":\"2.0\",\"method\":\"xdag_getBlockByHash\",\"params\":[\"4mvr3DNkpWY9ikpGy4maaMSQqUmXjR2hp\",\"0\"],\"id\":1}"
Resp:
{"jsonrpc":"2.0","id":1,"result":{"height":0,"balance":"1600.000000000","blockTime":1689139840000,"timeStamp":1729679196160,"state":"Accepted","hash":null,"address":"4mvr3DNkpWY9ikpGy4maaMSQqUmXjR2hp","remark":null,"diff":null,"type":"Wallet","flags":null,"totalPage":0,"refs":null,"transactions":null}} | Enter blockhash & set page = 0 to return the block information without querying MySQL to obtain tx | +| **xdag_getBlockByNumber** | BlockHeight(String), Page(String) | Req:
curl http://127.0.0.1:10001/ -s -X POST -H "Content-Type: application/json" --data "{\"jsonrpc\":\"2.0\",\"method\":\"xdag_blockNumber\",\"params\":[\"2652592\",\"1\"],\"id\":1}"
Resp:
{"jsonrpc":"2.0","id":1,"result":{"height":2652592,"balance":"0.000000000","blockTime":1690356415999,"timeStamp":1730924969983,"state":"Main","hash":"e5975ce26b8102350573292b19c38d0ef9dc09a374b9e86a2aedb011fa7c0d8e","address":"jg18+hGw7Spq6Ll0ownc+Q6NwxkrKXMF","remark":"XdagJ","diff":"0xcdf6e05670013e7517c3e4582f8","type":"Main","flags":"3f","totalpage":1,"refs":[{"direction":2,"address":"jg18+hGw7Spq6Ll0ownc+Q6NwxkrKXMF","hashlow":"00000000000000000573292b19c38d0ef9dc09a374b9e86a2aedb011fa7c0d8e","amount":"0.000000000"},{"direction":1,"address":"/JoxRqqgh7T/z2n7TjptTQ84n+QYfrqS","hashlow":"000000000000000092ba7e18e49f380f4d6d3a4efb69cfffb487a0aa46319afc","amount":"0.000000000"},{"direction":1,"address":"7LE5lCuvIAyREE3jF1VWTa85apucqS7Z","hashlow":"0000000000000000d92ea99c9b6a39af4d565517e34d10910c20af2b9439b1ec","amount":"0.000000000"}],"transactions":[{"direction":2,"hashlow":"00000000000000000573292b19c38d0ef9dc09a374b9e86a2aedb011fa7c0d8e","address":"jg18+hGw7Spq6Ll0ownc+Q6NwxkrKXMF","amount":"64.000000000","time":1690356415999,"remark":"XdagJ"}]}} | Enter block height & page to return block information | +| **xdag_getBlockByNumber** | BlockHeight(String), 0
"Set Page = 0, thereby avoiding querying MySQL to retrieve tx". | Req:
curl http://127.0.0.1:10001/ -s -X POST -H "Content-Type: application/json" --data "{\"jsonrpc\":\"2.0\",\"method\":\"xdag_blockNumber\",\"params\":[\"2652628\",\"0\"],\"id\":1}"
Resp: {"jsonrpc":"2.0","id":1,"result":{"height":2652628,"balance":"64.000000000","blockTime":1690781887999,"timeStamp":1731360653311,"state":"Main","hash":"efb5d86f28f16dc1ff51e4468edcaa508e97fe3a704b6db7a40c393b84d59683","address":"g5bVhDs5DKS3bUtwOv6XjlCq3I5G5FH/","remark":"XdagJ","diff":"0xcdf6e05670013e752373b6389d4","type":"Main","flags":"3f","totalPage":0,"refs":[{"direction":2,"address":"g5bVhDs5DKS3bUtwOv6XjlCq3I5G5FH/","hashlow":"0000000000000000ff51e4468edcaa508e97fe3a704b6db7a40c393b84d59683","amount":"0.000000000"},{"direction":1,"address":"uA+JMeO1R+XMraLPywQDbS+J44FqqOqt","hashlow":"0000000000000000adeaa86a81e3892f6d0304cbcfa2adcce547b5e331890fb8","amount":"0.000000000"},{"direction":1,"address":"Zt3jpA2OXs38d3scK5BxPVfT6+pUSFf/","hashlow":"0000000000000000ff574854eaebd3573d71902b1c7b77fccd5e8e0da4e3dd66","amount":"0.000000000"}],"transactions":null}} | Enter block height & set page = 0 to return block information without querying MySQL to obtain tx | +| **xdag_blockNumber** | Null | Req:
curl http://127.0.0.1:10001/ -s -X POST -H "Content-Type: application/json" --data "{\"jsonrpc\":\"2.0\",\"method\":\"xdag_blockNumber\",\"params\":[],\"id\":1}"
Resp:
{"jsonrpc":"2.0","id":1,"result":"5"} | Used to return the current main block height | +| **xdag_coinbase** | Null | Req:
curl http://127.0.0.1:10001/ -s -X POST -H "Content-Type: application/json" --data "{\"jsonrpc\":\"2.0\",\"method\":\"xdag_coinbase\",\"params\":[],\"id\":1}"
Resp:
{"jsonrpc":"2.0","id":1,"result":"K5q0ews/ma110QLUzePetOdU+EwYKrud"} | Used to return the current pool miner | +| **xdag_getBalance** | Address(String) | Req:
curl http://127.0.0.1:10001/ -s -X POST -H "Content-Type: application/json" --data "{\"jsonrpc\":\"2.0\",\"method\":\"xdag_getBalance\",\"params\":[\"K5q0ews/ma110QLUzePetOdU+EwYKrud\"],\"id\":1}"
Resp:
{"jsonrpc":"2.0","id":1,"result":"1024.000000000"} | Enter an address to return the balance of the address | +| **xdag_getTotalBalance** | Null | Req:
curl http://127.0.0.1:10001/ -s -X POST -H "Content-Type: application/json" --data "{\"jsonrpc\":\"2.0\",\"method\":\"xdag_getTotalBalance\",\"params\":[],\"id\":1}"
Resp:
{"jsonrpc":"2.0","id":1,"result":"5120.000000000"} | Used to return the current balance of this pool | +| **xdag_getStatus** | Null | Req:
curl http://127.0.0.1:10001/ -s -X POST -H "Content-Type: application/json" --data "{\"jsonrpc\":\"2.0\",\"method\":\"xdag_getStatus\",\"params\":[],\"id\":1}"
Resp:
{"jsonrpc":"2.0","id":1,"result":{"nblock":"410","totalNblocks":"410","nmain":"355","totalNmain":"355","curDiff":"0x8cdcc571bb0","netDiff":"0x8cdcc571bb0","hashRateOurs":"4.6310760077049364E-15","hashRateTotal":"4.6310760077049364E-15","ourSupply":"363520.000000000","netSupply":"363520.000000000"}} | Used to return the status of the XDAG network | +| **xdag_personal_sendTransaction** | From(String);
"from can be null, because it is pool default".
To(String);
Value(String); Remark(String); | Req:
curl http://127.0.0.1:10001/ -s -X POST -H "Content-Type: application/json" --data "{\"jsonrpc\":\"2.0\",\"method\":\"xdag_personal_sendTransaction\",\"params\":[{\"to\":\"K5q0ews/ma110QLUzePetOdU+EwYKrud\",\"value\": \"100\",\"remark\":\"test\"},\"password\"],\"id\":1}" #replace password
Resp:
{"jsonrpc":"2.0","id":1,"result":["vdRhmOwyMnZGWa175jIeGM8wRKxFD4R8","5OzeDiBqW3B6mtTeETgtR3WaVMKtB4+1","XUpG7kNvo+Ry0NYdPXSZCosaKdA2DfyR","byoUkvt9Y3jOLHjNpoiAJiwNT5ERSo+D","/7Fbib4Q/hONloUxX0lFNr28zEGdzOFp","9ECM/iCC9llyMfESZqDujftpkACcvR3R","eYi9z1vmNHNQqsXyXnzeq/gUlS7//WhQ","srN4XT6jPIrBWZ+OZZRydE/0bqZavjQZ","iXekUXBKRhuPWou7ChFZAmyrHEOfFVuI","LHhaVsyA8BSdumNlxTJ4o5j+I1IyeXj2"]} | Used to transfer from pool to other address | +| **xdag_getRewardByNumber** | Height | Req:
curl http://127.0.0.1:10001/ -s -X POST -H "Content-Type: application/json" --data "{\"jsonrpc\":\"2.0\",\"method\":\"xdag_getRewardByNumber\",\"params\":[\"1000\"],\"id\":1}"
Resp:
{"jsonrpc":"2.0","id":1,"result":"1024.000000000"} | Used to return the reward of some height | +| **xdag_sendRawTransaction** | BlockData(String)
"raw data of the block" | Req:
curl http://127.0.0.1:10001/ -s -X POST -H "Content-Type: application/json" --data "
{\"jsonrpc\":\"2.0\",\"method\":\"xdag_sendRawTransaction\",\"params\":
[\"00000000000000002863550000000000feffed9d7d01000000000000000000005d453264dfe0f2dcd0b09fff8db233af668bf7aa873176470000000064000000defb03f1a99ce1498f19afa5b0c752d5409bb2fdc4e087e10000000064000000506bc1dc099358e5137292f4efdd57e400f29ba5132aa5d12b18dac1c1f6aaba12dfa82f55245fb4a8a8ddbbe2eb970f80347741ff0907e8844630004981eb230a329c87c
2736c8067e7a15190587502e5bf761e4f919aaf84ce62b3f1f5cffc0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000(TxBlockRawDate)\"],\"id\":1}"
Resp:
{"jsonrpc":"2.0","id":1,"result":"MWdnWaYpLMwlazfFwmk4onmNE82JVFTB(BlockHash)"} | Used to send transactions | +| **xdag_netType** | Null | Req:
curl http://127.0.0.1:10001/ -s -X POST -H "Content-Type: application/json" --data "{\"jsonrpc\":\"2.0\",\"method\":\"xdag_netType\",\"params\":[],\"id\":1}"
Resp:
{"jsonrpc":"2.0","id":1,"result":"testnet"} | Used to return the net type xdag running for | +| **xdag_netConnectionList** | Null | Req:
curl http://127.0.0.1:10001/ -s -X POST -H "Content-Type: application/json" --data "{\"jsonrpc\":\"2.0\",\"method\":\"xdag_netConnectionList\",\"params\":[],\"id\":1}"
Resp:
{"jsonrpc":"2.0","id":1,"result":[{"nodeAddress":"localhost:8002","connectTime":1654431183389,"inBound":1744,"outBound":1101},{"nodeAddress":"localhost:61179","connectTime":1654431099718,"inBound":7949,"outBound":5623}]}Used to return the net conn list | Used to return the net connect list | +| **xdag_poolConfig** | Null | Req:
curl http://127.0.0.1:10001/ -s -X POST -H "Content-Type: application/json" --data "{\"jsonrpc\":\"2.0\",\"method\":\"xdag_poolConfig\",\"params\":[],\"id\":1}"
Resp:
{"jsonrpc":"2.0","id":1,"result":{"poolIp":"127.0.0.1","poolPort":7001,"nodeIp":"127.0.0.1","nodePort":8001,"globalMinerLimit":8192,"maxConnectMinerPerIp":256,"maxMinerPerAccount":256,"poolFeeRation":"5.0","poolRewardRation":"5.0","poolDirectRation":"5.0","poolFundRation":"5.0"}} | Used to get pool config | +| **xdag_updatePoolConfig** | poolRewardRation(String) poolDirectRation(String) poolFundRation(String) poolFeeRation(String) | Req:
curl http://127.0.0.1:10001/ -s -X POST -H "Content-Type: application/json" --data "{\"jsonrpc\":\"2.0\",\"method\":\"xdag_updatePoolConfig\",\"params\":[{\"poolFeeRation\":\"12\",\"poolRewardRation\":\"11\",\"poolDirectRation\":\"13\",\"poolFundRation\":\"14.2\"},\"password\"],\"id\":1}"
Resp:
{"jsonrpc":"2.0","id":1,"result":"Success"} | Used to update award configuration | diff --git a/script/mysql_create_table.sql b/script/mysql_create_table.sql index e978cc15..9d68ffa0 100644 --- a/script/mysql_create_table.sql +++ b/script/mysql_create_table.sql @@ -5,7 +5,7 @@ CREATE TABLE `t_transaction_history` ( `famount` decimal(20,9) unsigned zerofill NOT NULL, `ftype` tinyint NOT NULL, `fremark` varchar(64) DEFAULT NULL, - `ftime` datetime NOT NULL, + `ftime` datetime(3) NOT NULL, PRIMARY KEY (`fid`), UNIQUE KEY `id_UNIQUE` (`fid`), KEY `faddress_index` (`faddress`) diff --git a/src/main/java/io/xdag/cli/Commands.java b/src/main/java/io/xdag/cli/Commands.java index 5c07b5eb..b18b807d 100644 --- a/src/main/java/io/xdag/cli/Commands.java +++ b/src/main/java/io/xdag/cli/Commands.java @@ -525,18 +525,18 @@ public String printBlockInfo(Block block, boolean raw) { tx.append(String.format(" input: %s %s %s%n", hash2Address(address.getAddress()), address.getAmount().toDecimal(9, XUnit.XDAG).toPlainString(), FastDateFormat.getInstance("yyyy-MM-dd HH:mm:ss.SSS") - .format(XdagTime.xdagTimestampToMs(txHistory.getTimestamp())))); + .format(txHistory.getTimestamp()))); } else if (address.getType().equals(XDAG_FIELD_OUT)) { tx.append(String.format(" output: %s %s %s%n", hash2Address(address.getAddress()), address.getAmount().toDecimal(9, XUnit.XDAG).toPlainString(), FastDateFormat.getInstance("yyyy-MM-dd HH:mm:ss.SSS") - .format(XdagTime.xdagTimestampToMs(txHistory.getTimestamp())))); + .format(txHistory.getTimestamp()))); } else { tx.append(String.format(" snapshot: %s %s %s%n", hash2Address(address.getAddress()), address.getAmount().toDecimal(9, XUnit.XDAG).toPlainString(), FastDateFormat.getInstance("yyyy-MM-dd HH:mm:ss.SSS") - .format(XdagTime.xdagTimestampToMs(txHistory.getTimestamp())))); + .format(txHistory.getTimestamp()))); } } @@ -725,28 +725,28 @@ public String address(Bytes32 wrap, int page) { tx.append(String.format(" input: %s %s %s%n", hash2Address(address.getAddress()), address.getAmount().toDecimal(9, XUnit.XDAG).toPlainString(), FastDateFormat.getInstance("yyyy-MM-dd HH:mm:ss.SSS") - .format(XdagTime.xdagTimestampToMs(txHistory.getTimestamp())))); + .format(txHistory.getTimestamp()))); } else if (address.getType().equals(XDAG_FIELD_OUTPUT)) { tx.append(String.format(" output: %s %s %s%n", hash2Address(address.getAddress()), address.getAmount().toDecimal(9, XUnit.XDAG).toPlainString(), FastDateFormat.getInstance("yyyy-MM-dd HH:mm:ss.SSS") - .format(XdagTime.xdagTimestampToMs(txHistory.getTimestamp())))); + .format(txHistory.getTimestamp()))); } else if (address.getType().equals(XDAG_FIELD_COINBASE) && (blockInfo.flags&BI_MAIN) != 0) { tx.append(String.format(" coinbase: %s %s %s%n", hash2Address(address.getAddress()), address.getAmount().toDecimal(9, XUnit.XDAG).toPlainString(), FastDateFormat.getInstance("yyyy-MM-dd HH:mm:ss.SSS") - .format(XdagTime.xdagTimestampToMs(txHistory.getTimestamp())))); + .format(txHistory.getTimestamp()))); } else { tx.append(String.format(" snapshot: %s %s %s%n", hash2Address(address.getAddress()), address.getAmount().toDecimal(9, XUnit.XDAG).toPlainString(), FastDateFormat.getInstance("yyyy-MM-dd HH:mm:ss.SSS") - .format(XdagTime.xdagTimestampToMs(txHistory.getTimestamp())))); + .format(txHistory.getTimestamp()))); } }else { tx.append(String.format(" snapshot: %s %s %s%n", (toBase58(BytesUtils.byte32ToArray(address.getAddress()))), address.getAmount().toDecimal(9, XUnit.XDAG).toPlainString(), FastDateFormat.getInstance("yyyy-MM-dd HH:mm:ss.SSS") - .format(XdagTime.xdagTimestampToMs(txHistory.getTimestamp())))); + .format(txHistory.getTimestamp()))); } } diff --git a/src/main/java/io/xdag/config/AbstractConfig.java b/src/main/java/io/xdag/config/AbstractConfig.java index e4ac39d6..d9bc8651 100644 --- a/src/main/java/io/xdag/config/AbstractConfig.java +++ b/src/main/java/io/xdag/config/AbstractConfig.java @@ -81,7 +81,7 @@ public class AbstractConfig implements Config, AdminSpec, PoolSpec, NodeSpec, Wa protected int maxShareCountPerChannel = 20; protected int awardEpoch = 0xf; - protected int waitEpoch = 10; + protected int waitEpoch = 20; // ========================= // Node spec diff --git a/src/main/java/io/xdag/db/mysql/TransactionHistoryStoreImpl.java b/src/main/java/io/xdag/db/mysql/TransactionHistoryStoreImpl.java index eb74c6f7..d7fa8339 100644 --- a/src/main/java/io/xdag/db/mysql/TransactionHistoryStoreImpl.java +++ b/src/main/java/io/xdag/db/mysql/TransactionHistoryStoreImpl.java @@ -80,7 +80,7 @@ public boolean saveTxHistory(TxHistory txHistory) { pstmt.setBigDecimal(3, txHistory.getAddress().getAmount().toDecimal(9, XUnit.XDAG)); pstmt.setInt(4, txHistory.getAddress().getType().asByte()); pstmt.setString(5, txHistory.getRemark()); - pstmt.setTimestamp(6, new java.sql.Timestamp(txHistory.getTimestamp())); + pstmt.setTimestamp(6, new java.sql.Timestamp(XdagTime.xdagTimestampToMs(txHistory.getTimestamp()))); result = pstmt.executeUpdate() == 1; } } catch (Exception e) { @@ -110,7 +110,7 @@ public boolean batchSaveTxHistory(TxHistory txHistory) { pstmtBatch.setBigDecimal(3, address.getAmount().toDecimal(9, XUnit.XDAG)); pstmtBatch.setInt(4, address.getType().asByte()); pstmtBatch.setString(5, txHistory.getRemark()); - pstmtBatch.setTimestamp(6, new java.sql.Timestamp(txHistory.getTimestamp())); + pstmtBatch.setTimestamp(6, new java.sql.Timestamp(XdagTime.xdagTimestampToMs(txHistory.getTimestamp()))); pstmtBatch.addBatch(); count++; } @@ -146,16 +146,16 @@ public List listTxHistoryByAddress(String address, int page, Object.. ResultSet rs = null; List txHistoryList = Lists.newArrayList(); int totalcount = 0; - long start = XdagTime.msToXdagtimestamp(new Date(0).getTime()); - long end = XdagTime.msToXdagtimestamp(System.currentTimeMillis()); + long start = new Date(0).getTime(); + long end = System.currentTimeMillis(); if (timeRange.length != 0){ try{ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - start =XdagTime.msToXdagtimestamp(sdf.parse(timeRange[0].toString()).getTime()); - end = XdagTime.msToXdagtimestamp(sdf.parse(timeRange[1].toString()).getTime()); + start =sdf.parse(timeRange[0].toString()).getTime(); + end = sdf.parse(timeRange[1].toString()).getTime(); }catch (ParseException e){ - start = XdagTime.msToXdagtimestamp(Long.parseLong(timeRange[0].toString())); - end = XdagTime.msToXdagtimestamp(Long.parseLong(timeRange[1].toString())); + start = Long.parseLong(timeRange[0].toString()); + end = Long.parseLong(timeRange[1].toString()); } } try { diff --git a/src/main/java/io/xdag/rpc/modules/xdag/XdagModuleChainBase.java b/src/main/java/io/xdag/rpc/modules/xdag/XdagModuleChainBase.java index bed4df3a..5842853a 100644 --- a/src/main/java/io/xdag/rpc/modules/xdag/XdagModuleChainBase.java +++ b/src/main/java/io/xdag/rpc/modules/xdag/XdagModuleChainBase.java @@ -196,7 +196,7 @@ private BlockResultDTO transferBlockInfoToBlockResultDTO(Block block, int page, .balance(String.format("%s", block.getInfo().getAmount().toDecimal(9, XUnit.XDAG).toPlainString())) .type(SNAPSHOT.getDesc()) .blockTime(xdagTimestampToMs(kernel.getConfig().getSnapshotSpec().getSnapshotTime())) - .timeStamp(kernel.getConfig().getSnapshotSpec().getSnapshotTime()) + .timeStamp(kernel.getConfig().getSnapshotSpec().getSnapshotTime()); // .flags(Integer.toHexString(block.getInfo().getFlags())) // .diff(toQuantityJsonHex(block.getInfo().getDifficulty())) // .remark(block.getInfo().getRemark() == null ? "" : new String(block.getInfo().getRemark(), @@ -205,8 +205,10 @@ private BlockResultDTO transferBlockInfoToBlockResultDTO(Block block, int page, // .type(getType(block)) // .refs(getLinks(block)) // .height(block.getInfo().getHeight()) - .transactions(getTxLinks(block, page, timeRange)) + if (page != 0){ + BlockResultDTOBuilder.transactions(getTxLinks(block, page, timeRange)) .totalPage(totalPage); + } totalPage = 1; return BlockResultDTOBuilder.build(); } @@ -221,9 +223,11 @@ private BlockResultDTO transferAccountToBlockResultDTO(String address, int page, .type("Wallet") .blockTime(xdagTimestampToMs(kernel.getConfig().getSnapshotSpec().getSnapshotTime())) .timeStamp(kernel.getConfig().getSnapshotSpec().getSnapshotTime()) - .state("Accepted") - .transactions(getTxHistory(address, page, timeRange)) + .state("Accepted"); + if (page != 0){ + BlockResultDTOBuilder.transactions(getTxHistory(address, page, timeRange)) .totalPage(totalPage); + } totalPage = 1; return BlockResultDTOBuilder.build(); } @@ -245,9 +249,11 @@ private BlockResultDTO transferBlockToBlockResultDTO(Block block, int page, Obje .state(getStateByFlags(block.getInfo().getFlags())) .type(getType(block)) .refs(getLinks(block)) - .height(block.getInfo().getHeight()) - .transactions(getTxLinks(block, page, timeRange)) - .totalPage(totalPage); + .height(block.getInfo().getHeight()); + if (page != 0) { + BlockResultDTOBuilder.transactions(getTxLinks(block, page, timeRange)) + .totalPage(totalPage); + } totalPage = 1; return BlockResultDTOBuilder.build(); } @@ -320,7 +326,7 @@ private List getTxLinks(Block block, int page, Object timeRange) { .amount(String.format("%s", txHistory.getAddress().getAmount().toDecimal(9, XUnit.XDAG).toPlainString())) .direction(txHistory.getAddress().getType().equals(XDAG_FIELD_IN) ? 0 : txHistory.getAddress().getType().equals(XDAG_FIELD_OUT) ? 1 : 3) - .time(xdagTimestampToMs(txHistory.getTimestamp())) + .time(txHistory.getTimestamp()) .remark(txHistory.getRemark()); txLinks.add(txLinkBuilder.build()); } @@ -344,7 +350,7 @@ private List getTxHistory(String address, int page, Object... timeRange) .direction(txHistory.getAddress().getType().equals(XDAG_FIELD_INPUT) ? 0 : txHistory.getAddress().getType().equals(XDAG_FIELD_OUTPUT) ? 1 : txHistory.getAddress().getType().equals(XDAG_FIELD_COINBASE) ? 2 : 3) - .time(xdagTimestampToMs(txHistory.getTimestamp())) + .time(txHistory.getTimestamp()) .remark(txHistory.getRemark()); } else { txLinkBuilder.address(toBase58(BytesUtils.byte32ToArray(txHistory.getAddress().getAddress()))) diff --git a/src/test/java/io/xdag/db/mysql/TransactionHistoryStoreImplTest.java b/src/test/java/io/xdag/db/mysql/TransactionHistoryStoreImplTest.java index df730843..b56959ae 100644 --- a/src/test/java/io/xdag/db/mysql/TransactionHistoryStoreImplTest.java +++ b/src/test/java/io/xdag/db/mysql/TransactionHistoryStoreImplTest.java @@ -35,6 +35,7 @@ import java.sql.Statement; import java.util.List; +import io.xdag.utils.XdagTime; import org.apache.tuweni.bytes.Bytes32; import org.hyperledger.besu.crypto.SECPPrivateKey; import org.junit.BeforeClass; @@ -60,7 +61,7 @@ public class TransactionHistoryStoreImplTest { `famount` decimal(20,9) NOT NULL, `ftype` tinyint NOT NULL, `fremark` varchar(64) DEFAULT NULL, - `ftime` datetime NOT NULL, + `ftime` datetime(3) NOT NULL, PRIMARY KEY (`fid`), UNIQUE KEY `id_UNIQUE` (`fid`), KEY `faddress_index` (`faddress`) @@ -93,7 +94,7 @@ public void testTxHistorySaveAndListAndCount() { txHistory.setAddress(input); txHistory.setHash(hash); txHistory.setRemark(remark); - txHistory.setTimestamp(timestamp); + txHistory.setTimestamp(XdagTime.msToXdagtimestamp(timestamp)); assertTrue(txHistoryStore.saveTxHistory(txHistory)); String addr = input.getIsAddress()?toBase58(hash2byte(input.getAddress())):hash2Address(input.getAddress());