jl777
7 years ago
committed by
GitHub
75 changed files with 4645 additions and 1652 deletions
@ -0,0 +1,2 @@ |
|||
curl --url "http://127.0.0.1:7776" --data "{\"conf\":\"AXO.conf\",\"path\":\"${HOME#"/"}/.komodo/AXO\",\"unitval\":\"20\",\"zcash\":1,\"RELAY\":-1,\"VALIDATE\":0,\"prefetchlag\":-1,\"poll\":100,\"active\":1,\"agent\":\"iguana\",\"method\":\"addcoin\",\"startpend\":4,\"endpend\":4,\"services\":129,\"maxpeers\":8,\"newcoin\":\"AXO\",\"name\":\"AXO\",\"hasheaders\":1,\"useaddmultisig\":0,\"netmagic\":\"ba009d17\",\"p2p\":12926,\"rpc\":12927,\"pubval\":60,\"p2shval\":85,\"wifval\":188,\"txfee_satoshis\":\"10000\",\"isPoS\":0,\"minoutput\":10000,\"minconfirms\":2,\"genesishash\":\"027e3758c3a65b12aa1046462b486d0a63bfa1beae327897f56c5cfb7daaae71\",\"protover\":170002,\"genesisblock\":\"0100000000000000000000000000000000000000000000000000000000000000000000003ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a000000000000000000000000000000000000000000000000000000000000000029ab5f490f0f0f200b00000000000000000000000000000000000000000000000000000000000000fd4005000d5ba7cda5d473947263bf194285317179d2b0d307119c2e7cc4bd8ac456f0774bd52b0cd9249be9d40718b6397a4c7bbd8f2b3272fed2823cd2af4bd1632200ba4bf796727d6347b225f670f292343274cc35099466f5fb5f0cd1c105121b28213d15db2ed7bdba490b4cedc69742a57b7c25af24485e523aadbb77a0144fc76f79ef73bd8530d42b9f3b9bed1c135ad1fe152923fafe98f95f76f1615e64c4abb1137f4c31b218ba2782bc15534788dda2cc08a0ee2987c8b27ff41bd4e31cd5fb5643dfe862c9a02ca9f90c8c51a6671d681d04ad47e4b53b1518d4befafefe8cadfb912f3d03051b1efbf1dfe37b56e93a741d8dfd80d576ca250bee55fab1311fc7b3255977558cdda6f7d6f875306e43a14413facdaed2f46093e0ef1e8f8a963e1632dcbeebd8e49fd16b57d49b08f9762de89157c65233f60c8e38a1f503a48c555f8ec45dedecd574a37601323c27be597b956343107f8bd80f3a925afaf30811df83c402116bb9c1e5231c70fff899a7c82f73c902ba54da53cc459b7bf1113db65cc8f6914d3618560ea69abd13658fa7b6af92d374d6eca9529f8bd565166e4fcbf2a8dfb3c9b69539d4d2ee2e9321b85b331925df195915f2757637c2805e1d4131e1ad9ef9bc1bb1c732d8dba4738716d351ab30c996c8657bab39567ee3b29c6d054b711495c0d52e1cd5d8e55b4f0f0325b97369280755b46a02afd54be4ddd9f77c22272b8bbb17ff5118fedbae2564524e797bd28b5f74f7079d532ccc059807989f94d267f47e724b3f1ecfe00ec9e6541c961080d8891251b84b4480bc292f6a180bea089fef5bbda56e1e41390d7c0e85ba0ef530f7177413481a226465a36ef6afe1e2bca69d2078712b3912bba1a99b1fbff0d355d6ffe726d2bb6fbc103c4ac5756e5bee6e47e17424ebcbf1b63d8cb90ce2e40198b4f4198689daea254307e52a25562f4c1455340f0ffeb10f9d8e914775e37d0edca019fb1b9c6ef81255ed86bc51c5391e0591480f66e2d88c5f4fd7277697968656a9b113ab97f874fdd5f2465e5559533e01ba13ef4a8f7a21d02c30c8ded68e8c54603ab9c8084ef6d9eb4e92c75b078539e2ae786ebab6dab73a09e0aa9ac575bcefb29e930ae656e58bcb513f7e3c17e079dce4f05b5dbc18c2a872b22509740ebe6a3903e00ad1abc55076441862643f93606e3dc35e8d9f2caef3ee6be14d513b2e062b21d0061de3bd56881713a1a5c17f5ace05e1ec09da53f99442df175a49bd154aa96e4949decd52fed79ccf7ccbce32941419c314e374e4a396ac553e17b5340336a1a25c22f9e42a243ba5404450b650acfc826a6e432971ace776e15719515e1634ceb9a4a35061b668c74998d3dfb5827f6238ec015377e6f9c94f38108768cf6e5c8b132e0303fb5a200368f845ad9d46343035a6ff94031df8d8309415bb3f6cd5ede9c135fdabcc030599858d803c0f85be7661c88984d88faa3d26fb0e9aac0056a53f1b5d0baed713c853c4a2726869a0a124a8a5bbc0fc0ef80c8ae4cb53636aa02503b86a1eb9836fcc259823e2692d921d88e1ffc1e6cb2bde43939ceb3f32a611686f539f8f7c9f0bf00381f743607d40960f06d347d1cd8ac8a51969c25e37150efdf7aa4c2037a2fd0516fb444525ab157a0ed0a7412b2fa69b217fe397263153782c0f64351fbdf2678fa0dc8569912dcd8e3ccad38f34f23bbbce14c6a26ac24911b308b82c7e43062d180baeac4ba7153858365c72c63dcf5f6a5b08070b730adb017aeae925b7d0439979e2679f45ed2f25a7edcfd2fb77a8794630285ccb0a071f5cce410b46dbf9750b0354aae8b65574501cc69efb5b6a43444074fee116641bb29da56c2b4a7f456991fc92b2\",\"debug\":0,\"seedipaddr\":\"78.47.196.146\"}" |
|||
|
@ -0,0 +1,2 @@ |
|||
curl --url "http://127.0.0.1:7778" --data "{\"conf\":\"AXO.conf\",\"path\":\"${HOME#"/"}/.komodo/AXO\",\"unitval\":\"20\",\"zcash\":1,\"RELAY\":0,\"VALIDATE\":0,\"prefetchlag\":-1,\"poll\":100,\"active\":1,\"agent\":\"iguana\",\"method\":\"addcoin\",\"startpend\":4,\"endpend\":4,\"services\":129,\"maxpeers\":8,\"newcoin\":\"AXO\",\"name\":\"AXO\",\"hasheaders\":1,\"useaddmultisig\":0,\"netmagic\":\"ba009d17\",\"p2p\":12926,\"rpc\":12927,\"pubval\":60,\"p2shval\":85,\"wifval\":188,\"txfee_satoshis\":\"10000\",\"isPoS\":0,\"minoutput\":10000,\"minconfirms\":2,\"genesishash\":\"027e3758c3a65b12aa1046462b486d0a63bfa1beae327897f56c5cfb7daaae71\",\"protover\":170002,\"genesisblock\":\"0100000000000000000000000000000000000000000000000000000000000000000000003ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a000000000000000000000000000000000000000000000000000000000000000029ab5f490f0f0f200b00000000000000000000000000000000000000000000000000000000000000fd4005000d5ba7cda5d473947263bf194285317179d2b0d307119c2e7cc4bd8ac456f0774bd52b0cd9249be9d40718b6397a4c7bbd8f2b3272fed2823cd2af4bd1632200ba4bf796727d6347b225f670f292343274cc35099466f5fb5f0cd1c105121b28213d15db2ed7bdba490b4cedc69742a57b7c25af24485e523aadbb77a0144fc76f79ef73bd8530d42b9f3b9bed1c135ad1fe152923fafe98f95f76f1615e64c4abb1137f4c31b218ba2782bc15534788dda2cc08a0ee2987c8b27ff41bd4e31cd5fb5643dfe862c9a02ca9f90c8c51a6671d681d04ad47e4b53b1518d4befafefe8cadfb912f3d03051b1efbf1dfe37b56e93a741d8dfd80d576ca250bee55fab1311fc7b3255977558cdda6f7d6f875306e43a14413facdaed2f46093e0ef1e8f8a963e1632dcbeebd8e49fd16b57d49b08f9762de89157c65233f60c8e38a1f503a48c555f8ec45dedecd574a37601323c27be597b956343107f8bd80f3a925afaf30811df83c402116bb9c1e5231c70fff899a7c82f73c902ba54da53cc459b7bf1113db65cc8f6914d3618560ea69abd13658fa7b6af92d374d6eca9529f8bd565166e4fcbf2a8dfb3c9b69539d4d2ee2e9321b85b331925df195915f2757637c2805e1d4131e1ad9ef9bc1bb1c732d8dba4738716d351ab30c996c8657bab39567ee3b29c6d054b711495c0d52e1cd5d8e55b4f0f0325b97369280755b46a02afd54be4ddd9f77c22272b8bbb17ff5118fedbae2564524e797bd28b5f74f7079d532ccc059807989f94d267f47e724b3f1ecfe00ec9e6541c961080d8891251b84b4480bc292f6a180bea089fef5bbda56e1e41390d7c0e85ba0ef530f7177413481a226465a36ef6afe1e2bca69d2078712b3912bba1a99b1fbff0d355d6ffe726d2bb6fbc103c4ac5756e5bee6e47e17424ebcbf1b63d8cb90ce2e40198b4f4198689daea254307e52a25562f4c1455340f0ffeb10f9d8e914775e37d0edca019fb1b9c6ef81255ed86bc51c5391e0591480f66e2d88c5f4fd7277697968656a9b113ab97f874fdd5f2465e5559533e01ba13ef4a8f7a21d02c30c8ded68e8c54603ab9c8084ef6d9eb4e92c75b078539e2ae786ebab6dab73a09e0aa9ac575bcefb29e930ae656e58bcb513f7e3c17e079dce4f05b5dbc18c2a872b22509740ebe6a3903e00ad1abc55076441862643f93606e3dc35e8d9f2caef3ee6be14d513b2e062b21d0061de3bd56881713a1a5c17f5ace05e1ec09da53f99442df175a49bd154aa96e4949decd52fed79ccf7ccbce32941419c314e374e4a396ac553e17b5340336a1a25c22f9e42a243ba5404450b650acfc826a6e432971ace776e15719515e1634ceb9a4a35061b668c74998d3dfb5827f6238ec015377e6f9c94f38108768cf6e5c8b132e0303fb5a200368f845ad9d46343035a6ff94031df8d8309415bb3f6cd5ede9c135fdabcc030599858d803c0f85be7661c88984d88faa3d26fb0e9aac0056a53f1b5d0baed713c853c4a2726869a0a124a8a5bbc0fc0ef80c8ae4cb53636aa02503b86a1eb9836fcc259823e2692d921d88e1ffc1e6cb2bde43939ceb3f32a611686f539f8f7c9f0bf00381f743607d40960f06d347d1cd8ac8a51969c25e37150efdf7aa4c2037a2fd0516fb444525ab157a0ed0a7412b2fa69b217fe397263153782c0f64351fbdf2678fa0dc8569912dcd8e3ccad38f34f23bbbce14c6a26ac24911b308b82c7e43062d180baeac4ba7153858365c72c63dcf5f6a5b08070b730adb017aeae925b7d0439979e2679f45ed2f25a7edcfd2fb77a8794630285ccb0a071f5cce410b46dbf9750b0354aae8b65574501cc69efb5b6a43444074fee116641bb29da56c2b4a7f456991fc92b2\",\"debug\":0,\"seedipaddr\":\"78.47.196.146\"}" |
|||
|
@ -0,0 +1 @@ |
|||
curl --url "http://127.0.0.1:7778" --data "{\"conf\":\"BTCH.conf\",\"path\":\"${HOME#"/"}/.komodo/BTCH\",\"unitval\":\"20\",\"zcash\":1,\"RELAY\":0,\"VALIDATE\":0,\"prefetchlag\":-1,\"poll\":100,\"active\":1,\"agent\":\"iguana\",\"method\":\"addcoin\",\"startpend\":4,\"endpend\":4,\"services\":129,\"maxpeers\":8,\"newcoin\":\"BTCH\",\"name\":\"BTCH\",\"hasheaders\":1,\"useaddmultisig\":0,\"netmagic\":\"b0ed1968\",\"p2p\":10160,\"rpc\":10161,\"pubval\":60,\"p2shval\":85,\"wifval\":188,\"txfee_satoshis\":\"10000\",\"isPoS\":0,\"minoutput\":10000,\"minconfirms\":2,\"genesishash\":\"027e3758c3a65b12aa1046462b486d0a63bfa1beae327897f56c5cfb7daaae71\",\"protover\":170002,\"genesisblock\":\"0100000000000000000000000000000000000000000000000000000000000000000000003ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a000000000000000000000000000000000000000000000000000000000000000029ab5f490f0f0f200b00000000000000000000000000000000000000000000000000000000000000fd4005000d5ba7cda5d473947263bf194285317179d2b0d307119c2e7cc4bd8ac456f0774bd52b0cd9249be9d40718b6397a4c7bbd8f2b3272fed2823cd2af4bd1632200ba4bf796727d6347b225f670f292343274cc35099466f5fb5f0cd1c105121b28213d15db2ed7bdba490b4cedc69742a57b7c25af24485e523aadbb77a0144fc76f79ef73bd8530d42b9f3b9bed1c135ad1fe152923fafe98f95f76f1615e64c4abb1137f4c31b218ba2782bc15534788dda2cc08a0ee2987c8b27ff41bd4e31cd5fb5643dfe862c9a02ca9f90c8c51a6671d681d04ad47e4b53b1518d4befafefe8cadfb912f3d03051b1efbf1dfe37b56e93a741d8dfd80d576ca250bee55fab1311fc7b3255977558cdda6f7d6f875306e43a14413facdaed2f46093e0ef1e8f8a963e1632dcbeebd8e49fd16b57d49b08f9762de89157c65233f60c8e38a1f503a48c555f8ec45dedecd574a37601323c27be597b956343107f8bd80f3a925afaf30811df83c402116bb9c1e5231c70fff899a7c82f73c902ba54da53cc459b7bf1113db65cc8f6914d3618560ea69abd13658fa7b6af92d374d6eca9529f8bd565166e4fcbf2a8dfb3c9b69539d4d2ee2e9321b85b331925df195915f2757637c2805e1d4131e1ad9ef9bc1bb1c732d8dba4738716d351ab30c996c8657bab39567ee3b29c6d054b711495c0d52e1cd5d8e55b4f0f0325b97369280755b46a02afd54be4ddd9f77c22272b8bbb17ff5118fedbae2564524e797bd28b5f74f7079d532ccc059807989f94d267f47e724b3f1ecfe00ec9e6541c961080d8891251b84b4480bc292f6a180bea089fef5bbda56e1e41390d7c0e85ba0ef530f7177413481a226465a36ef6afe1e2bca69d2078712b3912bba1a99b1fbff0d355d6ffe726d2bb6fbc103c4ac5756e5bee6e47e17424ebcbf1b63d8cb90ce2e40198b4f4198689daea254307e52a25562f4c1455340f0ffeb10f9d8e914775e37d0edca019fb1b9c6ef81255ed86bc51c5391e0591480f66e2d88c5f4fd7277697968656a9b113ab97f874fdd5f2465e5559533e01ba13ef4a8f7a21d02c30c8ded68e8c54603ab9c8084ef6d9eb4e92c75b078539e2ae786ebab6dab73a09e0aa9ac575bcefb29e930ae656e58bcb513f7e3c17e079dce4f05b5dbc18c2a872b22509740ebe6a3903e00ad1abc55076441862643f93606e3dc35e8d9f2caef3ee6be14d513b2e062b21d0061de3bd56881713a1a5c17f5ace05e1ec09da53f99442df175a49bd154aa96e4949decd52fed79ccf7ccbce32941419c314e374e4a396ac553e17b5340336a1a25c22f9e42a243ba5404450b650acfc826a6e432971ace776e15719515e1634ceb9a4a35061b668c74998d3dfb5827f6238ec015377e6f9c94f38108768cf6e5c8b132e0303fb5a200368f845ad9d46343035a6ff94031df8d8309415bb3f6cd5ede9c135fdabcc030599858d803c0f85be7661c88984d88faa3d26fb0e9aac0056a53f1b5d0baed713c853c4a2726869a0a124a8a5bbc0fc0ef80c8ae4cb53636aa02503b86a1eb9836fcc259823e2692d921d88e1ffc1e6cb2bde43939ceb3f32a611686f539f8f7c9f0bf00381f743607d40960f06d347d1cd8ac8a51969c25e37150efdf7aa4c2037a2fd0516fb444525ab157a0ed0a7412b2fa69b217fe397263153782c0f64351fbdf2678fa0dc8569912dcd8e3ccad38f34f23bbbce14c6a26ac24911b308b82c7e43062d180baeac4ba7153858365c72c63dcf5f6a5b08070b730adb017aeae925b7d0439979e2679f45ed2f25a7edcfd2fb77a8794630285ccb0a071f5cce410b46dbf9750b0354aae8b65574501cc69efb5b6a43444074fee116641bb29da56c2b4a7f456991fc92b2\",\"debug\":0,\"seedipaddr\":\"78.47.196.146\"}" |
@ -0,0 +1,2 @@ |
|||
curl --url "http://127.0.0.1:7778" --data "{\"conf\":\"ETOMIC.conf\",\"path\":\"${HOME#"/"}/.komodo/ETOMIC\",\"unitval\":\"20\",\"zcash\":1,\"RELAY\":0,\"VALIDATE\":0,\"prefetchlag\":-1,\"poll\":100,\"active\":1,\"agent\":\"iguana\",\"method\":\"addcoin\",\"startpend\":4,\"endpend\":4,\"services\":129,\"maxpeers\":8,\"newcoin\":\"ETOMIC\",\"name\":\"ETOMIC\",\"hasheaders\":1,\"useaddmultisig\":0,\"netmagic\":\"072a90e8\",\"p2p\":10270,\"rpc\":10271,\"pubval\":60,\"p2shval\":85,\"wifval\":188,\"txfee_satoshis\":\"10000\",\"isPoS\":0,\"minoutput\":10000,\"minconfirms\":2,\"genesishash\":\"027e3758c3a65b12aa1046462b486d0a63bfa1beae327897f56c5cfb7daaae71\",\"protover\":170002,\"genesisblock\":\"0100000000000000000000000000000000000000000000000000000000000000000000003ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a000000000000000000000000000000000000000000000000000000000000000029ab5f490f0f0f200b00000000000000000000000000000000000000000000000000000000000000fd4005000d5ba7cda5d473947263bf194285317179d2b0d307119c2e7cc4bd8ac456f0774bd52b0cd9249be9d40718b6397a4c7bbd8f2b3272fed2823cd2af4bd1632200ba4bf796727d6347b225f670f292343274cc35099466f5fb5f0cd1c105121b28213d15db2ed7bdba490b4cedc69742a57b7c25af24485e523aadbb77a0144fc76f79ef73bd8530d42b9f3b9bed1c135ad1fe152923fafe98f95f76f1615e64c4abb1137f4c31b218ba2782bc15534788dda2cc08a0ee2987c8b27ff41bd4e31cd5fb5643dfe862c9a02ca9f90c8c51a6671d681d04ad47e4b53b1518d4befafefe8cadfb912f3d03051b1efbf1dfe37b56e93a741d8dfd80d576ca250bee55fab1311fc7b3255977558cdda6f7d6f875306e43a14413facdaed2f46093e0ef1e8f8a963e1632dcbeebd8e49fd16b57d49b08f9762de89157c65233f60c8e38a1f503a48c555f8ec45dedecd574a37601323c27be597b956343107f8bd80f3a925afaf30811df83c402116bb9c1e5231c70fff899a7c82f73c902ba54da53cc459b7bf1113db65cc8f6914d3618560ea69abd13658fa7b6af92d374d6eca9529f8bd565166e4fcbf2a8dfb3c9b69539d4d2ee2e9321b85b331925df195915f2757637c2805e1d4131e1ad9ef9bc1bb1c732d8dba4738716d351ab30c996c8657bab39567ee3b29c6d054b711495c0d52e1cd5d8e55b4f0f0325b97369280755b46a02afd54be4ddd9f77c22272b8bbb17ff5118fedbae2564524e797bd28b5f74f7079d532ccc059807989f94d267f47e724b3f1ecfe00ec9e6541c961080d8891251b84b4480bc292f6a180bea089fef5bbda56e1e41390d7c0e85ba0ef530f7177413481a226465a36ef6afe1e2bca69d2078712b3912bba1a99b1fbff0d355d6ffe726d2bb6fbc103c4ac5756e5bee6e47e17424ebcbf1b63d8cb90ce2e40198b4f4198689daea254307e52a25562f4c1455340f0ffeb10f9d8e914775e37d0edca019fb1b9c6ef81255ed86bc51c5391e0591480f66e2d88c5f4fd7277697968656a9b113ab97f874fdd5f2465e5559533e01ba13ef4a8f7a21d02c30c8ded68e8c54603ab9c8084ef6d9eb4e92c75b078539e2ae786ebab6dab73a09e0aa9ac575bcefb29e930ae656e58bcb513f7e3c17e079dce4f05b5dbc18c2a872b22509740ebe6a3903e00ad1abc55076441862643f93606e3dc35e8d9f2caef3ee6be14d513b2e062b21d0061de3bd56881713a1a5c17f5ace05e1ec09da53f99442df175a49bd154aa96e4949decd52fed79ccf7ccbce32941419c314e374e4a396ac553e17b5340336a1a25c22f9e42a243ba5404450b650acfc826a6e432971ace776e15719515e1634ceb9a4a35061b668c74998d3dfb5827f6238ec015377e6f9c94f38108768cf6e5c8b132e0303fb5a200368f845ad9d46343035a6ff94031df8d8309415bb3f6cd5ede9c135fdabcc030599858d803c0f85be7661c88984d88faa3d26fb0e9aac0056a53f1b5d0baed713c853c4a2726869a0a124a8a5bbc0fc0ef80c8ae4cb53636aa02503b86a1eb9836fcc259823e2692d921d88e1ffc1e6cb2bde43939ceb3f32a611686f539f8f7c9f0bf00381f743607d40960f06d347d1cd8ac8a51969c25e37150efdf7aa4c2037a2fd0516fb444525ab157a0ed0a7412b2fa69b217fe397263153782c0f64351fbdf2678fa0dc8569912dcd8e3ccad38f34f23bbbce14c6a26ac24911b308b82c7e43062d180baeac4ba7153858365c72c63dcf5f6a5b08070b730adb017aeae925b7d0439979e2679f45ed2f25a7edcfd2fb77a8794630285ccb0a071f5cce410b46dbf9750b0354aae8b65574501cc69efb5b6a43444074fee116641bb29da56c2b4a7f456991fc92b2\",\"debug\":0,\"seedipaddr\":\"78.47.196.146\"}" |
|||
|
@ -0,0 +1,2 @@ |
|||
curl --url "http://127.0.0.1:7776" --data "{\"conf\":\"BTCH.conf\",\"path\":\"${HOME#"/"}/.komodo/BTCH\",\"unitval\":\"20\",\"zcash\":1,\"RELAY\":-1,\"VALIDATE\":0,\"prefetchlag\":-1,\"poll\":100,\"active\":1,\"agent\":\"iguana\",\"method\":\"addcoin\",\"startpend\":4,\"endpend\":4,\"services\":129,\"maxpeers\":8,\"newcoin\":\"BTCH\",\"name\":\"BTCH\",\"hasheaders\":1,\"useaddmultisig\":0,\"netmagic\":\"b0ed1968\",\"p2p\":10160,\"rpc\":10161,\"pubval\":60,\"p2shval\":85,\"wifval\":188,\"txfee_satoshis\":\"10000\",\"isPoS\":0,\"minoutput\":10000,\"minconfirms\":2,\"genesishash\":\"027e3758c3a65b12aa1046462b486d0a63bfa1beae327897f56c5cfb7daaae71\",\"protover\":170002,\"genesisblock\":\"0100000000000000000000000000000000000000000000000000000000000000000000003ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a000000000000000000000000000000000000000000000000000000000000000029ab5f490f0f0f200b00000000000000000000000000000000000000000000000000000000000000fd4005000d5ba7cda5d473947263bf194285317179d2b0d307119c2e7cc4bd8ac456f0774bd52b0cd9249be9d40718b6397a4c7bbd8f2b3272fed2823cd2af4bd1632200ba4bf796727d6347b225f670f292343274cc35099466f5fb5f0cd1c105121b28213d15db2ed7bdba490b4cedc69742a57b7c25af24485e523aadbb77a0144fc76f79ef73bd8530d42b9f3b9bed1c135ad1fe152923fafe98f95f76f1615e64c4abb1137f4c31b218ba2782bc15534788dda2cc08a0ee2987c8b27ff41bd4e31cd5fb5643dfe862c9a02ca9f90c8c51a6671d681d04ad47e4b53b1518d4befafefe8cadfb912f3d03051b1efbf1dfe37b56e93a741d8dfd80d576ca250bee55fab1311fc7b3255977558cdda6f7d6f875306e43a14413facdaed2f46093e0ef1e8f8a963e1632dcbeebd8e49fd16b57d49b08f9762de89157c65233f60c8e38a1f503a48c555f8ec45dedecd574a37601323c27be597b956343107f8bd80f3a925afaf30811df83c402116bb9c1e5231c70fff899a7c82f73c902ba54da53cc459b7bf1113db65cc8f6914d3618560ea69abd13658fa7b6af92d374d6eca9529f8bd565166e4fcbf2a8dfb3c9b69539d4d2ee2e9321b85b331925df195915f2757637c2805e1d4131e1ad9ef9bc1bb1c732d8dba4738716d351ab30c996c8657bab39567ee3b29c6d054b711495c0d52e1cd5d8e55b4f0f0325b97369280755b46a02afd54be4ddd9f77c22272b8bbb17ff5118fedbae2564524e797bd28b5f74f7079d532ccc059807989f94d267f47e724b3f1ecfe00ec9e6541c961080d8891251b84b4480bc292f6a180bea089fef5bbda56e1e41390d7c0e85ba0ef530f7177413481a226465a36ef6afe1e2bca69d2078712b3912bba1a99b1fbff0d355d6ffe726d2bb6fbc103c4ac5756e5bee6e47e17424ebcbf1b63d8cb90ce2e40198b4f4198689daea254307e52a25562f4c1455340f0ffeb10f9d8e914775e37d0edca019fb1b9c6ef81255ed86bc51c5391e0591480f66e2d88c5f4fd7277697968656a9b113ab97f874fdd5f2465e5559533e01ba13ef4a8f7a21d02c30c8ded68e8c54603ab9c8084ef6d9eb4e92c75b078539e2ae786ebab6dab73a09e0aa9ac575bcefb29e930ae656e58bcb513f7e3c17e079dce4f05b5dbc18c2a872b22509740ebe6a3903e00ad1abc55076441862643f93606e3dc35e8d9f2caef3ee6be14d513b2e062b21d0061de3bd56881713a1a5c17f5ace05e1ec09da53f99442df175a49bd154aa96e4949decd52fed79ccf7ccbce32941419c314e374e4a396ac553e17b5340336a1a25c22f9e42a243ba5404450b650acfc826a6e432971ace776e15719515e1634ceb9a4a35061b668c74998d3dfb5827f6238ec015377e6f9c94f38108768cf6e5c8b132e0303fb5a200368f845ad9d46343035a6ff94031df8d8309415bb3f6cd5ede9c135fdabcc030599858d803c0f85be7661c88984d88faa3d26fb0e9aac0056a53f1b5d0baed713c853c4a2726869a0a124a8a5bbc0fc0ef80c8ae4cb53636aa02503b86a1eb9836fcc259823e2692d921d88e1ffc1e6cb2bde43939ceb3f32a611686f539f8f7c9f0bf00381f743607d40960f06d347d1cd8ac8a51969c25e37150efdf7aa4c2037a2fd0516fb444525ab157a0ed0a7412b2fa69b217fe397263153782c0f64351fbdf2678fa0dc8569912dcd8e3ccad38f34f23bbbce14c6a26ac24911b308b82c7e43062d180baeac4ba7153858365c72c63dcf5f6a5b08070b730adb017aeae925b7d0439979e2679f45ed2f25a7edcfd2fb77a8794630285ccb0a071f5cce410b46dbf9750b0354aae8b65574501cc69efb5b6a43444074fee116641bb29da56c2b4a7f456991fc92b2\",\"debug\":0,\"seedipaddr\":\"78.47.196.146\"}" |
|||
|
@ -0,0 +1,2 @@ |
|||
curl --url "http://127.0.0.1:7776" --data "{\"conf\":\"ETOMIC.conf\",\"path\":\"${HOME#"/"}/.komodo/ETOMIC\",\"unitval\":\"20\",\"zcash\":1,\"RELAY\":-1,\"VALIDATE\":0,\"prefetchlag\":-1,\"poll\":100,\"active\":1,\"agent\":\"iguana\",\"method\":\"addcoin\",\"startpend\":4,\"endpend\":4,\"services\":129,\"maxpeers\":8,\"newcoin\":\"ETOMIC\",\"name\":\"ETOMIC\",\"hasheaders\":1,\"useaddmultisig\":0,\"netmagic\":\"072a90e8\",\"p2p\":10270,\"rpc\":10271,\"pubval\":60,\"p2shval\":85,\"wifval\":188,\"txfee_satoshis\":\"10000\",\"isPoS\":0,\"minoutput\":10000,\"minconfirms\":2,\"genesishash\":\"027e3758c3a65b12aa1046462b486d0a63bfa1beae327897f56c5cfb7daaae71\",\"protover\":170002,\"genesisblock\":\"0100000000000000000000000000000000000000000000000000000000000000000000003ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a000000000000000000000000000000000000000000000000000000000000000029ab5f490f0f0f200b00000000000000000000000000000000000000000000000000000000000000fd4005000d5ba7cda5d473947263bf194285317179d2b0d307119c2e7cc4bd8ac456f0774bd52b0cd9249be9d40718b6397a4c7bbd8f2b3272fed2823cd2af4bd1632200ba4bf796727d6347b225f670f292343274cc35099466f5fb5f0cd1c105121b28213d15db2ed7bdba490b4cedc69742a57b7c25af24485e523aadbb77a0144fc76f79ef73bd8530d42b9f3b9bed1c135ad1fe152923fafe98f95f76f1615e64c4abb1137f4c31b218ba2782bc15534788dda2cc08a0ee2987c8b27ff41bd4e31cd5fb5643dfe862c9a02ca9f90c8c51a6671d681d04ad47e4b53b1518d4befafefe8cadfb912f3d03051b1efbf1dfe37b56e93a741d8dfd80d576ca250bee55fab1311fc7b3255977558cdda6f7d6f875306e43a14413facdaed2f46093e0ef1e8f8a963e1632dcbeebd8e49fd16b57d49b08f9762de89157c65233f60c8e38a1f503a48c555f8ec45dedecd574a37601323c27be597b956343107f8bd80f3a925afaf30811df83c402116bb9c1e5231c70fff899a7c82f73c902ba54da53cc459b7bf1113db65cc8f6914d3618560ea69abd13658fa7b6af92d374d6eca9529f8bd565166e4fcbf2a8dfb3c9b69539d4d2ee2e9321b85b331925df195915f2757637c2805e1d4131e1ad9ef9bc1bb1c732d8dba4738716d351ab30c996c8657bab39567ee3b29c6d054b711495c0d52e1cd5d8e55b4f0f0325b97369280755b46a02afd54be4ddd9f77c22272b8bbb17ff5118fedbae2564524e797bd28b5f74f7079d532ccc059807989f94d267f47e724b3f1ecfe00ec9e6541c961080d8891251b84b4480bc292f6a180bea089fef5bbda56e1e41390d7c0e85ba0ef530f7177413481a226465a36ef6afe1e2bca69d2078712b3912bba1a99b1fbff0d355d6ffe726d2bb6fbc103c4ac5756e5bee6e47e17424ebcbf1b63d8cb90ce2e40198b4f4198689daea254307e52a25562f4c1455340f0ffeb10f9d8e914775e37d0edca019fb1b9c6ef81255ed86bc51c5391e0591480f66e2d88c5f4fd7277697968656a9b113ab97f874fdd5f2465e5559533e01ba13ef4a8f7a21d02c30c8ded68e8c54603ab9c8084ef6d9eb4e92c75b078539e2ae786ebab6dab73a09e0aa9ac575bcefb29e930ae656e58bcb513f7e3c17e079dce4f05b5dbc18c2a872b22509740ebe6a3903e00ad1abc55076441862643f93606e3dc35e8d9f2caef3ee6be14d513b2e062b21d0061de3bd56881713a1a5c17f5ace05e1ec09da53f99442df175a49bd154aa96e4949decd52fed79ccf7ccbce32941419c314e374e4a396ac553e17b5340336a1a25c22f9e42a243ba5404450b650acfc826a6e432971ace776e15719515e1634ceb9a4a35061b668c74998d3dfb5827f6238ec015377e6f9c94f38108768cf6e5c8b132e0303fb5a200368f845ad9d46343035a6ff94031df8d8309415bb3f6cd5ede9c135fdabcc030599858d803c0f85be7661c88984d88faa3d26fb0e9aac0056a53f1b5d0baed713c853c4a2726869a0a124a8a5bbc0fc0ef80c8ae4cb53636aa02503b86a1eb9836fcc259823e2692d921d88e1ffc1e6cb2bde43939ceb3f32a611686f539f8f7c9f0bf00381f743607d40960f06d347d1cd8ac8a51969c25e37150efdf7aa4c2037a2fd0516fb444525ab157a0ed0a7412b2fa69b217fe397263153782c0f64351fbdf2678fa0dc8569912dcd8e3ccad38f34f23bbbce14c6a26ac24911b308b82c7e43062d180baeac4ba7153858365c72c63dcf5f6a5b08070b730adb017aeae925b7d0439979e2679f45ed2f25a7edcfd2fb77a8794630285ccb0a071f5cce410b46dbf9750b0354aae8b65574501cc69efb5b6a43444074fee116641bb29da56c2b4a7f456991fc92b2\",\"debug\":0,\"seedipaddr\":\"78.47.196.146\"}" |
|||
|
@ -0,0 +1,708 @@ |
|||
/******************************************************************************
|
|||
* Copyright © 2014-2017 The SuperNET Developers. * |
|||
* * |
|||
* See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at * |
|||
* the top-level directory of this distribution for the individual copyright * |
|||
* holder information and the developer policies on copyright and licensing. * |
|||
* * |
|||
* Unless otherwise agreed in a custom licensing agreement, no part of the * |
|||
* SuperNET software, including this file may be copied, modified, propagated * |
|||
* or distributed except according to the terms contained in the LICENSE file * |
|||
* * |
|||
* Removal or modification of this copyright notice is prohibited. * |
|||
* * |
|||
******************************************************************************/ |
|||
//
|
|||
// LP_mmjson.c
|
|||
// marketmaker
|
|||
//
|
|||
#define MMJSON_IPADDR 255 |
|||
#define MMJSON_BITS256 254 |
|||
#define MMJSON_SECP33 253 |
|||
#define MMJSON_SIG 252 |
|||
#define MMJSON_RMD160 251 |
|||
#define MMJSON_DECIMAL8 250 |
|||
#define MMJSON_DECIMAL8STR 249 |
|||
#define MMJSON_DECIMAL16 248 |
|||
#define MMJSON_DECIMAL16STR 247 |
|||
#define MMJSON_DECIMAL24 246 |
|||
#define MMJSON_DECIMAL24STR 245 |
|||
#define MMJSON_DECIMAL32 244 |
|||
#define MMJSON_DECIMAL32STR 243 |
|||
#define MMJSON_DECIMAL40 242 |
|||
#define MMJSON_DECIMAL40STR 241 |
|||
#define MMJSON_DECIMAL48 240 |
|||
#define MMJSON_DECIMAL48STR 239 |
|||
#define MMJSON_DOUBLE 238 |
|||
#define MMJSON_DECIMAL64 237 |
|||
#define MMJSON_DECIMAL64STR 236 |
|||
#define MMJSON_TIMESTAMP 235 |
|||
#define MMJSON_TIMEDIFF8 234 |
|||
#define MMJSON_TIMEDIFF16 233 |
|||
#define MMJSON_ZERO 232 |
|||
#define MMJSON_ZEROSTR 231 |
|||
#define MMJSON_COIN 230 |
|||
#define MMJSON_STRING 229 |
|||
#define MMJSON_ARRAY8 228 |
|||
#define MMJSON_ARRAY16 227 |
|||
#define MMJSON_ARRAY32 226 |
|||
#define MMJSON_BOUNDARY 98 |
|||
|
|||
int32_t MM_numfields; |
|||
char *MM_fields[256] = |
|||
{ |
|||
"timestamp", "getdPoW", "dPoW", "aliceid", "src", "base", "basevol", "dest", "rel", "relvol", "price", "requestid", "quoteid", "finished", "expired", "bobdeposit", "alicepayment", "bobpayment", "paymentspent", "Apaymentspent", "depositspent", "ind", "method", "swapstatus", "method2", "gettradestatus", "coin", "rmd160", "pub", "pubsecp", "sig", "session", "notify", "pubkey", "price64", "credits", "utxocoin", "n", "bal", "min", "max", "postprice", "notarized", "notarizedhash", "notarizationtxid", "wantnotify", "isLP", "gui", "nogui", "tradeid", "address", "txid", "vout", "srchash", "txfee", "quotetime", "satoshis", "desthash", "txid2", "vout2", "destaddr", "desttxid", "destvout", "feetxid", "feevout", "desttxfee", "destsatoshis", "pending", "reserved", "broadcast", "ismine", "simplegui", "request", "proof", "connect", "expiration", "iambob", "Bgui", "", "Agui", "bob", "srcamount", "bobtxfee", "alice", "destamount", "alicetxfee", "sentflags", "values", "result", "success", "status", "finishtime", "tradestatus", "pair", "connected", "warning", "critical", "endcritical", |
|||
}; |
|||
|
|||
char *MM_coins[256] = |
|||
{ |
|||
"KMD", "BTC", "CRC", "VOT", "INN", "MOON", "CRW", "EFL", "GBX", "BCO", "BLK", "BTG", "BCH", "ABY", "STAK", "XZC", "QTUM", "PURA", "DSR", "MNZ", "BTCZ", "MAGA", "BSD", "IOP", "BLOCK", "CHIPS", "888", "ARG", "GLT", "ZER", "HODLC", "UIS", "HUC", "PIVX", "BDL", "ARC", "ZCL", "VIA", "ERC", "FAIR", "FLO", "SXC", "CREA", "TRC", "BTA", "SMC", "NMC", "NAV", "EMC2", "SYS", "I0C", "DASH", "STRAT", "MUE", "MONA", "XMY", "MAC", "BTX", "XRE", "LBC", "SIB", "VTC", "REVS", "JUMBLR", "DOGE", "HUSH", "ZEC", "DGB", "ZET", "GAME", "LTC", "SUPERNET", "WLC", "PANGEA", "DEX", "BET", "CRYPTO", "HODL", "MSHARK", "BOTS", "MGW", "COQUI", "KV", "CEAL", "MESH", |
|||
}; |
|||
|
|||
int32_t mmjson_coinfind(char *symbol) |
|||
{ |
|||
int32_t i; |
|||
for (i=0; i<sizeof(MM_coins)/sizeof(*MM_coins); i++) |
|||
{ |
|||
if ( MM_coins[i] == 0 ) |
|||
return(-1); |
|||
if ( strcmp(MM_coins[i],symbol) == 0 ) |
|||
return(i); |
|||
} |
|||
return(-1); |
|||
}; |
|||
|
|||
int32_t mmadd(char *field) |
|||
{ |
|||
MM_fields[MM_numfields] = calloc(1,strlen(field)+1); |
|||
strcpy(MM_fields[MM_numfields],field); |
|||
return(MM_numfields++); |
|||
} |
|||
|
|||
int32_t mmfind(char *field) |
|||
{ |
|||
int32_t i; |
|||
if ( MM_numfields == 0 ) |
|||
{ |
|||
for (i=0; i<sizeof(MM_fields)/sizeof(*MM_fields); i++) |
|||
if ( MM_fields[i] == 0 ) |
|||
break; |
|||
MM_numfields = i; |
|||
} |
|||
for (i=0; i<MM_numfields; i++) |
|||
{ |
|||
if ( strcmp(MM_fields[i],field) == 0 ) |
|||
return(i); |
|||
} |
|||
return(-1); |
|||
} |
|||
|
|||
int32_t MMJSON_rwnum(int32_t rwflag,uint8_t *buf,uint64_t *longp,int32_t n) |
|||
{ |
|||
int32_t i; uint64_t l = 0; |
|||
if ( rwflag != 0 ) |
|||
{ |
|||
l = *longp; |
|||
for (i=0; i<n; i++) |
|||
{ |
|||
buf[i] = (uint8_t)l; |
|||
l >>= 8; |
|||
} |
|||
} |
|||
else |
|||
{ |
|||
for (i=n-1; i>=0; i--) |
|||
{ |
|||
l <<= 8; |
|||
l |= buf[i]; |
|||
} |
|||
*longp = l; |
|||
} |
|||
return(n); |
|||
} |
|||
|
|||
int32_t MMJSON_decodeitem(cJSON *lineobj,uint8_t *linebuf,int32_t i,int32_t len,char *fieldstr,uint32_t *timestampp) |
|||
{ |
|||
int32_t c,valind,j; char tmpstr[64],ipaddr[64],hexstr[256],arbstr[8192]; uint64_t l; |
|||
switch ( (valind= linebuf[i++]) ) |
|||
{ |
|||
case MMJSON_IPADDR: |
|||
i += MMJSON_rwnum(0,&linebuf[i],&l,4); |
|||
expand_ipbits(ipaddr,(uint32_t)l); |
|||
jaddstr(lineobj,fieldstr,ipaddr); |
|||
break; |
|||
case MMJSON_BITS256: |
|||
init_hexbytes_noT(hexstr,&linebuf[i],32); |
|||
i += 32; |
|||
jaddstr(lineobj,fieldstr,hexstr); |
|||
break; |
|||
case MMJSON_SECP33: |
|||
init_hexbytes_noT(hexstr,&linebuf[i],33); |
|||
i += 33; |
|||
jaddstr(lineobj,fieldstr,hexstr); |
|||
break; |
|||
case MMJSON_SIG: |
|||
init_hexbytes_noT(hexstr,&linebuf[i],65); |
|||
i += 65; |
|||
jaddstr(lineobj,fieldstr,hexstr); |
|||
break; |
|||
case MMJSON_RMD160: |
|||
init_hexbytes_noT(hexstr,&linebuf[i],20); |
|||
i += 20; |
|||
jaddstr(lineobj,fieldstr,hexstr); |
|||
break; |
|||
case MMJSON_DECIMAL8: |
|||
l = linebuf[i++]; |
|||
jaddnum(lineobj,fieldstr,l); |
|||
break; |
|||
case MMJSON_DECIMAL8STR: |
|||
l = linebuf[i++]; |
|||
jadd64bits(lineobj,fieldstr,l); |
|||
break; |
|||
case MMJSON_DECIMAL16: |
|||
i += MMJSON_rwnum(0,&linebuf[i],&l,2); |
|||
jaddnum(lineobj,fieldstr,l); |
|||
break; |
|||
case MMJSON_DECIMAL16STR: |
|||
i += MMJSON_rwnum(0,&linebuf[i],&l,2); |
|||
jadd64bits(lineobj,fieldstr,l); |
|||
break; |
|||
case MMJSON_DECIMAL24: |
|||
i += MMJSON_rwnum(0,&linebuf[i],&l,3); |
|||
jaddnum(lineobj,fieldstr,l); |
|||
break; |
|||
case MMJSON_DECIMAL24STR: |
|||
i += MMJSON_rwnum(0,&linebuf[i],&l,3); |
|||
sprintf(tmpstr,"%llu",(long long)l); |
|||
jaddstr(lineobj,fieldstr,tmpstr); |
|||
break; |
|||
case MMJSON_DECIMAL32: |
|||
i += MMJSON_rwnum(0,&linebuf[i],&l,4); |
|||
//printf("decimal32.%u %08x\n",(uint32_t)l,(uint32_t)l);
|
|||
jaddnum(lineobj,fieldstr,l); |
|||
break; |
|||
case MMJSON_DECIMAL32STR: |
|||
i += MMJSON_rwnum(0,&linebuf[i],&l,4); |
|||
//printf("decimal32.%u %08x\n",(uint32_t)l,(uint32_t)l);
|
|||
jadd64bits(lineobj,fieldstr,l); |
|||
break; |
|||
case MMJSON_DECIMAL40: |
|||
i += MMJSON_rwnum(0,&linebuf[i],&l,5); |
|||
jaddnum(lineobj,fieldstr,l); |
|||
break; |
|||
case MMJSON_DECIMAL40STR: |
|||
i += MMJSON_rwnum(0,&linebuf[i],&l,5); |
|||
jadd64bits(lineobj,fieldstr,l); |
|||
break; |
|||
case MMJSON_DECIMAL48: |
|||
i += MMJSON_rwnum(0,&linebuf[i],&l,6); |
|||
jaddnum(lineobj,fieldstr,l); |
|||
break; |
|||
case MMJSON_DECIMAL48STR: |
|||
i += MMJSON_rwnum(0,&linebuf[i],&l,6); |
|||
jadd64bits(lineobj,fieldstr,l); |
|||
break; |
|||
case MMJSON_DOUBLE: |
|||
i += MMJSON_rwnum(0,&linebuf[i],&l,8); |
|||
//printf("double %llu -> %.8f\n",(long long)l,dstr(l));
|
|||
jaddnum(lineobj,fieldstr,dstr(l)); |
|||
break; |
|||
case MMJSON_DECIMAL64: |
|||
i += MMJSON_rwnum(0,&linebuf[i],&l,8); |
|||
jadd64bits(lineobj,fieldstr,l); |
|||
break; |
|||
case MMJSON_DECIMAL64STR: |
|||
i += MMJSON_rwnum(0,&linebuf[i],&l,8); |
|||
jadd64bits(lineobj,fieldstr,l); |
|||
break; |
|||
case MMJSON_TIMESTAMP: |
|||
if ( *timestampp == 0 ) |
|||
{ |
|||
i += MMJSON_rwnum(0,&linebuf[i],&l,4); |
|||
*timestampp = (uint32_t)l; |
|||
jaddnum(lineobj,fieldstr,l); |
|||
} |
|||
else |
|||
{ |
|||
printf("timestamp %u already exists\n",*timestampp); |
|||
free_json(lineobj); |
|||
return(-1); |
|||
} |
|||
break; |
|||
case MMJSON_TIMEDIFF8: |
|||
jaddnum(lineobj,fieldstr,*timestampp + linebuf[i++]); |
|||
break; |
|||
case MMJSON_TIMEDIFF16: |
|||
i += MMJSON_rwnum(0,&linebuf[i],&l,2); |
|||
jaddnum(lineobj,fieldstr,*timestampp + l); |
|||
break; |
|||
case MMJSON_ZERO: |
|||
jaddnum(lineobj,fieldstr,0); |
|||
break; |
|||
case MMJSON_ZEROSTR: |
|||
//printf("%s.zerostr\n",fieldstr);
|
|||
jadd64bits(lineobj,fieldstr,0); |
|||
break; |
|||
case MMJSON_COIN: |
|||
jaddstr(lineobj,fieldstr,MM_coins[linebuf[i++]]); |
|||
break; |
|||
case MMJSON_STRING: |
|||
j = 0; |
|||
while ( (c= linebuf[i++]) != 0 ) |
|||
{ |
|||
if ( i > len ) |
|||
{ |
|||
printf("string overflow i.%d vs len.%d\n",i,len); |
|||
free_json(lineobj); |
|||
return(-1); |
|||
} |
|||
arbstr[j++] = c; |
|||
} |
|||
arbstr[j] = 0; |
|||
jaddstr(lineobj,fieldstr,arbstr); |
|||
break; |
|||
default: |
|||
if ( valind < MMJSON_BOUNDARY ) |
|||
jaddstr(lineobj,fieldstr,MM_fields[valind]); |
|||
else |
|||
{ |
|||
printf("%s unhandled valind.%d k.%d len.%d (%s)\n",fieldstr,valind,i,len,jprint(lineobj,0)); |
|||
free_json(lineobj); |
|||
return(-1); |
|||
} |
|||
break; |
|||
} |
|||
return(i); |
|||
} |
|||
|
|||
char *MMJSON_decode(uint8_t *linebuf,int32_t len) |
|||
{ |
|||
uint32_t timestamp = 0; char *fieldstr; uint64_t l; int32_t ind,i=0,j,m=-1; cJSON *obj,*item,*array,*lineobj = cJSON_CreateObject(); |
|||
while ( i+1 < len ) |
|||
{ |
|||
//printf("ind.%d i.%d vs len.%d\n",linebuf[i],i,len);
|
|||
if ( (ind= linebuf[i++]) >= MMJSON_BOUNDARY ) |
|||
{ |
|||
if ( ind != MMJSON_STRING ) |
|||
{ |
|||
printf("illegal field ind.%d (%s)\n",ind,jprint(lineobj,0)); |
|||
free_json(lineobj); |
|||
return(0); |
|||
} |
|||
else |
|||
{ |
|||
fieldstr = (char *)&linebuf[i++]; |
|||
while ( linebuf[i] != 0 ) |
|||
i++; |
|||
i++; |
|||
} |
|||
} else fieldstr = MM_fields[ind]; |
|||
if ( linebuf[i] == MMJSON_ARRAY8 ) |
|||
{ |
|||
i++; |
|||
m = linebuf[i++]; |
|||
} |
|||
else if ( linebuf[i] == MMJSON_ARRAY16 ) |
|||
{ |
|||
i++; |
|||
i += MMJSON_rwnum(0,&linebuf[i],&l,2); |
|||
m = (int32_t)l; |
|||
} |
|||
else if ( linebuf[i] == MMJSON_ARRAY32 ) |
|||
{ |
|||
i++; |
|||
i += MMJSON_rwnum(0,&linebuf[i],&l,4); |
|||
m = (int32_t)l; |
|||
} else m = -1; |
|||
if ( m >= 0 ) |
|||
{ |
|||
//printf("%s i.%d m.%d\n",fieldstr,i,m);
|
|||
array = cJSON_CreateArray(); |
|||
for (j=0; j<m; j++) |
|||
{ |
|||
item = cJSON_CreateObject(); |
|||
if ( (i= MMJSON_decodeitem(item,linebuf,i,len,fieldstr,×tamp)) < 0 ) |
|||
{ |
|||
printf("error decoding item ind.%s (%s)\n",fieldstr,jprint(lineobj,0)); |
|||
free_json(array); |
|||
free_json(lineobj); |
|||
return(0); |
|||
} |
|||
obj = jobj(item,fieldstr); |
|||
jaddi(array,jduplicate(obj)); |
|||
free_json(item); |
|||
} |
|||
jadd(lineobj,fieldstr,array); |
|||
} |
|||
else if ( (i= MMJSON_decodeitem(lineobj,linebuf,i,len,fieldstr,×tamp)) < 0 ) |
|||
{ |
|||
printf("error decoding item ind.%s (%s)\n",fieldstr,jprint(lineobj,0)); |
|||
free_json(lineobj); |
|||
return(0); |
|||
} |
|||
//printf("i.%d/%d ind.%d %s valind.%d\n",i,len,ind,MM_fields[ind],linebuf[i]);
|
|||
} |
|||
return(jprint(lineobj,1)); |
|||
} |
|||
|
|||
int32_t MMJSON_encodeval(uint8_t *linebuf,int32_t k,int32_t ind,char *v,uint32_t *timestampp,cJSON *ptr,char *fieldstr) |
|||
{ |
|||
double val; char checkstr[512]; uint64_t l; int32_t valind,len,isstr=0,coinind,j,dots,diff; |
|||
if ( ind >= 0 ) |
|||
{ |
|||
fieldstr = MM_fields[ind]; |
|||
if ( strcmp("utxocoin",fieldstr) == 0 || strcmp("alice",fieldstr) == 0 || strcmp("bob",fieldstr) == 0 || strcmp("base",fieldstr) == 0 || strcmp("rel",fieldstr) == 0 || strcmp("coin",fieldstr) == 0 || strcmp("txfee",fieldstr) == 0 || strcmp("desttxfee",fieldstr) == 0 || strcmp("price64",fieldstr) == 0 || strcmp("satoshis",fieldstr) == 0 || strcmp("destsatoshis",fieldstr) == 0 ) |
|||
isstr = 1; |
|||
else isstr = 0; |
|||
} |
|||
//printf("%s.(%s) k.%d\n",fieldstr,v,k);
|
|||
if ( (valind= mmfind(v)) >= 0 ) |
|||
{ |
|||
linebuf[k++] = valind; |
|||
return(k); |
|||
} |
|||
else if ( strcmp("0",v) == 0 ) |
|||
{ |
|||
if ( isstr != 0 ) |
|||
linebuf[k++] = MMJSON_ZEROSTR; |
|||
else linebuf[k++] = MMJSON_ZERO; |
|||
return(k); |
|||
} |
|||
for (j=dots=0; v[j]!=0; j++) |
|||
{ |
|||
if ( (v[j] < '0' || v[j] > '9') && v[j] != '.' ) |
|||
break; |
|||
else if ( v[j] == '.' ) |
|||
dots++; |
|||
} |
|||
if ( dots == 3 && v[j] == 0 && strlen(v) < 17 && is_ipaddr(v) != 0 ) |
|||
{ |
|||
//printf("<ipaddr> ");
|
|||
linebuf[k++] = MMJSON_IPADDR; |
|||
l = calc_ipbits(v); |
|||
k += MMJSON_rwnum(1,&linebuf[k],&l,4); |
|||
} |
|||
else if ( dots == 1 && v[j] == 0 ) |
|||
{ |
|||
if ( (val= atof(v)) > SMALLVAL ) |
|||
{ |
|||
l = SATOSHIDEN * (val + 0.000000005); |
|||
sprintf(checkstr,"%.8f",dstr(l)); |
|||
if ( strcmp(checkstr,v) == 0 ) |
|||
{ |
|||
//printf("<double> ");
|
|||
linebuf[k++] = MMJSON_DOUBLE; |
|||
k += MMJSON_rwnum(1,&linebuf[k],&l,8); |
|||
} else printf("ERR.<%s %s> ",v,checkstr); |
|||
} |
|||
} |
|||
else if ( (len= is_hexstr(v,0)) == 64 ) |
|||
{ |
|||
//printf("<bits256> ");
|
|||
linebuf[k++] = MMJSON_BITS256; |
|||
decode_hex(&linebuf[k],32,v), k += 32; |
|||
} |
|||
else if ( len == 66 ) |
|||
{ |
|||
//printf("<secp33> ");
|
|||
linebuf[k++] = MMJSON_SECP33; |
|||
decode_hex(&linebuf[k],33,v), k += 33; |
|||
} |
|||
else if ( len == 65*2 ) |
|||
{ |
|||
//printf("<sig> ");
|
|||
linebuf[k++] = MMJSON_SIG; |
|||
decode_hex(&linebuf[k],65,v), k += 65; |
|||
} |
|||
else if ( len == 40 ) |
|||
{ |
|||
//printf("<rmd160> ");
|
|||
linebuf[k++] = MMJSON_RMD160; |
|||
decode_hex(&linebuf[k],20,v), k += 20; |
|||
} |
|||
else if ( len > 40 ) |
|||
{ |
|||
printf("ERR.<hex.%d> ",len/2); |
|||
} |
|||
else if ( is_decimalstr(v) != 0 && (l= calc_nxt64bits(v)) > 0 ) |
|||
{ |
|||
if ( l < 0x100 ) |
|||
{ |
|||
//printf("<decimal8> ");
|
|||
if ( l == 0 ) |
|||
{ |
|||
linebuf[k++] = isstr != 0 ? MMJSON_ZEROSTR : MMJSON_ZERO; |
|||
} |
|||
else |
|||
{ |
|||
linebuf[k++] = isstr != 0 ? MMJSON_DECIMAL8STR : MMJSON_DECIMAL8; |
|||
linebuf[k++] = (uint8_t)l; |
|||
} |
|||
} |
|||
else if ( l < 0x10000 ) |
|||
{ |
|||
//printf("<decimal16> ");
|
|||
linebuf[k++] = isstr != 0 ? MMJSON_DECIMAL16STR : MMJSON_DECIMAL16; |
|||
k += MMJSON_rwnum(1,&linebuf[k],&l,2); |
|||
} |
|||
else if ( l < 0x1000000 ) |
|||
{ |
|||
linebuf[k++] = isstr != 0 ? MMJSON_DECIMAL24STR : MMJSON_DECIMAL24; |
|||
//printf("decimal24 %llu %s (%s) %d\n",(long long)l,v,fieldstr,linebuf[k-1]);
|
|||
k += MMJSON_rwnum(1,&linebuf[k],&l,3); |
|||
} |
|||
else if ( l < 0x100000000LL ) |
|||
{ |
|||
if ( v[0] != '"' && *timestampp == 0 && strcmp(fieldstr,"timestamp") == 0 ) |
|||
{ |
|||
*timestampp = (uint32_t)atol(v); |
|||
//printf("<timestamp> ");
|
|||
linebuf[k++] = MMJSON_TIMESTAMP; |
|||
l = *timestampp; |
|||
k += MMJSON_rwnum(1,&linebuf[k],&l,4); |
|||
} |
|||
else if ( v[0] != '"' && *timestampp != 0 && (diff= ((uint32_t)atol(v)-*timestampp)) < 0x100 && diff >= 0 ) |
|||
{ |
|||
//printf("<timediff.8> ");
|
|||
linebuf[k++] = MMJSON_TIMEDIFF8; |
|||
linebuf[k++] = (uint8_t)diff; |
|||
} |
|||
else if ( v[0] != '"' && *timestampp != 0 && (diff= ((uint32_t)atol(v)-*timestampp)) < 0x10000 && diff >= 0 ) |
|||
{ |
|||
//printf("<timediff.16> ");
|
|||
linebuf[k++] = MMJSON_TIMEDIFF16; |
|||
l = diff; |
|||
k += MMJSON_rwnum(1,&linebuf[k],&l,2); |
|||
} |
|||
else |
|||
{ |
|||
//printf("<decimal32>.%u %08x\n",(uint32_t)l,(uint32_t)l);
|
|||
linebuf[k++] = isstr != 0 ? MMJSON_DECIMAL32STR : MMJSON_DECIMAL32; |
|||
k += MMJSON_rwnum(1,&linebuf[k],&l,4); |
|||
} |
|||
} |
|||
else if ( l < 0x10000000000LL ) |
|||
{ |
|||
//printf("<decimal40> ");
|
|||
linebuf[k++] = isstr != 0 ? MMJSON_DECIMAL40STR : MMJSON_DECIMAL40; |
|||
k += MMJSON_rwnum(1,&linebuf[k],&l,5); |
|||
} |
|||
else if ( l < 0x1000000000000LL ) |
|||
{ |
|||
//printf("<decimal48> ");
|
|||
linebuf[k++] = isstr != 0 ? MMJSON_DECIMAL48STR : MMJSON_DECIMAL48; |
|||
k += MMJSON_rwnum(1,&linebuf[k],&l,6); |
|||
} |
|||
//else if ( l < 0x100000000000000LL )
|
|||
// printf("<decimal56> ");
|
|||
else |
|||
{ |
|||
//printf("<decimal64> ");
|
|||
linebuf[k++] = isstr != 0 ? MMJSON_DECIMAL64STR : MMJSON_DECIMAL64; |
|||
k += MMJSON_rwnum(1,&linebuf[k],&l,8); |
|||
} |
|||
} |
|||
else |
|||
{ |
|||
if ( (ind= mmfind(v)) >= 0 ) |
|||
linebuf[k++] = ind; |
|||
else |
|||
{ |
|||
for (j=0; v[j]!=0; j++) |
|||
{ |
|||
if ( v[j] >= 'a' && v[j] <= 'z' ) |
|||
continue; |
|||
else break; |
|||
} |
|||
if ( v[j] == 0 ) |
|||
{ |
|||
printf("unexpected missing string value.(%s)\n",v); |
|||
//ind = mmadd(v);
|
|||
//printf("%s.<%s>.%d ",s,v,ind);
|
|||
//linebuf[k++] = ind;
|
|||
linebuf[k++] = MMJSON_STRING; |
|||
memcpy(&linebuf[k],v,strlen(v)+1); |
|||
k += (int32_t)strlen(v) + 1; |
|||
} |
|||
else |
|||
{ |
|||
for (j=0; v[j]!=0; j++) |
|||
{ |
|||
if ( v[j] >= 'A' && v[j] <= 'Z' ) |
|||
continue; |
|||
else break; |
|||
} |
|||
if ( v[j] == 0 && (coinind= mmjson_coinfind(v)) >= 0 ) |
|||
{ |
|||
//printf("<coin> ");
|
|||
linebuf[k++] = MMJSON_COIN; |
|||
linebuf[k++] = coinind; |
|||
} |
|||
/*else if ( strlen(v) == 34 )
|
|||
{ |
|||
printf("<coinaddr> "); |
|||
k += 22; |
|||
}*/ |
|||
else |
|||
{ |
|||
linebuf[k++] = MMJSON_STRING; |
|||
if ( v[0] == '"' ) |
|||
{ |
|||
v++; |
|||
v[strlen(v)-1] = 0; |
|||
} |
|||
//printf("str.<%s> ",v);
|
|||
memcpy(&linebuf[k],v,strlen(v)+1); |
|||
k += (int32_t)strlen(v) + 1; |
|||
} |
|||
} |
|||
} |
|||
} |
|||
return(k); |
|||
} |
|||
|
|||
int32_t MMJSON_encode(uint8_t *linebuf,char *line) |
|||
{ |
|||
uint32_t timestamp; uint64_t l; char *decodestr,*s,*v=0; cJSON *lineobj,*array,*ptr; int32_t k=0,m,i,asize,ind,z,allocv_flag; |
|||
timestamp = 0; |
|||
if ( (lineobj= cJSON_Parse(line)) != 0 ) |
|||
{ |
|||
if ( line[strlen(line)-1] == '\n' ) |
|||
line[strlen(line)-1] = 0; |
|||
//printf("%s\n",jprint(lineobj,0));
|
|||
if ( (m= cJSON_GetArraySize(lineobj)) > 0 ) |
|||
{ |
|||
ptr = lineobj->child; |
|||
for (i=0; i<m; i++,ptr=ptr->next) |
|||
{ |
|||
allocv_flag = 0; |
|||
s = jfieldname(ptr); |
|||
if ( (ind= mmfind(s)) < 0 ) |
|||
{ |
|||
printf("missing field.(%s) add to MM_fields[]\n",s); |
|||
linebuf[k++] = MMJSON_STRING; |
|||
memcpy(&linebuf[k],s,strlen(s)+1); |
|||
k += (int32_t)strlen(s) + 1; |
|||
//ind = mmadd(s);
|
|||
} else linebuf[k++] = ind; |
|||
//printf("%s ",s);
|
|||
if ( (array= jobj(lineobj,s)) != 0 && is_cJSON_Array(array) != 0 ) |
|||
{ |
|||
asize = cJSON_GetArraySize(array); |
|||
if ( asize < 0x100 ) |
|||
{ |
|||
linebuf[k++] = MMJSON_ARRAY8; |
|||
linebuf[k++] = asize; |
|||
} |
|||
else if ( asize < 0x10000 ) |
|||
{ |
|||
linebuf[k++] = MMJSON_ARRAY16; |
|||
l = asize; |
|||
k += MMJSON_rwnum(1,&linebuf[k],&l,2); |
|||
} |
|||
else |
|||
{ |
|||
linebuf[k++] = MMJSON_ARRAY32; |
|||
l = asize; |
|||
k += MMJSON_rwnum(1,&linebuf[k],&l,4); |
|||
} |
|||
for (z=0; z<asize; z++) |
|||
{ |
|||
if ( (v= jprint(jitem(array,z),0)) != 0 ) |
|||
{ |
|||
//printf("%d.(%s k.%d).%d ",z,v,k,asize);
|
|||
k = MMJSON_encodeval(linebuf,k,ind,v,×tamp,ptr,s); |
|||
free(v); |
|||
} else printf("ERROR.(%s) ",jprint(jitem(array,z),0)); |
|||
} |
|||
//printf("%s array.%d k.%d\n",fieldstr,asize,k);
|
|||
continue; |
|||
} |
|||
else if ( (v= jstr(lineobj,s)) == 0 ) |
|||
{ |
|||
v = jprint(jobj(lineobj,s),0); |
|||
//printf("allocate v.%p\n",v);
|
|||
allocv_flag = 1; |
|||
} |
|||
if ( v != 0 ) |
|||
{ |
|||
//printf("%s\n",v);
|
|||
k = MMJSON_encodeval(linebuf,k,ind,v,×tamp,ptr,s); |
|||
} |
|||
else printf("ERROR.(%s) ",jprint(jobj(lineobj,s),0)); |
|||
if ( allocv_flag != 0 && v != 0 ) |
|||
{ |
|||
//printf("free allocated v\n");
|
|||
free(v); |
|||
} |
|||
//printf("m.%d values\n",m);
|
|||
} |
|||
} |
|||
free_json(lineobj); |
|||
if ( (decodestr= MMJSON_decode(linebuf,k)) == 0 || strcmp(decodestr,line) != 0 ) |
|||
{ |
|||
for (i=0; i<k; i++) |
|||
printf("%d ",linebuf[i]); |
|||
printf(" k.%d error decoding (%s) -> (%s)\n",k,line,decodestr==0?"":decodestr); |
|||
if ( decodestr != 0 ) |
|||
free(decodestr); |
|||
return(-1); |
|||
} //else printf("decoded\n");
|
|||
free(decodestr); |
|||
} |
|||
return(k); |
|||
} |
|||
|
|||
#ifndef FROM_MARKETMAKER |
|||
#define packetout "/Users/mac/mmjson/packet.out" |
|||
#define packetlog "/Users/mac/mmjson/packet.log" |
|||
|
|||
int main(int argc, const char * argv[]) |
|||
{ |
|||
FILE *fp,*outfp; uint8_t linebuf[8192]; char line[8192],str[65]; int32_t i,k,compressed=0,n=0,total = 0; |
|||
outfp = fopen(packetout,"wb"); |
|||
if ( (fp= fopen(packetlog,"rb")) != 0 ) |
|||
{ |
|||
while ( fgets(line,sizeof(line),fp) > 0 ) |
|||
{ |
|||
n++; |
|||
total += strlen(line); |
|||
if ( (k= MMJSON_encode(linebuf,line)) > 0 ) |
|||
{ |
|||
//printf("\n");
|
|||
if ( outfp != 0 ) |
|||
fwrite(linebuf,1,k,outfp); |
|||
compressed += k; |
|||
} |
|||
else |
|||
{ |
|||
compressed += strlen(line); |
|||
//printf("error parsing.(%s)\n",line);
|
|||
} |
|||
} |
|||
fclose(fp); |
|||
if ( outfp != 0 ) |
|||
{ |
|||
uint8_t *data,*bits; int32_t numbits; bits256 seed; long fsize = ftell(outfp); |
|||
fclose(outfp); |
|||
if ( (0) && (outfp= fopen(packetout,"rb")) != 0 ) |
|||
{ |
|||
data = calloc(1,fsize); |
|||
bits = calloc(1,fsize); |
|||
if ( fread(data,1,fsize,outfp) == fsize ) |
|||
{ |
|||
memset(seed.bytes,0,sizeof(seed)); |
|||
decode_hex(seed.bytes,32,"ffffff070000810478800084000800b200101400002001400404844402d29fc4"); |
|||
numbits = ramcoder_compress(bits,(int32_t)fsize,data,(int32_t)fsize,seed); |
|||
fclose(outfp); |
|||
printf("numbits.%d %d bytes %.1f seed.%s\n",numbits,numbits/8+1,(double)compressed/(numbits/8),bits256_str(str,seed)); |
|||
} |
|||
} |
|||
} |
|||
} else printf("cant find packet.log\n"); |
|||
printf("char *MM_fields[256] = \n{\n"); |
|||
for (i=0; i<MM_numfields; i++) |
|||
printf("\"%s\", ",MM_fields[i]); |
|||
printf("\n};\nnumlines.%d size %d compressed.%d %.3f maxind.%d\n",n,total,compressed,(double)total/compressed,MM_numfields); |
|||
} |
|||
#endif |
@ -0,0 +1,2 @@ |
|||
source userpass |
|||
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"autoprice\",\"base\":\"CHIPS\",\"rel\":\"BTC\",\"margin\":0.01,\"refbase\":\"chips\",\"refrel\":\"coinmarketcap\"}" |
@ -0,0 +1,2 @@ |
|||
source userpass |
|||
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"autoprice\",\"base\":\"CHIPS\",\"rel\":\"KMD\",\"margin\":0.01,\"refbase\":\"chips\",\"refrel\":\"coinmarketcap\"}" |
@ -1,3 +0,0 @@ |
|||
#!/bin/bash |
|||
source userpass |
|||
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"autofill\",\"base\":\"KMD\",\"rel\":\"BTC\",\"price\":0.0005,\"relvolume\":0.1}" |
@ -1,3 +0,0 @@ |
|||
#!/bin/bash |
|||
source userpass |
|||
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"autotrade\",\"base\":\"REVS\",\"rel\":\"KMD\",\"relvolume\":1.01,\"price\":1.234}" |
@ -0,0 +1,3 @@ |
|||
#!/bin/bash |
|||
source userpass |
|||
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"balances\"}" |
@ -0,0 +1,4 @@ |
|||
#!/bin/bash |
|||
source userpass |
|||
# this will only work for watchonly addresses that have been rescanned and with active coins |
|||
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"fundvalue\",\"address\":\"RNdqHx26GWy9bk8MtmH1UiXjQcXE4RKK2P\",\"divisor\":1000000}" |
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -0,0 +1,4 @@ |
|||
#!/bin/bash |
|||
source userpass |
|||
# this will only work for watchonly addresses that have been rescanned and with active coins |
|||
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"fundvalue\",\"address\":\"RThtXup6Zo7LZAi8kRWgjAyi1s4u6U9Cpf\",\"divisor\":1000000}" |
@ -1,5 +1,15 @@ |
|||
#!/bin/bash |
|||
source userpass |
|||
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"REVS\"}" |
|||
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"CHIPS\"}" |
|||
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"MNZ\"}" |
|||
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"KMD\"}" |
|||
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"BTC\"}" |
|||
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"SUPERNET\"}" |
|||
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"CRYPTO\"}" |
|||
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"DEX\"}" |
|||
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"BOTS\"}" |
|||
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"BET\"}" |
|||
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"HODL\"}" |
|||
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"MSHARK\"}" |
|||
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"MGW\"}" |
|||
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"PANGEA\"}" |
|||
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"JUMBLR\"}" |
|||
|
@ -0,0 +1,4 @@ |
|||
#!/bin/bash |
|||
source userpass |
|||
# this will only work for watchonly addresses that have been rescanned and with active coins |
|||
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"fundvalue\",\"address\":\"RRyyejME7LRTuvdziWsXkAbSW1fdiohGwK\",\"holdings\":[{\"coin\":\"iota\",\"balance\":13000000}, {\"coin\":\"stratis\",\"balance\":1300000}, {\"coin\":\"zcash\",\"balance\":10000}, {\"coin\":\"syscoin\",\"balance\":20000000}, {\"coin\":\"waves\",\"balance\":700000}, {\"coin\":\"bitcoin\",\"balance\":625}, {\"coin\":\"bitcoin-cash\",\"balance\":1500}, {\"coin\":\"heat-ledger\",\"balance\":2323851 }, {\"coin\":\"decred\",\"balance\":20000}, {\"coin\":\"vericoin\",\"balance\":2199368 }, {\"coin\":\"byteball\",\"balance\":4238}, {\"coin\":\"iocoin\",\"balance\":150000}, {\"coin\":\"quantum-resistant-ledger\",\"balance\":375000}, {\"coin\":\"chips\",\"balance\":2577006 }, {\"coin\":\"hush\",\"balance\":100000 }, {\"coin\":\"mobilego\",\"balance\":100000 }],\"divisor\":650000}" |
@ -0,0 +1,15 @@ |
|||
#!/bin/bash |
|||
source userpass |
|||
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"getprice\",\"base\":\"REVS\",\"rel\":\"KMD\"}" |
|||
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"getprice\",\"base\":\"CHIPS\",\"rel\":\"KMD\"}" |
|||
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"getprice\",\"base\":\"KMD\",\"rel\":\"BTC\"}" |
|||
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"getprice\",\"base\":\"SUPERNET\",\"rel\":\"KMD\"}" |
|||
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"getprice\",\"base\":\"CRYPTO\",\"rel\":\"KMD\"}" |
|||
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"getprice\",\"base\":\"DEX\",\"rel\":\"KMD\"}" |
|||
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"getprice\",\"base\":\"BOTS\",\"rel\":\"KMD\"}" |
|||
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"getprice\",\"base\":\"BET\",\"rel\":\"KMD\"}" |
|||
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"getprice\",\"base\":\"HODL\",\"rel\":\"KMD\"}" |
|||
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"getprice\",\"base\":\"MSHARK\",\"rel\":\"KMD\"}" |
|||
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"getprice\",\"base\":\"MGW\",\"rel\":\"KMD\"}" |
|||
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"getprice\",\"base\":\"PANGEA\",\"rel\":\"KMD\"}" |
|||
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"getprice\",\"base\":\"JUMBLR\",\"rel\":\"KMD\"}" |
@ -0,0 +1,4 @@ |
|||
#!/bin/bash |
|||
source userpass |
|||
# this will only work for watchonly addresses that have been rescanned and with active coins |
|||
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"fundvalue\",\"address\":\"RNcUaMUEFLxVwtTo7rgruhwYanGk1jTkeU\",\"holdings\":[{\"coin\":\"siacoin\",\"balance\":185000000,\"comment\":\"using siafunds equal to million siacoin\"}],\"divisor\":10000000}" |
@ -0,0 +1,4 @@ |
|||
#!/bin/bash |
|||
source userpass |
|||
# this will only work for watchonly addresses that have been rescanned and with active coins |
|||
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"fundvalue\",\"address\":\"RGhxXpXSSBTBm9EvNsXnTQczthMCxHX91t\",\"divisor\":1000000}" |
@ -0,0 +1,943 @@ |
|||
/******************************************************************************
|
|||
* Copyright © 2014-2017 The SuperNET Developers. * |
|||
* * |
|||
* See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at * |
|||
* the top-level directory of this distribution for the individual copyright * |
|||
* holder information and the developer policies on copyright and licensing. * |
|||
* * |
|||
* Unless otherwise agreed in a custom licensing agreement, no part of the * |
|||
* SuperNET software, including this file may be copied, modified, propagated * |
|||
* or distributed except according to the terms contained in the LICENSE file * |
|||
* * |
|||
* Removal or modification of this copyright notice is prohibited. * |
|||
* * |
|||
******************************************************************************/ |
|||
//
|
|||
// main.c
|
|||
// marketmaker
|
|||
//
|
|||
// Copyright © 2017 SuperNET. All rights reserved.
|
|||
//
|
|||
|
|||
|
|||
void PNACL_message(char *arg,...) |
|||
{ |
|||
|
|||
} |
|||
#define FROM_MARKETMAKER |
|||
|
|||
#include <stdio.h> |
|||
#include <stdint.h> |
|||
#ifndef NATIVE_WINDOWS |
|||
#include "OS_portable.h" |
|||
#else |
|||
#include "../../crypto777/OS_portable.h" |
|||
#endif // !_WIN_32
|
|||
|
|||
uint32_t DOCKERFLAG; |
|||
#define MAX(a,b) ((a) > (b) ? (a) : (b)) |
|||
char *stats_JSON(void *ctx,char *myipaddr,int32_t pubsock,cJSON *argjson,char *remoteaddr,uint16_t port); |
|||
#include "stats.c" |
|||
void LP_priceupdate(char *base,char *rel,double price,double avebid,double aveask,double highbid,double lowask,double PAXPRICES[32]); |
|||
|
|||
//defined(__APPLE__) ||
|
|||
#ifdef FROM_JS // defined(WIN32) || defined(USE_STATIC_NANOMSG)
|
|||
#include "../../crypto777/nanosrc/nn.h" |
|||
#include "../../crypto777/nanosrc/bus.h" |
|||
#include "../../crypto777/nanosrc/pubsub.h" |
|||
#include "../../crypto777/nanosrc/pipeline.h" |
|||
#include "../../crypto777/nanosrc/reqrep.h" |
|||
#include "../../crypto777/nanosrc/tcp.h" |
|||
#include "../../crypto777/nanosrc/pair.h" |
|||
#else |
|||
#if defined(WIN32) || defined(USE_STATIC_NANOMSG) |
|||
#include "../../crypto777/nanosrc/nn.h" |
|||
#include "../../crypto777/nanosrc/bus.h" |
|||
#include "../../crypto777/nanosrc/pubsub.h" |
|||
#include "../../crypto777/nanosrc/pipeline.h" |
|||
#include "../../crypto777/nanosrc/reqrep.h" |
|||
#include "../../crypto777/nanosrc/tcp.h" |
|||
#include "../../crypto777/nanosrc/pair.h" |
|||
#else |
|||
#include "/usr/local/include/nanomsg/nn.h" |
|||
#include "/usr/local/include/nanomsg/bus.h" |
|||
#include "/usr/local/include/nanomsg/pubsub.h" |
|||
#include "/usr/local/include/nanomsg/pipeline.h" |
|||
#include "/usr/local/include/nanomsg/reqrep.h" |
|||
#include "/usr/local/include/nanomsg/tcp.h" |
|||
#include "/usr/local/include/nanomsg/pair.h" |
|||
#endif |
|||
#endif |
|||
|
|||
char DEX_baseaddr[64],DEX_reladdr[64]; |
|||
struct mmpending_order |
|||
{ |
|||
double price,volume; |
|||
int32_t dir; |
|||
uint32_t pending,completed,canceled,cancelstarted,reported; |
|||
cJSON *errorjson; |
|||
char exchange[16],base[65],rel[65],orderid[64]; |
|||
} *Pending_orders; |
|||
int32_t Num_Pending; |
|||
|
|||
#define IGUANA_URL "http://127.0.0.1:7778"
|
|||
|
|||
/*char CURRENCIES[][8] = { "USD", "EUR", "JPY", "GBP", "AUD", "CAD", "CHF", "NZD", // major currencies
|
|||
"CNY", "RUB", "MXN", "BRL", "INR", "HKD", "TRY", "ZAR", "PLN", "NOK", "SEK", "DKK", "CZK", "HUF", "ILS", "KRW", "MYR", "PHP", "RON", "SGD", "THB", "BGN", "IDR", "HRK", // end of currencies
|
|||
};*/ |
|||
double PAXPRICES[sizeof(CURRENCIES)/sizeof(*CURRENCIES)]; |
|||
uint32_t PAXACTIVE; |
|||
|
|||
char *DEX_swapstatus() |
|||
{ |
|||
char url[512],postdata[1024]; |
|||
sprintf(url,"%s/?",IGUANA_URL); |
|||
sprintf(postdata,"{\"agent\":\"InstantDEX\",\"method\":\"getswaplist\"}"); |
|||
return(bitcoind_RPC(0,"InstantDEX",url,0,"getswaplist",postdata,0)); |
|||
} |
|||
|
|||
char *DEX_amlp(char *blocktrail) |
|||
{ |
|||
char url[512],postdata[1024]; |
|||
sprintf(url,"%s/?",IGUANA_URL); |
|||
sprintf(postdata,"{\"agent\":\"tradebot\",\"method\":\"amlp\",\"blocktrail\":\"%s\"}",blocktrail); |
|||
return(bitcoind_RPC(0,"tradebot",url,0,"amlp",postdata,0)); |
|||
} |
|||
|
|||
char *DEX_openorders(char *exchange) |
|||
{ |
|||
char url[512],postdata[1024]; |
|||
sprintf(url,"%s/?",IGUANA_URL); |
|||
sprintf(postdata,"{\"agent\":\"InstantDEX\",\"method\":\"openorders\",\"exchange\":\"%s\"}",exchange); |
|||
return(bitcoind_RPC(0,"InstantDEX",url,0,"openorders",postdata,0)); |
|||
} |
|||
|
|||
char *DEX_tradehistory(char *exchange) |
|||
{ |
|||
char url[512],postdata[1024]; |
|||
sprintf(url,"%s/?",IGUANA_URL); |
|||
sprintf(postdata,"{\"agent\":\"InstantDEX\",\"method\":\"tradehistory\",\"exchange\":\"%s\"}",exchange); |
|||
return(bitcoind_RPC(0,"InstantDEX",url,0,"tradehistory",postdata,0)); |
|||
} |
|||
|
|||
char *DEX_orderstatus(char *exchange,char *orderid) |
|||
{ |
|||
char url[512],postdata[1024]; |
|||
sprintf(url,"%s/?",IGUANA_URL); |
|||
sprintf(postdata,"{\"agent\":\"InstantDEX\",\"method\":\"orderstatus\",\"exchange\":\"%s\",\"orderid\":\"%s\"}",exchange,orderid); |
|||
return(bitcoind_RPC(0,"InstantDEX",url,0,"orderstatus",postdata,0)); |
|||
} |
|||
|
|||
char *DEX_cancelorder(char *exchange,char *orderid) |
|||
{ |
|||
char url[512],postdata[1024]; |
|||
sprintf(url,"%s/?",IGUANA_URL); |
|||
sprintf(postdata,"{\"agent\":\"InstantDEX\",\"method\":\"cancelorder\",\"exchange\":\"%s\",\"orderid\":\"%s\"}",exchange,orderid); |
|||
return(bitcoind_RPC(0,"InstantDEX",url,0,"cancelorder",postdata,0)); |
|||
} |
|||
|
|||
char *DEX_balance(char *exchange,char *base,char *coinaddr) |
|||
{ |
|||
char url[512],postdata[1024]; |
|||
sprintf(url,"%s/?",IGUANA_URL); |
|||
if ( strcmp(exchange,"DEX") == 0 ) |
|||
{ |
|||
sprintf(postdata,"{\"agent\":\"dex\",\"method\":\"getbalance\",\"address\":\"%s\",\"symbol\":\"%s\"}",coinaddr,base); |
|||
return(bitcoind_RPC(0,"dex",url,0,"getbalance",postdata,0)); |
|||
} |
|||
else |
|||
{ |
|||
sprintf(postdata,"{\"agent\":\"InstantDEX\",\"method\":\"balance\",\"exchange\":\"%s\",\"base\":\"%s\"}",exchange,base); |
|||
return(bitcoind_RPC(0,"InstantDEX",url,0,"balance",postdata,0)); |
|||
} |
|||
} |
|||
|
|||
char *DEX_apikeypair(char *exchange,char *apikey,char *apisecret) |
|||
{ |
|||
char url[512],postdata[1024]; |
|||
sprintf(url,"%s/?",IGUANA_URL); |
|||
sprintf(postdata,"{\"agent\":\"InstantDEX\",\"method\":\"apikeypair\",\"exchange\":\"%s\",\"apikey\":\"%s\",\"apisecret\":\"%s\"}",exchange,apikey,apisecret); |
|||
return(bitcoind_RPC(0,"InstantDEX",url,0,"apikeypair",postdata,0)); |
|||
} |
|||
|
|||
char *DEX_setuserid(char *exchange,char *userid,char *tradepassword) |
|||
{ |
|||
char url[512],postdata[1024]; |
|||
sprintf(url,"%s/?",IGUANA_URL); |
|||
sprintf(postdata,"{\"agent\":\"InstantDEX\",\"method\":\"setuserid\",\"exchange\":\"%s\",\"userid\":\"%s\",\"tradepassword\":\"%s\"}",exchange,userid,tradepassword); |
|||
return(bitcoind_RPC(0,"InstantDEX",url,0,"setuserid",postdata,0)); |
|||
} |
|||
|
|||
char *DEX_trade(char *exchange,char *base,char *rel,int32_t dir,double price,double volume) |
|||
{ |
|||
char url[512],postdata[1024]; |
|||
sprintf(url,"%s/?",IGUANA_URL); |
|||
sprintf(postdata,"{\"agent\":\"InstantDEX\",\"method\":\"%s\",\"exchange\":\"%s\",\"base\":\"%s\",\"rel\":\"%s\",\"price\":%.8f,\"volume\":%.8f,\"dotrade\":1}",dir>0?"buy":"sell",exchange,base,rel,price,volume); |
|||
//printf("DEX_trade.(%s)\n",postdata);
|
|||
return(bitcoind_RPC(0,"InstantDEX",url,0,dir>0?"buy":"sell",postdata,0)); |
|||
} |
|||
|
|||
char *DEX_withdraw(char *exchange,char *base,char *destaddr,double amount) |
|||
{ |
|||
char url[512],postdata[1024]; |
|||
sprintf(url,"%s/?",IGUANA_URL); |
|||
sprintf(postdata,"{\"agent\":\"InstantDEX\",\"method\":\"withdraw\",\"exchange\":\"%s\",\"destaddr\":\"%s\",\"amount\":%.8f}",exchange,destaddr,amount); |
|||
return(bitcoind_RPC(0,"InstantDEX",url,0,"withdraw",postdata,0)); |
|||
} |
|||
|
|||
char *iguana_walletpassphrase(char *passphrase,int32_t timeout) |
|||
{ |
|||
char url[512],postdata[1024]; |
|||
sprintf(url,"%s/coin=KMD&agent=bitcoinrpc&method=walletpassphrase?",IGUANA_URL); |
|||
sprintf(postdata,"[\"%s\", %d]",passphrase,timeout); |
|||
return(bitcoind_RPC(0,"",url,0,"walletpassphrase",postdata,0)); |
|||
} |
|||
|
|||
/*char *iguana_listunspent(char *coin,char *coinaddr)
|
|||
{ |
|||
char url[512],postdata[1024]; |
|||
sprintf(url,"%s/coin=%s&agent=bitcoinrpc&method=listunspent?",IGUANA_URL,coin); |
|||
sprintf(postdata,"[\"%s\"]",coinaddr); |
|||
return(bitcoind_RPC(0,"",url,0,"listunspent",postdata)); |
|||
}*/ |
|||
|
|||
/*char *issue_LP_intro(char *destip,uint16_t destport,char *ipaddr,uint16_t port,int32_t numpeers)
|
|||
{ |
|||
char url[512]; |
|||
sprintf(url,"http://%s:%u/api/stats/intro?ipaddr=%s&port=%u&numpeers=%d",destip,destport,ipaddr,port,numpeers); |
|||
printf("(%s)\n",url); |
|||
return(issue_curl(url)); |
|||
}*/ |
|||
|
|||
//
|
|||
// http://127.0.0.1:7779/api/stats/getpeers
|
|||
|
|||
char *DEX_listunspent(char *coin,char *coinaddr) |
|||
{ |
|||
char url[512],postdata[1024]; |
|||
sprintf(url,"%s/?",IGUANA_URL); |
|||
sprintf(postdata,"{\"agent\":\"dex\",\"method\":\"listunspent\",\"address\":\"%s\",\"symbol\":\"%s\",\"timeout\":60000}",coinaddr,coin); |
|||
return(bitcoind_RPC(0,"dex",url,0,"listunspent",postdata,0)); |
|||
} |
|||
|
|||
bits256 iguana_wif2privkey(char *wifstr) |
|||
{ |
|||
char url[512],postdata[1024],*retstr,*privstr; bits256 privkey; cJSON *retjson; |
|||
memset(privkey.bytes,0,sizeof(privkey)); |
|||
sprintf(url,"%s/?",IGUANA_URL); |
|||
sprintf(postdata,"{\"agent\":\"SuperNET\",\"method\":\"wif2priv\",\"wif\":\"%s\"}",wifstr); |
|||
if ( (retstr= bitcoind_RPC(0,"SuperNET",url,0,"wif2priv",postdata,0)) != 0 ) |
|||
{ |
|||
if ( (retjson= cJSON_Parse(retstr)) != 0 ) |
|||
{ |
|||
if ( (privstr= jstr(retjson,"privkey")) != 0 ) |
|||
{ |
|||
if ( strlen(privstr) == 64 ) |
|||
decode_hex(privkey.bytes,32,privstr); |
|||
} |
|||
free_json(retjson); |
|||
} |
|||
free(retstr); |
|||
} |
|||
return(privkey); |
|||
} |
|||
|
|||
double bittrex_balance(char *base,char *coinaddr) |
|||
{ |
|||
char *retstr; cJSON *retjson; double balance = 0.; |
|||
if ( (retstr= DEX_balance("bittrex",base,coinaddr)) != 0 ) |
|||
{ |
|||
if ( (retjson= cJSON_Parse(retstr)) != 0 ) |
|||
{ |
|||
balance = jdouble(retjson,"balance"); |
|||
free_json(retjson); |
|||
} |
|||
free(retstr); |
|||
} |
|||
return(balance); |
|||
} |
|||
|
|||
double dex_balance(char *base,char *coinaddr) |
|||
{ |
|||
char *retstr; cJSON *retjson; double balance = 0.; |
|||
if ( (retstr= DEX_balance("DEX",base,coinaddr)) != 0 ) |
|||
{ |
|||
if ( (retjson= cJSON_Parse(retstr)) != 0 ) |
|||
{ |
|||
balance = jdouble(retjson,"balance"); |
|||
free_json(retjson); |
|||
} |
|||
free(retstr); |
|||
} |
|||
return(balance); |
|||
} |
|||
|
|||
int32_t komodo_baseid(char *base) |
|||
{ |
|||
int32_t i; |
|||
for (i=0; i<sizeof(CURRENCIES)/sizeof(*CURRENCIES); i++) |
|||
if ( strcmp(base,CURRENCIES[i]) == 0 ) |
|||
return(i); |
|||
return(-1); |
|||
} |
|||
|
|||
cJSON *yahoo_allcurrencies() |
|||
{ |
|||
char *retstr; cJSON *retjson = 0; |
|||
if ( (retstr= issue_curl("http://finance.yahoo.com/webservice/v1/symbols/allcurrencies/quote?format=json")) != 0 ) |
|||
{ |
|||
retjson = cJSON_Parse(retstr); |
|||
free(retstr); |
|||
} |
|||
return(retjson); |
|||
} |
|||
|
|||
void _marketmaker_fiatupdate(int32_t baseid,double price) |
|||
{ |
|||
PAXPRICES[baseid] = price * PAXPRICES[0]; |
|||
printf("%.6f %s per USD, %.8f %s per KMD\n",price,CURRENCIES[baseid],PAXPRICES[baseid],CURRENCIES[baseid]); |
|||
} |
|||
|
|||
uint32_t marketmaker_fiatupdate(cJSON *fiatjson) |
|||
{ |
|||
int32_t i,n,baseid; cJSON *item,*array; double price; char *name; uint64_t mask = 0; |
|||
fiatjson = jobj(fiatjson,"list"); |
|||
if ( fiatjson != 0 && (array= jarray(&n,fiatjson,"resources")) > 0 ) |
|||
{ |
|||
for (i=0; i<n; i++) |
|||
{ |
|||
/*
|
|||
"resource" : { |
|||
"classname" : "Quote", |
|||
"fields" : { |
|||
"name" : "USD/BRX", |
|||
"price" : "3.063200", |
|||
"symbol" : "BRX=X", |
|||
"ts" : "1487866204", |
|||
"type" : "currency", |
|||
"utctime" : "2017-02-23T16:10:04+0000", |
|||
"volume" : "0" |
|||
} |
|||
*/ |
|||
item = jitem(array,i); |
|||
if ( (item= jobj(item,"resource")) != 0 ) |
|||
item = jobj(item,"fields"); |
|||
if ( item != 0 ) |
|||
{ |
|||
price = jdouble(item,"price"); |
|||
if ( price > SMALLVAL && (name= jstr(item,"name")) != 0 && strncmp(name,"USD/",4) == 0 ) |
|||
{ |
|||
if ( (baseid= komodo_baseid(name+4)) >= 0 && baseid < 32 ) |
|||
{ |
|||
if ( ((1LL << baseid) & mask) == 0 ) |
|||
{ |
|||
_marketmaker_fiatupdate(baseid,price); |
|||
mask |= (1LL << baseid); |
|||
} else if ( fabs(price*PAXPRICES[0] - PAXPRICES[baseid]) > SMALLVAL ) |
|||
printf("DUPLICATE PRICE? %s %.8f vs %.8f\n",name+4,price*PAXPRICES[0],PAXPRICES[baseid]); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
printf("pax mask.%x\n",(uint32_t)mask); |
|||
return((uint32_t)mask); |
|||
} |
|||
|
|||
void marketmaker_cancel(struct mmpending_order *ptr) |
|||
{ |
|||
char *retstr; cJSON *retjson; |
|||
if ( ptr->pending != 0 && ptr->cancelstarted == 0 ) |
|||
{ |
|||
ptr->cancelstarted = (uint32_t)time(NULL); |
|||
if ( (retstr= DEX_cancelorder(ptr->exchange,ptr->orderid)) != 0 ) |
|||
{ |
|||
if ( (retjson= cJSON_Parse(retstr)) != 0 ) |
|||
{ |
|||
printf("cancel %s (%s/%s) %.8f vol %.8f dir.%d -> (%s)\n",ptr->exchange,ptr->base,ptr->rel,ptr->price,ptr->volume,ptr->dir,jprint(retjson,0)); |
|||
free_json(retjson); |
|||
ptr->pending = 0; |
|||
ptr->canceled = (uint32_t)time(NULL); |
|||
} |
|||
free(retstr); |
|||
} |
|||
} |
|||
} |
|||
|
|||
void marketmaker_queue(char *exchange,char *base,char *rel,int32_t dir,double price,double volume,cJSON *retjson) |
|||
{ |
|||
struct mmpending_order *ptr; char *orderid; |
|||
//DEX_trade.({"success":true,"message":"","result":{"uuid":"d5faa9e4-660d-436f-a257-2c6a40442d8c"},"tag":"11271578410079391025"}
|
|||
if ( is_cJSON_True(jobj(retjson,"success")) != 0 && jobj(retjson,"result") != 0 ) |
|||
retjson = jobj(retjson,"result"); |
|||
printf("QUEUE.%s %s/%s dir.%d %.8f %.6f (%s)\n",exchange,base,rel,dir,price,volume,jprint(retjson,0)); |
|||
Pending_orders = realloc(Pending_orders,(1 + Num_Pending) * sizeof(*Pending_orders)); |
|||
ptr = &Pending_orders[Num_Pending++]; |
|||
memset(ptr,0,sizeof(*ptr)); |
|||
ptr->price = price; |
|||
ptr->volume = volume; |
|||
ptr->dir = dir; |
|||
ptr->pending = (uint32_t)time(NULL); |
|||
strcpy(ptr->exchange,exchange); |
|||
strcpy(ptr->base,base); |
|||
strcpy(ptr->rel,rel); |
|||
if ( (orderid= jstr(retjson,"OrderUuid")) != 0 || (orderid= jstr(retjson,"uuid")) != 0 ) |
|||
strcpy(ptr->orderid,orderid); |
|||
else strcpy(ptr->orderid,"0"); |
|||
} |
|||
|
|||
void marketmaker_pendingupdate(char *exchange,char *base,char *rel) |
|||
{ |
|||
char *retstr; cJSON *retjson,*obj; int32_t i; struct mmpending_order *ptr; |
|||
for (i=0; i<Num_Pending; i++) |
|||
{ |
|||
ptr = &Pending_orders[i]; |
|||
if ( strcmp(exchange,ptr->exchange) != 0 || strcmp(base,ptr->base) != 0 || strcmp(rel,ptr->rel) != 0 ) |
|||
continue; |
|||
if ( ptr->completed == 0 && (retstr= DEX_orderstatus(exchange,ptr->orderid)) != 0 ) |
|||
{ |
|||
//printf("%s status.(%s)\n",ptr->orderid,retstr);
|
|||
if ( (retjson= cJSON_Parse(retstr)) != 0 ) |
|||
{ |
|||
obj = jobj(retjson,"result"); |
|||
if ( is_cJSON_Array(obj) != 0 ) |
|||
obj = jitem(retjson,0); |
|||
if ( jdouble(obj,"QuantityRemaining") == 0. || is_cJSON_True(jobj(obj,"IsOpen")) == 0 ) |
|||
{ |
|||
//{"Uuid":null,"OrderUuid":"e7b0789c-0c4e-413b-a768-3d5734d9cbe5","Exchange":"BTC-KMD","OrderType":"LIMIT_SELL","Quantity":877.77700000,"QuantityRemaining":462.50512234,"Limit":0.00011770,"CommissionPaid":0.00012219,"Price":0.04887750,"PricePerUnit":0.00011769,"Opened":"2017-02-20T13:16:22.29","Closed":null,"CancelInitiated":false,"ImmediateOrCancel":false,"IsConditional":false,"Condition":"NONE","ConditionTarget":null} printf("uuid.(%s) finished.(%s)\n",ptr->orderid,jprint(retjson,0));
|
|||
ptr->completed = (uint32_t)time(NULL); |
|||
ptr->pending = 0; |
|||
} |
|||
free_json(retjson); |
|||
} |
|||
free(retstr); |
|||
} |
|||
} |
|||
} |
|||
|
|||
void marketmaker_pendinginit(char *exchange,char *base,char *rel) |
|||
{ |
|||
char *retstr,*orderid,*pairstr,relbase[65]; cJSON *retjson,*array,*item; int32_t i,j,n,dir; struct mmpending_order *ptr; |
|||
sprintf(relbase,"%s-%s",rel,base); |
|||
if ( (retstr= DEX_openorders(exchange)) != 0 ) |
|||
{ |
|||
if ( (retjson= cJSON_Parse(retstr)) != 0 ) |
|||
{ |
|||
//printf("%s\n",jprint(retjson,0));
|
|||
if ( is_cJSON_True(jobj(retjson,"success")) != 0 && (array= jarray(&n,retjson,"result")) != 0 ) |
|||
{ |
|||
for (i=0; i<n; i++) |
|||
{ |
|||
item = jitem(array,i); |
|||
if ( (pairstr= jstr(item,"Exchange")) == 0 ) |
|||
continue; |
|||
if ( strcmp(pairstr,relbase) != 0 ) |
|||
{ |
|||
printf("skip %s when %s\n",pairstr,relbase); |
|||
continue; |
|||
} |
|||
//printf("(%s)\n",jprint(item,0));
|
|||
//{"success":true,"message":"","result":[{"Uuid":null,"OrderUuid":"81ad3e37-65d4-4fee-9c29-03b050f5192b","Exchange":"BTC-KMD","OrderType":"LIMIT_BUY","Quantity":885.19934578,"QuantityRemaining":885.19934578,"Limit":0.00011184,"CommissionPaid":0,"Price":0,"PricePerUnit":null,"Opened":"2017-02-19T19:14:02.94","Closed":null,"CancelInitiated":false,"ImmediateOrCancel":false,"IsConditional":false,"Condition":"NONE","ConditionTarget":null}],"tag":"10056789044100011414"}
|
|||
if ( (orderid= jstr(item,"OrderUuid")) != 0 && is_cJSON_Null(jobj(item,"Closed")) != 0 && is_cJSON_False(jobj(item,"CancelInitiated")) != 0 ) |
|||
{ |
|||
for (j=0; j<Num_Pending; j++) |
|||
{ |
|||
ptr = &Pending_orders[j]; |
|||
if ( strcmp(exchange,ptr->exchange) != 0 || strcmp(base,ptr->base) != 0 || strcmp(rel,ptr->rel) != 0 ) |
|||
continue; |
|||
if ( strcmp(ptr->orderid,orderid) == 0 ) |
|||
{ |
|||
ptr->pending = (uint32_t)time(NULL); |
|||
ptr->completed = 0; |
|||
printf("%s pending\n",orderid); |
|||
break; |
|||
} |
|||
} |
|||
if ( j == Num_Pending ) |
|||
{ |
|||
if ( jstr(item,"OrderType") != 0 ) |
|||
{ |
|||
if ( strcmp(jstr(item,"OrderType"),"LIMIT_BUY") == 0 ) |
|||
dir = 1; |
|||
else if ( strcmp(jstr(item,"OrderType"),"LIMIT_SELL") == 0 ) |
|||
dir = -1; |
|||
else dir = 0; |
|||
if ( dir != 0 ) |
|||
marketmaker_queue(exchange,base,rel,dir,jdouble(item,"Limit"),jdouble(item,"QuantityRemaining"),item); |
|||
else printf("no dir (%s) (%s)\n",jprint(item,0),jstr(item,"OrderType")); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
free_json(retjson); |
|||
} |
|||
free(retstr); |
|||
} |
|||
} |
|||
|
|||
double marketmaker_filled(char *exchange,char *base,char *rel,double *buyvolp,double *sellvolp,double *pendingbidsp,double *pendingasksp) |
|||
{ |
|||
double pricesum = 0.,volsum = 0.; struct mmpending_order *ptr; int32_t i; |
|||
*pendingbidsp = *pendingasksp = 0.; |
|||
for (i=0; i<Num_Pending; i++) |
|||
{ |
|||
ptr = &Pending_orders[i]; |
|||
if ( strcmp(exchange,ptr->exchange) != 0 || strcmp(base,ptr->base) != 0 || strcmp(rel,ptr->rel) != 0 ) |
|||
continue; |
|||
if ( ptr->completed != 0 ) |
|||
{ |
|||
if ( ptr->reported == 0 ) |
|||
{ |
|||
if ( ptr->dir > 0 ) |
|||
(*buyvolp) += ptr->volume; |
|||
else if ( ptr->dir < 0 ) |
|||
(*sellvolp) += ptr->volume; |
|||
pricesum += ptr->volume * ptr->price; |
|||
volsum += ptr->volume; |
|||
ptr->reported = (uint32_t)time(NULL); |
|||
printf("REPORT dir.%d vol %.8f\n",ptr->dir,ptr->volume); |
|||
} |
|||
} |
|||
else if ( ptr->pending != 0 ) // alternative is error or cancelled
|
|||
{ |
|||
if ( ptr->dir > 0 ) |
|||
(*pendingbidsp) += ptr->volume; |
|||
else if ( ptr->dir < 0 ) |
|||
(*pendingasksp) += ptr->volume; |
|||
} |
|||
} |
|||
if ( volsum != 0. ) |
|||
pricesum /= volsum; |
|||
return(pricesum); |
|||
} |
|||
|
|||
int32_t marketmaker_prune(char *exchange,char *base,char *rel,int32_t polarity,double bid,double ask,double separation) |
|||
{ |
|||
int32_t i,n = 0; struct mmpending_order *ptr; |
|||
for (i=0; i<Num_Pending; i++) |
|||
{ |
|||
ptr = &Pending_orders[i]; |
|||
if ( strcmp(exchange,ptr->exchange) != 0 || strcmp(base,ptr->base) != 0 || strcmp(rel,ptr->rel) != 0 ) |
|||
continue; |
|||
if ( ptr->pending != 0 && ptr->cancelstarted == 0 ) |
|||
{ |
|||
if ( polarity != 0 ) |
|||
{ |
|||
if ( ((ptr->dir*polarity > 0 && ptr->price < bid-separation) || (ptr->dir*polarity < 0 && ptr->price > ask+separation)) ) |
|||
{ |
|||
printf("polarity.%d dir.%d price.%f bid.%f ask.%f\n",polarity,ptr->dir,ptr->price,bid,ask); |
|||
marketmaker_cancel(ptr), n++; |
|||
} |
|||
} |
|||
/*else
|
|||
{,*prunebid=0,*pruneask=0; double lowbid=0.,highask=0. |
|||
if ( ptr->dir > 0 && (lowbid == 0. || ptr->price < lowbid) ) |
|||
{ |
|||
lowbid = ptr->price; |
|||
prunebid = ptr; |
|||
} |
|||
else if ( ptr->dir < 0 && (highask == 0. || ptr->price > highask) ) |
|||
{ |
|||
highask = ptr->price; |
|||
pruneask = ptr; |
|||
} |
|||
}*/ |
|||
} |
|||
} |
|||
/*if ( polarity == 0 )
|
|||
{ |
|||
if ( prunebid != 0 && fabs(prunebid->price - bid) > separation ) |
|||
marketmaker_cancel(prunebid), n++; |
|||
if ( pruneask != 0 && fabs(pruneask->price - ask) > separation ) |
|||
marketmaker_cancel(pruneask), n++; |
|||
}*/ |
|||
return(n); |
|||
} |
|||
|
|||
void marketmaker_volumeset(double *bidincrp,double *askincrp,double incr,double buyvol,double pendingbids,double sellvol,double pendingasks,double maxexposure) |
|||
{ |
|||
*bidincrp = *askincrp = incr; |
|||
//if ( pendingbids >= pendingasks+maxexposure )
|
|||
// *bidincrp = 0.;
|
|||
//else if ( pendingasks >= pendingbids+maxexposure )
|
|||
// *askincrp = 0.;
|
|||
if ( *bidincrp > 0. && pendingbids + *bidincrp > maxexposure ) |
|||
*bidincrp = (maxexposure - *bidincrp); |
|||
if ( *askincrp > 0. && pendingasks + *askincrp > maxexposure ) |
|||
*askincrp = (maxexposure - *askincrp); |
|||
if ( *bidincrp < 0. ) |
|||
*bidincrp = 0.; |
|||
if ( *askincrp < 0. ) |
|||
*askincrp = 0.; |
|||
} |
|||
|
|||
int32_t marketmaker_spread(char *exchange,char *base,char *rel,double bid,double bidvol,double ask,double askvol,double separation) |
|||
{ |
|||
int32_t nearflags[2],i,n = 0; struct mmpending_order *ptr; cJSON *retjson,*vals; char *retstr,postdata[1024],url[128]; double vol,spread_ratio; |
|||
memset(nearflags,0,sizeof(nearflags)); |
|||
if ( strcmp("DEX",exchange) != 0 ) |
|||
{ |
|||
for (i=0; i<Num_Pending; i++) |
|||
{ |
|||
ptr = &Pending_orders[i]; |
|||
if ( strcmp(exchange,ptr->exchange) != 0 || strcmp(base,ptr->base) != 0 || strcmp(rel,ptr->rel) != 0 ) |
|||
continue; |
|||
if ( ptr->pending != 0 && ptr->cancelstarted == 0 ) |
|||
{ |
|||
if ( bid > SMALLVAL && bidvol > SMALLVAL && ptr->dir > 0 && fabs(bid - ptr->price) < separation ) |
|||
{ |
|||
//printf("bid %.8f near %.8f\n",bid,ptr->price);
|
|||
nearflags[0]++; |
|||
} |
|||
if ( ask > SMALLVAL && askvol > SMALLVAL && ptr->dir < 0 && fabs(ask - ptr->price) < separation ) |
|||
{ |
|||
//printf("%.8f near %.8f\n",ask,ptr->price);
|
|||
nearflags[1]++; |
|||
} |
|||
} |
|||
} |
|||
} |
|||
//printf("spread.%s (%.8f %.6f) (%.8f %.6f)\n",exchange,bid,bidvol,ask,askvol);
|
|||
if ( bid > SMALLVAL && bidvol > SMALLVAL && nearflags[0] == 0 ) |
|||
{ |
|||
if ( strcmp("DEX",exchange) == 0 && strcmp(base,"KMD") == 0 && strcmp(rel,"BTC") == 0 ) |
|||
{ |
|||
if ( ask > SMALLVAL && askvol > SMALLVAL ) |
|||
{ |
|||
/*li.profit = jdouble(vals,"profit");
|
|||
li.refprice = jdouble(vals,"refprice"); |
|||
li.bid = jdouble(vals,"bid"); |
|||
li.ask = jdouble(vals,"ask"); |
|||
if ( (li.minvol= jdouble(vals,"minvol")) <= 0. ) |
|||
li.minvol = (strcmp("BTC",base) == 0) ? 0.0001 : 0.001; |
|||
if ( (li.maxvol= jdouble(vals,"maxvol")) < li.minvol ) |
|||
li.maxvol = li.minvol;*/ |
|||
//curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"tradebot\",\"method\":\"liquidity\",\"targetcoin\":\"MVP\",\"vals\":{\"rel\":\"USD\",\"bid\":0.09,\"ask\":0.11,\"maxvol\":100}}"
|
|||
vals = cJSON_CreateObject(); |
|||
jaddstr(vals,"rel","BTC"); |
|||
jaddnum(vals,"bid",bid); |
|||
jaddnum(vals,"ask",ask); |
|||
vol = bidvol > askvol ? askvol : bidvol; |
|||
jaddnum(vals,"maxvol",vol); |
|||
jaddnum(vals,"minvol",vol*0.1 > 100 ? 100 : vol * 0.1); |
|||
sprintf(url,"%s/?",IGUANA_URL); |
|||
sprintf(postdata,"{\"agent\":\"tradebot\",\"method\":\"liquidity\",\"targetcoin\":\"%s\",\"vals\":%s}",base,jprint(vals,1)); |
|||
//printf("(%s)\n",postdata);
|
|||
if ( (retstr= bitcoind_RPC(0,"tradebot",url,0,"liqudity",postdata,0)) != 0 ) |
|||
{ |
|||
//printf("(%s) -> (%s)\n",postdata,retstr);
|
|||
free(retstr); |
|||
} |
|||
spread_ratio = .5 * ((ask - bid) / (bid + ask)); |
|||
for (i=0; i<sizeof(CURRENCIES)/sizeof(*CURRENCIES); i++) |
|||
{ |
|||
if ( (PAXACTIVE & (1<<i)) == 0 ) |
|||
continue; |
|||
if ( PAXPRICES[i] > SMALLVAL ) |
|||
{ |
|||
vals = cJSON_CreateObject(); |
|||
jaddstr(vals,"rel",CURRENCIES[i]); |
|||
jaddnum(vals,"bid",PAXPRICES[i] * (1. - spread_ratio)); |
|||
jaddnum(vals,"ask",PAXPRICES[i] * (1. + spread_ratio)); |
|||
jaddnum(vals,"maxvol",vol * PAXPRICES[i]); |
|||
jaddnum(vals,"minvol",MAX(1,(int32_t)(vol * 0.01 * PAXPRICES[i]))); |
|||
sprintf(url,"%s/?",IGUANA_URL); |
|||
sprintf(postdata,"{\"agent\":\"tradebot\",\"method\":\"liquidity\",\"targetcoin\":\"%s\",\"vals\":%s}","KMD",jprint(vals,1)); |
|||
if ( (retstr= bitcoind_RPC(0,"tradebot",url,0,"liqudity",postdata,0)) != 0 ) |
|||
{ |
|||
//printf("(%s) -> (%s)\n",postdata,retstr);
|
|||
free(retstr); |
|||
} |
|||
} |
|||
//break;
|
|||
} |
|||
} else printf("unsupported ask only for DEX %s/%s\n",base,rel); |
|||
} |
|||
else if ( (retstr= DEX_trade(exchange,base,rel,1,bid,bidvol)) != 0 ) |
|||
{ |
|||
//printf("DEX_trade.(%s)\n",retstr);
|
|||
if ( (retjson= cJSON_Parse(retstr)) != 0 ) |
|||
{ |
|||
marketmaker_queue(exchange,base,rel,1,bid,bidvol,retjson); |
|||
free_json(retjson); |
|||
} |
|||
free(retstr); |
|||
} //else printf("skip bid %s %.8f vol %f\n",exchange,bid,bidvol);
|
|||
} |
|||
if ( ask > SMALLVAL && askvol > SMALLVAL && nearflags[1] == 0 && strcmp("DEX",exchange) != 0 ) |
|||
{ |
|||
if ( (retstr= DEX_trade(exchange,base,rel,-1,ask,askvol)) != 0 ) |
|||
{ |
|||
//printf("DEX_trade.(%s)\n",retstr);
|
|||
if ( (retjson= cJSON_Parse(retstr)) != 0 ) |
|||
{ |
|||
marketmaker_queue(exchange,base,rel,-1,ask,askvol,retjson); |
|||
free_json(retjson); |
|||
} |
|||
free(retstr); |
|||
} |
|||
} //else printf("skip ask %s %.8f vol %f\n",exchange,bid,bidvol);
|
|||
return(n); |
|||
} |
|||
|
|||
double marketmaker_updateprice(char *name,char *base,char *rel,double theoretical,double *incrp) |
|||
{ |
|||
static uint32_t counter; |
|||
cJSON *fiatjson; double USD_average=0.,usdprice=0.,CMC_average=0.,avebid=0.,aveask=0.,val,changes[3],highbid=0.,lowask=0.; |
|||
if ( (val= get_theoretical(&avebid,&aveask,&highbid,&lowask,&CMC_average,changes,name,base,rel,&USD_average)) != 0. ) |
|||
{ |
|||
if ( theoretical == 0. ) |
|||
{ |
|||
theoretical = val; |
|||
if ( *incrp > 2 ) |
|||
{ |
|||
*incrp = (int32_t)*incrp; |
|||
*incrp += 0.777; |
|||
} |
|||
} else theoretical = (theoretical + val) * 0.5; |
|||
if ( (counter++ % 12) == 0 ) |
|||
{ |
|||
if ( USD_average > SMALLVAL && CMC_average > SMALLVAL && theoretical > SMALLVAL ) |
|||
{ |
|||
usdprice = USD_average * (theoretical / CMC_average); |
|||
printf("USD %.4f <- (%.6f * (%.8f / %.8f))\n",usdprice,USD_average,theoretical,CMC_average); |
|||
PAXPRICES[0] = usdprice; |
|||
if ( (fiatjson= yahoo_allcurrencies()) != 0 ) |
|||
{ |
|||
marketmaker_fiatupdate(fiatjson); |
|||
free_json(fiatjson); |
|||
} |
|||
} |
|||
} |
|||
LP_priceupdate(base,rel,theoretical,avebid,aveask,highbid,lowask,PAXPRICES); |
|||
} |
|||
return(theoretical); |
|||
} |
|||
|
|||
void marketmaker(double minask,double maxbid,char *baseaddr,char *reladdr,double start_BASE,double start_REL,double profitmargin,double maxexposure,double ratioincr,char *exchange,char *name,char *base,char *rel) |
|||
{ |
|||
char *retstr; double bid,ask,start_DEXbase,start_DEXrel,DEX_base = 0.,DEX_rel = 0.,balance_base=0.,balance_rel=0.,mmbid,mmask,aveprice,incr,pendingbids,pendingasks,buyvol,sellvol,bidincr,askincr,filledprice,avebid=0.,aveask=0.,highbid=0.,lowask=0.,theoretical = 0.; uint32_t lasttime = 0; |
|||
incr = maxexposure * ratioincr; |
|||
buyvol = sellvol = 0.; |
|||
start_DEXbase = dex_balance(base,baseaddr); |
|||
start_DEXrel = dex_balance(rel,reladdr); |
|||
while ( 1 ) |
|||
{ |
|||
if ( time(NULL) > lasttime+60 ) |
|||
{ |
|||
if ( (theoretical= marketmaker_updateprice(name,base,rel,theoretical,&incr)) != 0. ) |
|||
{ |
|||
if ( lasttime == 0 ) |
|||
maxexposure /= theoretical; |
|||
} |
|||
if ( strcmp(exchange,"bittrex") == 0 ) |
|||
{ |
|||
balance_base = bittrex_balance(base,""); |
|||
balance_rel = bittrex_balance(rel,""); |
|||
DEX_base = dex_balance(base,baseaddr); |
|||
DEX_rel = dex_balance(rel,reladdr); |
|||
} else printf("add support for %s balance\n",exchange); |
|||
lasttime = (uint32_t)time(NULL); |
|||
} |
|||
marketmaker_pendingupdate(exchange,base,rel); |
|||
if ( theoretical > SMALLVAL && avebid > SMALLVAL && aveask > SMALLVAL ) |
|||
{ |
|||
aveprice = (avebid + aveask) * 0.5; |
|||
// if order is filled, theoretical <- filled (theoretical + price)/2
|
|||
if ( (filledprice= marketmaker_filled(exchange,base,rel,&buyvol,&sellvol,&pendingbids,&pendingasks)) != 0. ) |
|||
theoretical = (theoretical + filledprice) * 0.5; |
|||
buyvol = sellvol = 0; |
|||
if ( (balance_base + DEX_base) < (start_BASE + start_DEXbase) ) |
|||
sellvol += ((start_BASE + start_DEXbase) - (balance_base + DEX_base)); |
|||
else buyvol += ((balance_base + DEX_base) - (start_BASE + start_DEXbase)); |
|||
if ( (balance_rel + DEX_rel) < (start_REL + start_DEXrel) ) |
|||
buyvol += ((start_REL + start_DEXrel) - (balance_rel + DEX_rel)) / theoretical; |
|||
else sellvol += ((balance_rel + DEX_rel) - (start_REL + start_DEXrel)) / theoretical; |
|||
mmbid = theoretical - theoretical*profitmargin; |
|||
mmask = theoretical + theoretical*profitmargin; |
|||
// if any existing order exceeds double margin distance, cancel
|
|||
marketmaker_prune(exchange,base,rel,1,mmbid - theoretical*profitmargin,mmask + theoretical*profitmargin,0.); |
|||
// if new prices crosses existing order, cancel old order first
|
|||
marketmaker_prune(exchange,base,rel,-1,mmbid,mmask,0.); |
|||
//printf("(%.8f %.8f) ",mmbid,mmask);
|
|||
if ( (1) ) |
|||
{ |
|||
if ( mmbid >= lowask || (maxbid > SMALLVAL && mmbid > maxbid) ) //mmbid < highbid ||
|
|||
{ |
|||
printf("clear mmbid %.8f lowask %.8f maxbid %.8f\n",mmbid,lowask,maxbid); |
|||
mmbid = 0.; |
|||
} |
|||
if ( mmask <= highbid || (minask > SMALLVAL && mmask < minask) ) // mmask > lowask ||
|
|||
mmask = 0.; |
|||
} |
|||
marketmaker_volumeset(&bidincr,&askincr,incr,buyvol,pendingbids,sellvol,pendingasks,maxexposure); |
|||
printf("AVE.(%.8f %.8f) hbla %.8f %.8f bid %.8f ask %.8f theory %.8f buys.(%.6f %.6f) sells.(%.6f %.6f) incr.(%.6f %.6f) balances.(%.8f + %.8f, %.8f + %.8f) test %f\n",avebid,aveask,highbid,lowask,mmbid,mmask,theoretical,buyvol,pendingbids,sellvol,pendingasks,bidincr,askincr,balance_base,DEX_base,balance_rel,DEX_rel,(aveask - avebid)/aveprice); |
|||
if ( (retstr= DEX_swapstatus()) != 0 ) |
|||
printf("%s\n",retstr), free(retstr); |
|||
printf("%s %s %s, %s %s %s\n",base,DEX_baseaddr,DEX_balance("DEX",base,DEX_baseaddr),rel,DEX_reladdr,DEX_balance("DEX",rel,DEX_reladdr)); |
|||
if ( (aveask - avebid)/aveprice > profitmargin ) |
|||
bid = highbid * (1 - profitmargin), ask = lowask * (1 + profitmargin); |
|||
else bid = avebid - profitmargin*aveprice, ask = avebid + profitmargin*aveprice; |
|||
marketmaker_spread("DEX",base,rel,bid,incr,ask,incr,profitmargin*aveprice*0.5); |
|||
if ( (pendingbids + buyvol) > (pendingasks + sellvol) && (pendingbids + buyvol) > bidincr ) |
|||
{ |
|||
bidincr *= ((double)(pendingasks + sellvol) / ((pendingbids + buyvol) + (pendingasks + sellvol))); |
|||
printf("bidincr %f buy.(%f + %f) sell.(%f + %f)\n",bidincr,pendingbids,buyvol,pendingasks,sellvol); |
|||
if ( bidincr < 0.1*incr ) |
|||
bidincr = 0.1*incr; |
|||
if ( bidincr > 1. ) |
|||
bidincr = (int32_t)bidincr + 0.777; |
|||
} |
|||
if ( (pendingbids + buyvol) < (pendingasks + sellvol) && (pendingasks + sellvol) > askincr ) |
|||
{ |
|||
askincr *= (double)(pendingbids + buyvol) / ((pendingbids + buyvol) + (pendingasks + sellvol)); |
|||
if ( askincr < 0.1*incr ) |
|||
askincr = 0.1*incr; |
|||
if ( askincr > 1. ) |
|||
askincr = (int32_t)askincr + 0.777; |
|||
} |
|||
//printf("mmbid %.8f %.6f, mmask %.8f %.6f\n",mmbid,bidincr,mmask,askincr);
|
|||
marketmaker_spread(exchange,base,rel,mmbid,bidincr,mmask,askincr,profitmargin*aveprice*0.5); |
|||
sleep(60); |
|||
} |
|||
} |
|||
} |
|||
|
|||
#include "LP_nativeDEX.c" |
|||
|
|||
void LP_main(void *ptr) |
|||
{ |
|||
char *passphrase; double profitmargin; uint16_t port; cJSON *argjson = ptr; |
|||
if ( (passphrase= jstr(argjson,"passphrase")) != 0 ) |
|||
{ |
|||
profitmargin = jdouble(argjson,"profitmargin"); |
|||
LP_profitratio += profitmargin; |
|||
if ( (port= juint(argjson,"rpcport")) < 1000 ) |
|||
port = LP_RPCPORT; |
|||
LPinit(port,LP_RPCPORT+10,LP_RPCPORT+20,LP_RPCPORT+30,passphrase,jint(argjson,"client"),jstr(argjson,"userhome"),argjson); |
|||
} |
|||
} |
|||
|
|||
int main(int argc, const char * argv[]) |
|||
{ |
|||
char dirname[512],*base,*rel,*name,*exchange,*apikey,*apisecret,*blocktrail,*retstr,*baseaddr,*reladdr,*passphrase; |
|||
double profitmargin,maxexposure,incrratio,start_rel,start_base,minask,maxbid,incr; |
|||
cJSON *retjson,*loginjson; int32_t i; |
|||
OS_init(); |
|||
if ( strstr(argv[0],"btc2kmd") != 0 && argv[1] != 0 ) |
|||
{ |
|||
uint8_t addrtype,rmd160[20],rmd160b[20]; char coinaddr[64],coinaddr2[64]; |
|||
bitcoin_addr2rmd160(0,&addrtype,rmd160,(char *)argv[1]); |
|||
if ( addrtype == 0 ) |
|||
{ |
|||
bitcoin_address(coinaddr,0,60,rmd160,20); |
|||
bitcoin_addr2rmd160(0,&addrtype,rmd160b,coinaddr); |
|||
bitcoin_address(coinaddr2,0,0,rmd160b,20); |
|||
} |
|||
else if ( addrtype == 60 ) |
|||
{ |
|||
bitcoin_address(coinaddr,0,0,rmd160,20); |
|||
bitcoin_addr2rmd160(0,&addrtype,rmd160b,coinaddr); |
|||
bitcoin_address(coinaddr2,0,60,rmd160b,20); |
|||
} |
|||
printf("(%s) -> %s -> %s\n",(char *)argv[1],coinaddr,coinaddr2); |
|||
if ( strcmp((char *)argv[1],coinaddr2) != 0 ) |
|||
printf("ERROR\n"); |
|||
exit(0); |
|||
} |
|||
sprintf(dirname,"%s",GLOBAL_DBDIR), OS_ensure_directory(dirname); |
|||
sprintf(dirname,"%s/SWAPS",GLOBAL_DBDIR), OS_ensure_directory(dirname); |
|||
sprintf(dirname,"%s/PRICES",GLOBAL_DBDIR), OS_ensure_directory(dirname); |
|||
sprintf(dirname,"%s/UNSPENTS",GLOBAL_DBDIR), OS_ensure_directory(dirname); |
|||
#ifdef FROM_JS |
|||
argc = 2; |
|||
retjson = cJSON_Parse("{\"client\":1,\"passphrase\":\"test\"}"); |
|||
printf("calling LP_main(%s)\n",jprint(retjson,0)); |
|||
LP_main(retjson); |
|||
emscripten_set_main_loop(LP_fromjs_iter,1,0); |
|||
#else |
|||
if ( argc == 1 ) |
|||
{ |
|||
LP_NXT_redeems(); |
|||
sleep(3); |
|||
return(0); |
|||
} |
|||
if ( argc > 1 && (retjson= cJSON_Parse(argv[1])) != 0 ) |
|||
{ |
|||
if ( jint(retjson,"docker") == 1 ) |
|||
DOCKERFLAG = 1; |
|||
else if ( jstr(retjson,"docker") != 0 ) |
|||
DOCKERFLAG = (uint32_t)calc_ipbits(jstr(retjson,"docker")); |
|||
if ( (passphrase= jstr(retjson,"passphrase")) == 0 ) |
|||
jaddstr(retjson,"passphrase","test"); |
|||
if ( OS_thread_create(malloc(sizeof(pthread_t)),NULL,(void *)LP_main,(void *)retjson) != 0 ) |
|||
{ |
|||
printf("error launching LP_main (%s)\n",jprint(retjson,0)); |
|||
exit(-1); |
|||
} //else printf("(%s) launched.(%s)\n",argv[1],passphrase);
|
|||
incr = 100.; |
|||
while ( (1) ) |
|||
sleep(100000); |
|||
profitmargin = jdouble(retjson,"profitmargin"); |
|||
minask = jdouble(retjson,"minask"); |
|||
maxbid = jdouble(retjson,"maxbid"); |
|||
maxexposure = jdouble(retjson,"maxexposure"); |
|||
incrratio = jdouble(retjson,"lotratio"); |
|||
start_base = jdouble(retjson,"start_base"); |
|||
start_rel = jdouble(retjson,"start_rel"); |
|||
apikey = jstr(retjson,"apikey"); |
|||
apisecret = jstr(retjson,"apisecret"); |
|||
base = jstr(retjson,"base"); |
|||
name = jstr(retjson,"name"); |
|||
rel = jstr(retjson,"rel"); |
|||
blocktrail = jstr(retjson,"blocktrail"); |
|||
exchange = jstr(retjson,"exchange"); |
|||
PAXACTIVE = juint(retjson,"paxactive"); |
|||
if ( profitmargin < 0. || maxexposure <= 0. || incrratio <= 0. || apikey == 0 || apisecret == 0 || base == 0 || name == 0 || rel == 0 || exchange == 0 || blocktrail == 0 ) |
|||
{ |
|||
printf("illegal parameter (%s)\n",jprint(retjson,0)); |
|||
exit(-1); |
|||
} |
|||
if ( (retstr= iguana_walletpassphrase(passphrase,999999)) != 0 ) |
|||
{ |
|||
printf("(%s/%s) login.(%s)\n",base,rel,retstr); |
|||
if ( (loginjson= cJSON_Parse(retstr)) != 0 ) |
|||
{ |
|||
if ( PAXACTIVE != 0 ) |
|||
{ |
|||
for (i=0; i<32; i++) |
|||
{ |
|||
if ( ((1<<i) & PAXACTIVE) != 0 ) |
|||
{ |
|||
if ( jstr(loginjson,CURRENCIES[i]) == 0 ) |
|||
PAXACTIVE &= ~(1 << i); |
|||
} |
|||
} |
|||
} |
|||
if ( (baseaddr= jstr(loginjson,base)) == 0 || (reladdr= jstr(loginjson,rel)) == 0 ) |
|||
{ |
|||
printf("Need to activate both %s and %s before marketmaker\n",base,rel); |
|||
exit(1); |
|||
} |
|||
printf("%s\n",DEX_apikeypair(exchange,apikey,apisecret)); |
|||
marketmaker_pendinginit(exchange,base,rel); |
|||
if ( baseaddr != 0 && reladdr != 0 ) |
|||
{ |
|||
printf("PAXACTIVE.%08x %s\n",PAXACTIVE,DEX_amlp(blocktrail)); |
|||
strncpy(DEX_baseaddr,baseaddr,sizeof(DEX_baseaddr)-1); |
|||
strncpy(DEX_reladdr,reladdr,sizeof(DEX_reladdr)-1); |
|||
printf("%s.%s %s\n",base,baseaddr,DEX_balance("DEX",base,baseaddr)); |
|||
printf("%s.%s %s\n",rel,reladdr,DEX_balance("DEX",rel,reladdr)); |
|||
// initialize state using DEX_pendingorders, etc.
|
|||
marketmaker(minask,maxbid,baseaddr,reladdr,start_base,start_rel,profitmargin,maxexposure,incrratio,exchange,name,base,rel); |
|||
} |
|||
free_json(loginjson); |
|||
} else printf("ERROR parsing.(%s)\n",retstr); |
|||
free(retstr); |
|||
} |
|||
free_json(retjson); |
|||
} |
|||
#endif |
|||
return 0; |
|||
} |
@ -0,0 +1,4 @@ |
|||
#!/bin/bash |
|||
source userpass |
|||
# this will only work for watchonly addresses that have been rescanned and with active coins |
|||
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"fundvalue\",\"address\":\"RTu3JZZKLJTcfNwBa19dWRagEfQq49STqC\",\"holdings\":[{\"coin\":\"iota\",\"balance\":1500000}, {\"coin\":\"bitcoin-cash\",\"balance\":1200}, {\"coin\":\"bitcoin\",\"balance\":145}],\"divisor\":1400000}" |
@ -0,0 +1,3 @@ |
|||
#!/bin/bash |
|||
source userpass |
|||
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"swapstatus\",\"pending\":1}" |
@ -0,0 +1,44 @@ |
|||
#!/bin/bash |
|||
margin=0.02 |
|||
source userpass |
|||
./auto_chipskmd |
|||
./auto_chipsbtc |
|||
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"autoprice\",\"base\":\"KMD\",\"rel\":\"BTC\",\"margin\":0.01,\"refbase\":\"komodo\",\"refrel\":\"coinmarketcap\"}" |
|||
#curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"autoprice\",\"base\":\"BTC\",\"rel\":\"KMD\",\"fixed\":0.00025,\"margin\":0.01}" |
|||
#curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"autoprice\",\"base\":\"KMD\",\"rel\":\"BTC\",\"fixed\":4000,\"margin\":0.01}" |
|||
#curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"autoprice\",\"base\":\"KMD\",\"rel\":\"MNZ\",\"offset\":0.0,\"refbase\":\"KMD\",\"refrel\":\"BTC\",\"factor\":15000,\"margin\":-0.2}" |
|||
|
|||
source crypto |
|||
source trackbtc |
|||
|
|||
source dex |
|||
source trackbtc |
|||
|
|||
source jumblr |
|||
source trackbtc |
|||
|
|||
source pangea |
|||
source trackbtc |
|||
|
|||
source bots |
|||
source trackbtc |
|||
|
|||
source bet |
|||
source trackbtc |
|||
|
|||
source revs |
|||
source trackbtc |
|||
|
|||
source mgw |
|||
source trackbtc |
|||
|
|||
source revs |
|||
source trackbtc |
|||
|
|||
sharkholdings="{\"coin\":\"iota\",\"balance\":1500000}, {\"coin\":\"bitcoin-cash\",\"balance\":1200}, {\"coin\":\"bitcoin\",\"balance\":145}" |
|||
curl --url "http://127.0.0.1:7783" --data "{\"base\":\"MSHARK\",\"rel\":\"KMD\",\"fundvalue_bid\":\"NAV_KMD\",\"fundvalue_ask\":\"assetNAV_KMD\",\"userpass\":\"$userpass\",\"method\":\"autoprice\",\"address\":\"RTu3JZZKLJTcfNwBa19dWRagEfQq49STqC\",\"holdings\":[$sharkholdings],\"divisor\":1400000}" |
|||
|
|||
|
|||
curl --url "http://127.0.0.1:7783" --data "{\"base\":\"SUPERNET\",\"rel\":\"KMD\",\"fundvalue_bid\":\"NAV_KMD\",\"fundvalue_ask\":\"assetNAV_KMD\",\"userpass\":\"$userpass\",\"method\":\"autoprice\",\"address\":\"RRyyejME7LRTuvdziWsXkAbSW1fdiohGwK\",\"holdings\":[{\"coin\":\"iota\",\"balance\":11000000}, {\"coin\":\"stratis\",\"balance\":1300000}, {\"coin\":\"zcash\",\"balance\":10000}, {\"coin\":\"syscoin\",\"balance\":20000000}, {\"coin\":\"waves\",\"balance\":700000}, {\"coin\":\"bitcoin\",\"balance\":625}, {\"coin\":\"bitcoin-cash\",\"balance\":1500}, {\"coin\":\"heat-ledger\",\"balance\":2323851 }, {\"coin\":\"decred\",\"balance\":20000}, {\"coin\":\"vericoin\",\"balance\":2199368 }, {\"coin\":\"byteball\",\"balance\":4238}, {\"coin\":\"iocoin\",\"balance\":150000}, {\"coin\":\"quantum-resistant-ledger\",\"balance\":375000}, {\"coin\":\"chips\",\"balance\":2577006 }, {\"coin\":\"hush\",\"balance\":100000 }, {\"coin\":\"mobilego\",\"balance\":100000 }],\"divisor\":816016}" |
|||
|
|||
curl --url "http://127.0.0.1:7783" --data "{\"margin\":0.01,\"base\":\"HODL\",\"rel\":\"KMD\",\"fundvalue_bid\":\"assetNAV_KMD\",\"fundvalue_ask\":\"assetNAV_KMD\",\"userpass\":\"$userpass\",\"method\":\"autoprice\",\"address\":\"RNcUaMUEFLxVwtTo7rgruhwYanGk1jTkeU\",\"holdings\":[{\"coin\":\"siacoin\",\"balance\":185000000,\"comment\":\"using siafunds equal to million siacoin\"}],\"divisor\":10000000}" |
@ -0,0 +1,3 @@ |
|||
coin=BET |
|||
price=0.0005 |
|||
invprice=2000 |
@ -0,0 +1,3 @@ |
|||
coin=BOTS |
|||
price=0.001 |
|||
invprice=1000 |
@ -0,0 +1,3 @@ |
|||
coin=CRYPTO |
|||
price=0.002666666 |
|||
invprice=375 |
@ -0,0 +1,3 @@ |
|||
coin=DEX |
|||
price=0.0015 |
|||
invprice=666 |
@ -0,0 +1,3 @@ |
|||
coin=JUMBLR |
|||
price=0.002 |
|||
invprice=500 |
@ -0,0 +1,3 @@ |
|||
coin=MGW |
|||
price=0.00015 |
|||
invprice=6666 |
@ -0,0 +1,3 @@ |
|||
coin=PANGEA |
|||
price=0.001 |
|||
invprice=1000 |
@ -0,0 +1,3 @@ |
|||
coin=REVS |
|||
price=0.0005 |
|||
invprice=2000 |
@ -0,0 +1,20 @@ |
|||
#!/bin/bash |
|||
source userpass |
|||
# this will only work for watchonly addresses that have been rescanned and with active coins |
|||
echo mshark |
|||
./mshark |
|||
echo hodl |
|||
./hodl |
|||
echo dex |
|||
./dex |
|||
echo jumblr |
|||
./jumblr |
|||
echo bots |
|||
./bots |
|||
echo supernet |
|||
|
|||
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"balances\",\"address\":\"RRyyejME7LRTuvdziWsXkAbSW1fdiohGwK\"}" |
|||
echo supernet |
|||
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"fundvalue\",\"address\":\"RRyyejME7LRTuvdziWsXkAbSW1fdiohGwK\",\"holdings\":[{\"coin\":\"iota\",\"balance\":11000000}, {\"coin\":\"stratis\",\"balance\":1300000}, {\"coin\":\"zcash\",\"balance\":10000}, {\"coin\":\"syscoin\",\"balance\":20000000}, {\"coin\":\"waves\",\"balance\":700000}, {\"coin\":\"bitcoin\",\"balance\":625}, {\"coin\":\"bitcoin-cash\",\"balance\":1500}, {\"coin\":\"heat-ledger\",\"balance\":2323851 }, {\"coin\":\"decred\",\"balance\":20000}, {\"coin\":\"vericoin\",\"balance\":2199368 }, {\"coin\":\"byteball\",\"balance\":4238}, {\"coin\":\"iocoin\",\"balance\":150000}, {\"coin\":\"quantum-resistant-ledger\",\"balance\":375000}, {\"coin\":\"hush\",\"balance\":100000 }, {\"coin\":\"mobilego\",\"balance\":100000 }],\"divisor\":816016}" |
|||
|
|||
#curl --url "http://5.9.253.196:7782" --data "{\"userpass\":\"$userpass\",\"method\":\"fundvalue\",\"address\":\"RRyyejME7LRTuvdziWsXkAbSW1fdiohGwK\",\"holdings\":[{\"coin\":\"iota\",\"balance\":11000000}, {\"coin\":\"stratis\",\"balance\":1300000}, {\"coin\":\"zcash\",\"balance\":10000}, {\"coin\":\"syscoin\",\"balance\":20000000}, {\"coin\":\"waves\",\"balance\":700000}, {\"coin\":\"bitcoin\",\"balance\":625}, {\"coin\":\"bitcoin-cash\",\"balance\":1500}, {\"coin\":\"heat-ledger\",\"balance\":2323851 }, {\"coin\":\"decred\",\"balance\":20000}, {\"coin\":\"vericoin\",\"balance\":2199368 }, {\"coin\":\"byteball\",\"balance\":4238}, {\"coin\":\"iocoin\",\"balance\":150000}, {\"coin\":\"quantum-resistant-ledger\",\"balance\":375000}, {\"coin\":\"chips\",\"balance\":2577006 }, {\"coin\":\"hush\",\"balance\":100000 }, {\"coin\":\"mobilego\",\"balance\":100000 }],\"divisor\":816016}" |
@ -0,0 +1,3 @@ |
|||
#!/bin/bash |
|||
source userpass |
|||
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"ticker\",\"base\":\"REVS\",\"rel\":\"KMD\"}" |
@ -0,0 +1,2 @@ |
|||
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"autoprice\",\"base\":\"KMD\",\"rel\":\"$coin\",\"offset\":0.0,\"refbase\":\"KMD\",\"refrel\":\"BTC\",\"factor\":$invprice,\"margin\":$margin}" |
|||
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"autoprice\",\"base\":\"$coin\",\"rel\":\"KMD\",\"offset\":0.0,\"refbase\":\"BTC\",\"refrel\":\"KMD\",\"factor\":$price,\"margin\":$margin}" |
Loading…
Reference in new issue