committed by
GitHub
123 changed files with 11296 additions and 4345 deletions
@ -0,0 +1,2 @@ |
|||
curl --url "http://127.0.0.1:7778" --data "{\"conf\":\"SHARK.conf\",\"path\":\"${HOME#"/"}/.komodo/SHARK\",\"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\":\"SHARK\",\"name\":\"SHARK\",\"hasheaders\":1,\"useaddmultisig\":0,\"netmagic\":\"54a5e30c\",\"p2p\":14103,\"rpc\":14104,\"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\"}" |
|||
|
@ -1,2 +1,2 @@ |
|||
#!/bin/bash |
|||
curl --url "http://127.0.0.1:7776" --data "{\"conf\":\"chips.conf\",\"path\":\"${HOME#"/"}/.chips\",\"prefetchlag\":-1,\"poll\":1,\"active\":1,\"agent\":\"iguana\",\"method\":\"addcoin\",\"newcoin\":\"CHIPS\",\"startpend\":64,\"endpend\":64,\"services\":0,\"maxpeers\":512,\"RELAY\":-1,\"VALIDATE\":0,\"portp2p\":57777,\"minconfirms\":1}" |
|||
curl --url "http://127.0.0.1:7776" --data "{\"conf\":\"chips.conf\",\"path\":\"${HOME#"/"}/.chips\",\"prefetchlag\":-1,\"poll\":1,\"active\":1,\"agent\":\"iguana\",\"method\":\"addcoin\",\"newcoin\":\"CHIPS\",\"startpend\":64,\"endpend\":64,\"services\":0,\"maxpeers\":512,\"RELAY\":-1,\"VALIDATE\":0,\"portp2p\":57777,\"minconfirms\":1,\"pubval\":60,\"p2shval\":85,\"wifval\":188}" |
|||
|
@ -1,2 +1,2 @@ |
|||
curl --url "http://127.0.0.1:7778" --data "{\"conf\":\"SHARK.conf\",\"path\":\"${HOME#"/"}/.komodo/SHARK\",\"unitval\":\"20\",\"zcash\":1,\"RELAY\":1,\"VALIDATE\":1,\"prefetchlag\":-1,\"poll\":100,\"active\":1,\"agent\":\"iguana\",\"method\":\"addcoin\",\"startpend\":4,\"endpend\":4,\"services\":129,\"maxpeers\":8,\"newcoin\":\"SHARK\",\"name\":\"SHARK\",\"hasheaders\":1,\"useaddmultisig\":0,\"netmagic\":\"54a5e30c\",\"p2p\":10113,\"rpc\":10114,\"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\"}" |
|||
curl --url "http://127.0.0.1:7778" --data "{\"conf\":\"SHARK.conf\",\"path\":\"${HOME#"/"}/.komodo/SHARK\",\"unitval\":\"20\",\"zcash\":1,\"RELAY\":1,\"VALIDATE\":1,\"prefetchlag\":-1,\"poll\":100,\"active\":1,\"agent\":\"iguana\",\"method\":\"addcoin\",\"startpend\":4,\"endpend\":4,\"services\":129,\"maxpeers\":8,\"newcoin\":\"SHARK\",\"name\":\"SHARK\",\"hasheaders\":1,\"useaddmultisig\":0,\"netmagic\":\"54a5e30c\",\"p2p\":14103,\"rpc\":14104,\"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\":\"MSHARK.conf\",\"path\":\"${HOME#"/"}/.komodo/MSHARK\",\"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\":\"MSHARK\",\"name\":\"MSHARK\",\"hasheaders\":1,\"useaddmultisig\":0,\"netmagic\":\"54a5e30c\",\"p2p\":8845,\"rpc\":8846,\"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\"}" |
|||
|
@ -1,2 +1,2 @@ |
|||
curl --url "http://127.0.0.1:7776" --data "{\"conf\":\"SHARK.conf\",\"path\":\"${HOME#"/"}/.komodo/SHARK\",\"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\":\"SHARK\",\"name\":\"SHARK\",\"hasheaders\":1,\"useaddmultisig\":0,\"netmagic\":\"54a5e30c\",\"p2p\":10113,\"rpc\":10114,\"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\"}" |
|||
curl --url "http://127.0.0.1:7776" --data "{\"conf\":\"SHARK.conf\",\"path\":\"${HOME#"/"}/.komodo/SHARK\",\"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\":\"SHARK\",\"name\":\"SHARK\",\"hasheaders\":1,\"useaddmultisig\":0,\"netmagic\":\"54a5e30c\",\"p2p\":14103,\"rpc\":14104,\"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,16 @@ |
|||
@echo off |
|||
set USERHOME=%APPDATA:\=\\% |
|||
rem [!] Coins config now taked from coins.json file, no need to put in environment variable |
|||
rem --------------------------------------------------------------------------------------- |
|||
rem set COINS=[{\"coin\":\"REVS\",\"active\":1,\"asset\":\"REVS\",\"rpcport\":10196}] |
|||
rem marketmaker "{\"gui\":\"nogui\",\"client\":1, \"userhome\":\"%USERHOME%\", \"passphrase\":\"mypassphrase\", \"coins\":%COINS%}" |
|||
|
|||
set COINS=\"\" |
|||
set /p PASSPHRASE=<passphrase |
|||
rem , \"canbind\":1 |
|||
rem marketmaker "{\"gui\":\"nogui\",\"client\":1, \"userhome\":\"%USERHOME%\", \"passphrase\":\"%PASSPHRASE%\"}" 1> marketmaker.log 2>&1 |
|||
marketmaker "{\"gui\":\"nogui\",\"client\":1, \"userhome\":\"%USERHOME%\", \"passphrase\":\"%PASSPHRASE%\"}" |
|||
|
|||
|
|||
|
|||
|
@ -0,0 +1,7 @@ |
|||
@echo off |
|||
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":null,\"method\":\"enable\",\"coin\":\" \"}" -s > userpass.json |
|||
for /f "tokens=2 delims=:," %%a in (' find "userpass" "userpass.json" ') do ( |
|||
echo UserPass: %%~a |
|||
echo %%~a > userpass |
|||
) |
|||
del userpass.json |
@ -0,0 +1,4 @@ |
|||
@echo off |
|||
set /p TMPUSERPASS=<userpass |
|||
set USERPASS=%TMPUSERPASS: =% |
|||
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"%USERPASS%\",\"method\":\"balance\",\"coin\":\"KMD\",\"address\":\"RSpP2Nffy379SwF1cAkooNg6vwPHpakCpC\"}" |
@ -0,0 +1,7 @@ |
|||
@echo off |
|||
set /p TMPUSERPASS=<userpass |
|||
set USERPASS=%TMPUSERPASS: =% |
|||
set /p PASSPHRASE=<passphrase |
|||
echo passphrase: "%PASSPHRASE%" |
|||
echo userpass: "%USERPASS%" |
|||
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"%USERPASS%\",\"method\":\"bot_buy\",\"base\":\"MNZ\",\"rel\":\"KMD\",\"maxprice\":0.20,\"relvolume\":10.0}" |
@ -0,0 +1,7 @@ |
|||
@echo off |
|||
set /p TMPUSERPASS=<userpass |
|||
set USERPASS=%TMPUSERPASS: =% |
|||
set /p PASSPHRASE=<passphrase |
|||
rem echo passphrase: "%PASSPHRASE%" |
|||
rem echo userpass: "%USERPASS%" |
|||
curl -s --url "http://127.0.0.1:7783" --data "{\"userpass\":\"%USERPASS%\",\"method\":\"bot_list\"}" |
@ -0,0 +1,7 @@ |
|||
@echo off |
|||
set /p TMPUSERPASS=<userpass |
|||
set USERPASS=%TMPUSERPASS: =% |
|||
set /p PASSPHRASE=<passphrase |
|||
rem echo passphrase: "%PASSPHRASE%" |
|||
rem echo userpass: "%USERPASS%" |
|||
curl -s --url "http://127.0.0.1:7783" --data "{\"userpass\":\"%USERPASS%\",\"method\":\"bot_statuslist\"}" |
@ -0,0 +1,7 @@ |
|||
@echo off |
|||
set /p TMPUSERPASS=<userpass |
|||
set USERPASS=%TMPUSERPASS: =% |
|||
set /p PASSPHRASE=<passphrase |
|||
rem echo passphrase: "%PASSPHRASE%" |
|||
rem echo userpass: "%USERPASS%" |
|||
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"%USERPASS%\",\"method\":\"bot_stop\",\"botid\":1376557535}" |
Binary file not shown.
@ -0,0 +1,9 @@ |
|||
@echo off |
|||
rem http://pad.supernet.org/electrum-servers |
|||
set /p TMPUSERPASS=<userpass |
|||
set USERPASS=%TMPUSERPASS: =% |
|||
set /p PASSPHRASE=<passphrase |
|||
echo passphrase: "%PASSPHRASE%" |
|||
echo userpass: "%USERPASS%" |
|||
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"%USERPASS%\",\"method\":\"electrum\",\"coin\":\"KMD\",\"ipaddr\":\"electrum.cipig.net\",\"port\":10001}" |
|||
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"%USERPASS%\",\"method\":\"electrum\",\"coin\":\"MNZ\",\"ipaddr\":\"electrum.cipig.net\",\"port\":10002}" |
@ -0,0 +1,4 @@ |
|||
@echo off |
|||
set /p TMPUSERPASS=<userpass |
|||
set USERPASS=%TMPUSERPASS: =% |
|||
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"%USERPASS%\",\"method\":\"enable\",\"coin\":\"REVS\"}" |
@ -0,0 +1,4 @@ |
|||
@echo off |
|||
set /p TMPUSERPASS=<userpass |
|||
set USERPASS=%TMPUSERPASS: =% |
|||
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"%USERPASS%\",\"method\":\"getcoin\",\"coin\":\"KMD\"}" |
@ -0,0 +1,4 @@ |
|||
@echo off |
|||
set /p TMPUSERPASS=<userpass |
|||
set USERPASS=%TMPUSERPASS: =% |
|||
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"%USERPASS%\",\"method\":\"getutxos\",\"coin\":\"KMD\"}" |
@ -0,0 +1,2 @@ |
|||
@echo off |
|||
curl --url "http://127.0.0.1:7783" --data "{\"method\":\"help\"}" |
@ -0,0 +1,100 @@ |
|||
## DexScripts for Windows. How to use? ## |
|||
|
|||
**1.** Before start you should put scripts and following binaries into one folder: |
|||
|
|||
- curl.exe (required for all scripts) |
|||
- marketmaker.exe |
|||
- libcurl.dll (required to run marketmaker) |
|||
- nanomsg.dll (required to run marketmaker) |
|||
|
|||
**2.** Don't forget to put `coins.json` file into a same folder. This file is available it this repo. |
|||
|
|||
**3.** Type your passphrase into passphrase file in this folder (you should create file with name `passphrase` and without extension) and run `1-client.cmd`. This will run marketmaker. Next step is to obtain userpass needed for other scripts, you can simply copy and paste it from marketmaker output on startup into userpass file. |
|||
|
|||
![](./images/userpass.png) |
|||
|
|||
Or run `2-getuserpass.cmd` to fill userpass file automatically.** NB!** To get userpass you shouldn't run any scripts between 1-client.cmd and 2-getuserpass.cmd launching. |
|||
|
|||
Sample output of correct `2-getuserpass.cmd` usage is: |
|||
|
|||
![](./images/userpass_usage.png) |
|||
|
|||
You should see your userpass on screen, and after it will automatically copied in userpass file. It's important to all other scripts to have this password in userpass file. If output of `2-getuserpass.cmd` is not same as showed on screen above - wait some seconds and run `2-getuserpass.cmd` again. Also make sure that you have allowed marketmaker to accept incoming connections in your Windows Firewall (first time launched system should automatically asked for it). |
|||
|
|||
**4.** For using other scripts please refer to barterDEX API. Or **barterDEX API Summary by Category** document by *shossain*. |
|||
|
|||
## Scripts List ## |
|||
|
|||
**NB!** Before you use any script that do some actions with your coins (for example, withdraw and others) **edit it** and make sure that it have correct addresses, coin name and volumes inside. Don't run any scripts without looking on it's source and clearly understanding what it does. |
|||
|
|||
* **1-client.cmd** - used to start Marketmaker. Make sure you already have filled a strong passphrase into `passphrase` file as described above. |
|||
* **2-getuserpass.cmd** - fills userpass in `userpass` file. this step needed to use any other scripts. |
|||
* **balance.cmd** - displays current balance of selected coin. |
|||
* **enable.cmd** - enables a selected coin for trading. |
|||
* **getcoin.cmd** - prints information about a selecting coin: |
|||
|
|||
|
|||
{"result":"success","enabled":2,"disabled":70,"coin":{"coin":"KMD","installed":true,"height":580716,"balance":72.68774305,"KMDvalue":72.68774305,"status":"active","electrum":"electrum.cipig.net:10001","smartaddress":"RTCVGuoSNehKG8YYxcoskC7LK1yZhgvQRV","rpc":"127.0.0.1:7771","pubtype":60,"p2shtype":85,"wiftype":188,"txfee":10000}} |
|||
|
|||
|
|||
* **getutxos.cmd** - seems alredy deprecated. |
|||
* **inventory.cmd** - prints your inventory. |
|||
* **listunspent.cmd** - prints your utxos. |
|||
* **orderbook.cmd** - prints base/rel orderbook. |
|||
* **portfolio.cmd** - prints porfolio information. |
|||
* **snapshot.cmd** - ... |
|||
* **electrum.cmd** - allows you to run coins in electum mode (!), example includes two coins - KMD and MNZ. if you need to run more coins in electrum mode, add needed electrum servers from here - [http://pad.supernet.org/electrum-servers](http://pad.supernet.org/electrum-servers). |
|||
* **help.cmd** - displays help about all available API commands. |
|||
* **bot_buy.cmd** - launches bot for buying. you'll need to set base and rel coin in script, and also maxprice and relvolume. |
|||
* **bot_list.cmd** - lists id of all running bots. |
|||
* **bot_statuslist.cmd** - list statuses of all running bots. |
|||
* **bot_stop.cmd** - stopt the bot with given bot_id. |
|||
* **withdraw.cmd** - example of withdraw method. you can send coins from your smartaddress to any other address using widthraw. as a result method generates signed raw tx in hex, which you can use with sendrawtransaction.cmd . remember, that withdraw only *prepares* transaction, but it doesn't broadcast (send) it to network. after tx is prepared we need to send it using sendrawtransaction method. |
|||
* **sendrawtransaction.cmd** - sends raw transaction. you'll need a signedtx in hex. |
|||
* **withdraw_send.cmd** - combines withdraw and send raw tx scripts. you can call it `send`, just specify coin, volume and addresses to which you wan send coins and it will prepare and broadcast transaction automatically. |
|||
* **withdraw_10_send.cmd** - example of inventory split: this split 10 KMD from your balance to Alice inventory in 10 utxos pairs (1.002, 0.00386871). Strongly recommended to read [http://pad.supernet.org/barterdex-readme](http://pad.supernet.org/barterdex-readme) -> UTXO PAIRS to understand the basics. This script is just for example how you can split your coins in (X, X/777) to start trading them. |
|||
|
|||
## F.A.Q. ## |
|||
|
|||
**Q.** Is any simple way how i can display JSON results returned by all scripts, like orderbook and others, in human readable form? |
|||
|
|||
**A.** Yes, you can use this service [JSON Editor Online](http://jsoneditoronline.org/), just copy and paste output of script in left column and see structured output in right. |
|||
|
|||
**Q.** I see an output like this when i'm start `1-client.cmd` : |
|||
|
|||
bind(0.0.0.0) port.7783 failed: No error sock.1468. errno.0 |
|||
bind(0.0.0.0) port.7783 failed: No error sock.1516. errno.0 |
|||
bind(0.0.0.0) port.7783 failed: No error sock.1444. errno.0 |
|||
bind(0.0.0.0) port.7783 failed: No error sock.1484. errno.0 |
|||
bind(0.0.0.0) port.7783 failed: No error sock.1412. errno.0 |
|||
bind(0.0.0.0) port.7783 failed: No error sock.1524. errno.0 |
|||
bind(0.0.0.0) port.7783 failed: No error sock.1008. errno.0 |
|||
|
|||
And nothing works. |
|||
|
|||
**A.** Before run `1-client.cmd` make sure in Task Manager that you haven't already running `marketmaker.exe`. If have - kill this process via Task Manager or via command line command `taskkill /f /im taskkill.exe` . |
|||
|
|||
**Q.** How can i pretty print JSON answers of marketmaker? |
|||
|
|||
**A.** You can get best results with 2 tools - [conemu](https://conemu.github.io/) and [jq](https://stedolan.github.io/jq/), conemu supports ANSI X3.64 and Xterm 256 colors and jq allow you to pretty-print json output with colors, like this: |
|||
|
|||
![](./images/conemu_jq.png) |
|||
|
|||
Also i'm always recommend to install [Far Manager](https://www.farmanager.com/index.php?l=en) - this is powerful console file manager for Windows, like Midnight Commander in *nix. |
|||
|
|||
**Q.** What additional dependencies required by marketmaker? |
|||
|
|||
**A.** Currently marketmaker (Windows) used the following DLLs: |
|||
|
|||
*32 bit:* |
|||
- libcrypto-1_1.dll |
|||
- libcurl.dll |
|||
- libssl-1_1.dll |
|||
- nanomsg.dll |
|||
- pthreadvc2.dll |
|||
|
|||
*64-bit:* |
|||
- libcurl.dll |
|||
- nanomsg.dll |
|||
|
|||
It already included in repo and in archive with release. |
After Width: | Height: | Size: 31 KiB |
After Width: | Height: | Size: 17 KiB |
After Width: | Height: | Size: 11 KiB |
@ -0,0 +1,4 @@ |
|||
@echo off |
|||
set /p TMPUSERPASS=<userpass |
|||
set USERPASS=%TMPUSERPASS: =% |
|||
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"%USERPASS%\",\"method\":\"inventory\",\"coin\":\"KMD\"}" |
@ -0,0 +1,4 @@ |
|||
@echo off |
|||
set /p TMPUSERPASS=<userpass |
|||
set USERPASS=%TMPUSERPASS: =% |
|||
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"%USERPASS%\",\"method\":\"listunspent\",\"coin\":\"KMD\",\"address\":\"RSpP2Nffy379SwF1cAkooNg6vwPHpakCpC\"}" |
@ -0,0 +1,4 @@ |
|||
@echo off |
|||
set /p TMPUSERPASS=<userpass |
|||
set USERPASS=%TMPUSERPASS: =% |
|||
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"%USERPASS%\",\"method\":\"orderbook\",\"base\":\"KMD\",\"rel\":\"REVS\"}" |
@ -0,0 +1 @@ |
|||
your_very_strong_secret_passphrase |
@ -0,0 +1,4 @@ |
|||
@echo off |
|||
set /p TMPUSERPASS=<userpass |
|||
set USERPASS=%TMPUSERPASS: =% |
|||
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"%USERPASS%\",\"method\":\"portfolio\"}" |
@ -0,0 +1,5 @@ |
|||
@echo off |
|||
set /p TMPUSERPASS=<userpass |
|||
set USERPASS=%TMPUSERPASS: =% |
|||
set HEX=your_signed_raw_tx |
|||
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"%USERPASS%\",\"method\":\"sendrawtransaction\",\"coin\":\"KMD\",\"signedtx\":%HEX%"\"}" |
@ -0,0 +1,5 @@ |
|||
@echo off |
|||
set /p TMPUSERPASS=<userpass |
|||
set USERPASS=%TMPUSERPASS: =% |
|||
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"%USERPASS%\",\"method\":\"snapshot\",\"coin\":\"KMD\",\"height\":%1}" |
|||
|
@ -0,0 +1,8 @@ |
|||
@echo off |
|||
set /p TMPUSERPASS=<userpass |
|||
set USERPASS=%TMPUSERPASS: =% |
|||
rem *** Change coin and outputs before use (!) *** |
|||
set COIN=KMD |
|||
set OUTPUTS=[{\"RDecker69MM5dhDBosUXPNTzfoGqxPQqHu\":0.00007777}] |
|||
curl -s --url "http://127.0.0.1:7783" --data "{\"userpass\":\"%USERPASS%\",\"method\":\"withdraw\",\"coin\":\"%COIN%\",\"outputs\":%OUTPUTS%}" > withdraw.txt |
|||
type withdraw.txt |
@ -0,0 +1,14 @@ |
|||
@echo off |
|||
set /p TMPUSERPASS=<userpass |
|||
set USERPASS=%TMPUSERPASS: =% |
|||
rem *** Change coin and outputs before use (!) *** |
|||
set COIN=KMD |
|||
set SMARTADDRESS=RDecker69MM5dhDBosUXPNTzfoGqxPQqHu |
|||
set OUTPUTS=[{\"%SMARTADDRESS%\":1.002},{\"%SMARTADDRESS%\":0.00386871},{\"%SMARTADDRESS%\":1.002},{\"%SMARTADDRESS%\":0.00386871},{\"%SMARTADDRESS%\":1.002},{\"%SMARTADDRESS%\":0.00386871},{\"%SMARTADDRESS%\":1.002},{\"%SMARTADDRESS%\":0.00386871},{\"%SMARTADDRESS%\":1.002},{\"%SMARTADDRESS%\":0.00386871},{\"%SMARTADDRESS%\":1.002},{\"%SMARTADDRESS%\":0.00386871},{\"%SMARTADDRESS%\":1.002},{\"%SMARTADDRESS%\":0.00386871},{\"%SMARTADDRESS%\":1.002},{\"%SMARTADDRESS%\":0.00386871},{\"%SMARTADDRESS%\":1.002},{\"%SMARTADDRESS%\":0.00386871},{\"%SMARTADDRESS%\":1.002},{\"%SMARTADDRESS%\":0.00386871}] |
|||
curl -s --url "http://127.0.0.1:7783" --data "{\"userpass\":\"%USERPASS%\",\"method\":\"withdraw\",\"coin\":\"%COIN%\",\"outputs\":%OUTPUTS%}" > withdraw.txt |
|||
type withdraw.txt |
|||
timeout /t 5 /nobreak |
|||
for /f "tokens=4 delims=:," %%a in (' find "hex" "withdraw.txt" ') do ( |
|||
rem echo [%%~a] |
|||
curl -s --url "http://127.0.0.1:7783" --data "{\"userpass\":\"%USERPASS%\",\"method\":\"sendrawtransaction\",\"coin\":\"%COIN%\",\"signedtx\":\"%%~a\"}" |
|||
) |
@ -0,0 +1,14 @@ |
|||
@echo off |
|||
set /p TMPUSERPASS=<userpass |
|||
set USERPASS=%TMPUSERPASS: =% |
|||
rem *** Change coin and outputs before use (!) *** |
|||
set COIN=KMD |
|||
set OUTPUTS=[{\"RDecker69MM5dhDBosUXPNTzfoGqxPQqHu\":0.00007777}] |
|||
curl -s --url "http://127.0.0.1:7783" --data "{\"userpass\":\"%USERPASS%\",\"method\":\"withdraw\",\"coin\":\"%COIN%\",\"outputs\":%OUTPUTS%}" > withdraw.txt |
|||
type withdraw.txt |
|||
timeout /t 5 /nobreak |
|||
for /f "tokens=4 delims=:," %%a in (' find "hex" "withdraw.txt" ') do ( |
|||
rem echo [%%~a] |
|||
curl -s --url "http://127.0.0.1:7783" --data "{\"userpass\":\"%USERPASS%\",\"method\":\"sendrawtransaction\",\"coin\":\"%COIN%\",\"signedtx\":\"%%~a\"}" |
|||
) |
|||
|
@ -0,0 +1,342 @@ |
|||
|
|||
/******************************************************************************
|
|||
* 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_NXT.c
|
|||
// marketmaker
|
|||
//
|
|||
|
|||
|
|||
char *NXTnodes[] = { "62.75.159.113", "91.44.203.238", "82.114.88.225", "78.63.207.76", "188.174.110.224", "91.235.72.49", "213.144.130.91", "209.222.98.250", "216.155.128.10", "178.33.203.157", "162.243.122.251", "69.163.47.173", "193.151.106.129", "78.94.2.74", "192.3.196.10", "173.33.112.87", "104.198.173.28", "35.184.154.126", "174.140.167.239", "23.88.113.131", "198.71.84.173", "178.150.207.53", "23.88.61.53", "192.157.233.106", "192.157.241.212", "23.89.192.88", "23.89.200.27", "192.157.241.139", "23.89.200.63", "23.89.192.98", "163.172.214.102", "176.9.85.5", "80.150.243.88", "80.150.243.92", "80.150.243.98", "109.70.186.198", "146.148.84.237", "104.155.56.82", "104.197.157.140", "37.48.73.249", "146.148.77.226", "84.57.170.200", "107.161.145.131", "80.150.243.97", "80.150.243.93", "80.150.243.100", "80.150.243.95", "80.150.243.91", "80.150.243.99", "80.150.243.96", "93.231.187.177", "212.237.23.85", "35.158.179.254", "46.36.66.41", "185.170.113.79", "163.172.68.112", "78.47.35.210", "77.90.90.75", "94.177.196.134", "212.237.22.215", "94.177.234.11", "167.160.180.199", "54.68.189.9", "94.159.62.14", "195.181.221.89", "185.33.145.94", "195.181.209.245", "195.181.221.38", "195.181.221.162", "185.33.145.12", "185.33.145.176", "178.79.128.235", "94.177.214.120", "94.177.199.41", "94.177.214.200", "94.177.213.201", "212.237.13.162", "195.181.221.236", "195.181.221.185", "185.28.103.187", "185.33.146.244", "217.61.123.71", "195.181.214.45", "195.181.212.99", "195.181.214.46", "195.181.214.215", "195.181.214.68", "217.61.123.118", "195.181.214.79", "217.61.123.14", "217.61.124.100", "195.181.214.111", "85.255.0.176", "81.2.254.116", "217.61.123.184", "195.181.212.231", "94.177.214.110", "195.181.209.164", "104.129.56.238", "85.255.13.64", "167.160.180.206", "217.61.123.226", "167.160.180.208", "93.186.253.127", "212.237.6.208", "94.177.207.190", "217.61.123.119", "85.255.1.245", "217.61.124.157", "37.59.57.141", "167.160.180.58", "104.223.53.14", "217.61.124.69", "195.181.212.103", "85.255.13.141", "104.207.133.204", "71.90.7.107", "107.150.18.108", "23.94.134.161", "80.150.243.13", "80.150.243.11", "185.81.165.52", "80.150.243.8" }; |
|||
|
|||
static char *assetids[][4] = |
|||
{ |
|||
{ "13502152099823770958", "SUPERNETx2", "10000", "10000" }, |
|||
{ "12071612744977229797", "SUPERNET", "10000", "10000" }, |
|||
{ "12071612744977229797", "UNITY", "10000", "10000" }, |
|||
{ "15344649963748848799", "DEX", "1", "100000000" }, |
|||
{ "6883271355794806507", "PANGEA", "10000", "10000" }, |
|||
{ "17911762572811467637", "JUMBLR", "10000", "10000" }, |
|||
{ "17083334802666450484", "BET", "10000", "10000" }, |
|||
{ "13476425053110940554", "CRYPTO", "1000", "100000" }, |
|||
{ "6932037131189568014", "HODL", "1", "100000000" }, |
|||
//{ "3006420581923704757", "SHARK", "10000", "10000" },
|
|||
{ "3006420581923704757", "MSHARK", "10", "10000000" }, |
|||
{ "17571711292785902558", "BOTS", "1", "100000000" }, |
|||
{ "10524562908394749924", "MGW", "1", "100000000" }, |
|||
{ "8217222248380501882", "MESH", "10000", "10000" }, |
|||
{ "15641806960898178066", "TOKEN", "1", "100000000" }, |
|||
}; |
|||
|
|||
void LP_sendtoaddress_line(char *validaddress,char *assetname,uint64_t satoshis,uint64_t txnum) |
|||
{ |
|||
char line[1024],lowerstr[64]; |
|||
if ( strcmp(assetname,"SUPERNETx2") == 0 ) |
|||
{ |
|||
sprintf(line,"fiat/supernet sendtoaddress %s %.8f # txnum.%llu",validaddress,dstr(satoshis),(long long)txnum); |
|||
printf("%s\n",line); |
|||
sprintf(line,"fiat/revs sendtoaddress %s %.8f # txnum.%llu",validaddress,dstr(satoshis),(long long)txnum); |
|||
} |
|||
else |
|||
{ |
|||
if ( strcmp(assetname,"TOKEN") == 0 ) |
|||
strcpy(lowerstr,"supernet"); |
|||
else strcpy(lowerstr,assetname); |
|||
tolowercase(lowerstr); |
|||
sprintf(line,"sleep 1; fiat/%s sendtoaddress %s %.8f # txnum.%llu",lowerstr,validaddress,dstr(satoshis),(long long)txnum); |
|||
} |
|||
printf("%s\n",line); |
|||
} |
|||
|
|||
uint64_t LP_assetid_mult(int32_t *assetindp,char *name,uint64_t assetid) |
|||
{ |
|||
int32_t i; uint64_t mult = 0; |
|||
name[0] = 0; |
|||
*assetindp = -1; |
|||
for (i=0; i<sizeof(assetids)/sizeof(*assetids); i++) |
|||
{ |
|||
if ( assetid == calc_nxt64bits(assetids[i][0]) ) |
|||
{ |
|||
*assetindp = i; |
|||
mult = atoi(assetids[i][3]); |
|||
strcpy(name,assetids[i][1]); |
|||
break; |
|||
} |
|||
} |
|||
return(mult); |
|||
} |
|||
|
|||
cJSON *LP_NXT_message(char *method,uint64_t txnum,char *passphrase) |
|||
{ |
|||
char url[1024],*retstr; cJSON *retjson = 0; |
|||
sprintf(url,"http://127.0.0.1:7876/nxt?requestType=%s&transaction=%llu&secretPhrase=%s",method,(long long)txnum,passphrase); |
|||
//printf("issue.(%s)\n",url);
|
|||
if ( (retstr= issue_curlt(url,LP_HTTP_TIMEOUT)) != 0 ) |
|||
{ |
|||
if ( (retjson= cJSON_Parse(retstr)) != 0 ) |
|||
{ |
|||
|
|||
} |
|||
free(retstr); |
|||
} |
|||
return(retjson); |
|||
} |
|||
|
|||
cJSON *LP_NXT_decrypt(uint64_t txnum,char *account,char *data,char *nonce,char *passphrase) |
|||
{ |
|||
char url[1024],*retstr; cJSON *retjson = 0; |
|||
if ( account != 0 && data != 0 && nonce != 0 && passphrase != 0 ) |
|||
{ |
|||
sprintf(url,"http://127.0.0.1:7876/nxt?requestType=readMessage&transaction=%llu&secretPhrase=%s",(long long)txnum,passphrase); |
|||
if ( (retstr= issue_curlt(url,LP_HTTP_TIMEOUT)) != 0 ) |
|||
{ |
|||
if ( (retjson= cJSON_Parse(retstr)) != 0 ) |
|||
{ |
|||
|
|||
} |
|||
free(retstr); |
|||
} |
|||
} |
|||
return(retjson); |
|||
} |
|||
|
|||
int64_t NXTventure_qty(uint64_t assetid) |
|||
{ |
|||
char url[1024],*retstr; uint64_t qty=0; cJSON *retjson; |
|||
sprintf(url,"http://127.0.0.1:7876/nxt?requestType=getAccountAssets&account=NXT-XRK4-5HYK-5965-9FH4Z&includeAssetInfo=true"); |
|||
if ( (retstr= issue_curlt(url,LP_HTTP_TIMEOUT)) != 0 ) |
|||
{ |
|||
printf("NXT_venture_qty(%s)\n",retstr); |
|||
if ( (retjson= cJSON_Parse(retstr)) != 0 ) |
|||
{ |
|||
free_json(retjson); |
|||
} |
|||
free(retstr); |
|||
} |
|||
//NXT_venture_qty({"accountAssets":[{"quantityQNT":"3900000000","unconfirmedQuantityQNT":"3900000000","decimals":4,"name":"ATOMIC","asset":"11694807213441909013"},{"quantityQNT":"2900000000","unconfirmedQuantityQNT":"2900000000","decimals":8,"name":"NSC","asset":"6775372232354238105"},{"quantityQNT":"750000000","unconfirmedQuantityQNT":"750000000","decimals":4,"name":"omnigames","asset":"7441230892853180965"},{"quantityQNT":"607438148","unconfirmedQuantityQNT":"607438148","decimals":4,"name":"ARDR","asset":"12422608354438203866"},{"quantityQNT":"451991779","unconfirmedQuantityQNT":"451991779","decimals":4,"name":"SuperNET","asset":"12071612744977229797"},{"quantityQNT":"146960000","unconfirmedQuantityQNT":"146960000","decimals":4,"name":"Privatebet","asset":"17083334802666450484"},{"quantityQNT":"79500188","unconfirmedQuantityQNT":"79500188","decimals":3,"name":"crypto777","asset":"13476425053110940554"},{"quantityQNT":"1495473","unconfirmedQuantityQNT":"1495473","decimals":0,"name":"jl777hodl","asset":"6932037131189568014"},{"quantityQNT":"500000","unconfirmedQuantityQNT":"500000","decimals":0,"name":"Boost","asset":"9719950459730291994"},{"quantityQNT":"200000","unconfirmedQuantityQNT":"200000","decimals":0,"name":"NXTforex","asset":"15245281832566929110"},{"quantityQNT":"150000","unconfirmedQuantityQNT":"150000","decimals":0,"name":"NXTsharks","asset":"8049009002993773168"},{"quantityQNT":"100000","unconfirmedQuantityQNT":"100000","decimals":5,"name":"solarweb","asset":"13604572534081373849"},{"quantityQNT":"75000","unconfirmedQuantityQNT":"75000","decimals":0,"name":"SNN","asset":"15113552914305929842"},{"quantityQNT":"57299","unconfirmedQuantityQNT":"57299","decimals":2,"name":"SLEUTH","asset":"4174874835406708311"},{"quantityQNT":"18801","unconfirmedQuantityQNT":"18801","decimals":2,"name":"BTCDdev","asset":"15131486578879082754"},{"quantityQNT":"18767","unconfirmedQuantityQNT":"18767","decimals":2,"name":"longzai","asset":"10955830010602647139"},{"quantityQNT":"13000","unconfirmedQuantityQNT":"13000","decimals":0,"name":"NXTventure","asset":"16212446818542881180"},{"quantityQNT":"7250","unconfirmedQuantityQNT":"7250","decimals":0,"name":"InstantDEX","asset":"15344649963748848799"},{"quantityQNT":"2873","unconfirmedQuantityQNT":"2873","decimals":4,"name":"EDinar","asset":"17740527756732147253"},{"quantityQNT":"39","unconfirmedQuantityQNT":"39","decimals":0,"name":"JebBush","asset":"1929419574701797581"},{"quantityQNT":"30","unconfirmedQuantityQNT":"30","decimals":0,"name":"Hilary","asset":"11814755740231942504"}],"requestProcessingTime":1})
|
|||
return(qty); |
|||
} |
|||
|
|||
void *curl_post(void **cHandlep,char *url,char *userpass,char *postfields,char *hdr0,char *hdr1,char *hdr2,char *hdr3); |
|||
|
|||
void NXTventure_liquidation() |
|||
{ |
|||
/*{"quantityQNT":"607438148","unconfirmedQuantityQNT":"607438148","decimals":4,"name":"ARDR","asset":""},
|
|||
{"quantityQNT":"451991779","unconfirmedQuantityQNT":"451991779","decimals":4,"name":"SuperNET","asset":"12071612744977229797"}, |
|||
{"quantityQNT":"146960000","unconfirmedQuantityQNT":"146960000","decimals":4,"name":"Privatebet","asset":"17083334802666450484"}, |
|||
{"quantityQNT":"79500188","unconfirmedQuantityQNT":"79500188","decimals":3,"name":"crypto777","asset":"13476425053110940554"}, |
|||
{"quantityQNT":"1495473","unconfirmedQuantityQNT":"1495473","decimals":0,"name":"jl777hodl","asset":"6932037131189568014"}, |
|||
{"quantityQNT":"7250","unconfirmedQuantityQNT":"7250","decimals":0,"name":"InstantDEX","asset":"15344649963748848799"},*/ |
|||
char *assetids[][4] = |
|||
{ |
|||
{ "12422608354438203866", "607438148", "ARDR", "10000" }, |
|||
{ "12071612744977229797", "451991779", "SuperNET", "10000" }, |
|||
{ "17083334802666450484", "146960000", "Privatebet", "10000" }, |
|||
{ "13476425053110940554", "79500188", "crypto777", "1000" }, |
|||
{ "6932037131189568014", "1495473", "jl777hodl", "1" }, |
|||
{ "15344649963748848799", "7250", "InstantDEX", "1" }, |
|||
}; |
|||
void *cHandle=0; char *retstr,*retstr2,url[1024],*account; uint64_t txid,qty,qtyA,assetid,sum; double ratio; cJSON *array,*retjson2,*item,*retjson; int32_t i,j,decimals,numassetids=(int32_t)(sizeof(assetids)/sizeof(*assetids)),n=0; |
|||
char *passphrase = ""; |
|||
sprintf(url,"http://127.0.0.1:7876/nxt?requestType=getAssetAccounts&asset=16212446818542881180"); |
|||
if ( (retstr= issue_curlt(url,LP_HTTP_TIMEOUT)) != 0 ) |
|||
{ |
|||
if ( (retjson= cJSON_Parse(retstr)) != 0 ) |
|||
{ |
|||
if ( (array= jarray(&n,retjson,"accountAssets")) != 0 ) |
|||
{ |
|||
for (j=0; j<numassetids; j++) |
|||
{ |
|||
assetid = calc_nxt64bits(assetids[j][0]); |
|||
qtyA = calc_nxt64bits(assetids[j][1]); |
|||
decimals = (int32_t)calc_nxt64bits(assetids[j][3]); |
|||
printf("distribute %llu QNT of %s assetid %llu %.8f\n",(long long)qtyA,assetids[j][2],(long long)assetid,(double)qtyA / decimals); |
|||
sum = 0; |
|||
for (i=0; i<n; i++) |
|||
{ |
|||
item = jitem(array,i); |
|||
qty = j64bits(item,"quantityQNT"); |
|||
ratio = (double)qty / (1000000. - 13000.); |
|||
if ( (account= jstr(item,"accountRS")) != 0 && qtyA*ratio >= 1 ) |
|||
{ |
|||
if ( strcmp(account,"NXT-XRK4-5HYK-5965-9FH4Z") != 0 ) |
|||
{ |
|||
sum += (long long)(qtyA * ratio); |
|||
sprintf(url,"requestType=transferAsset&secretPhrase=%s&recipient=%s&asset=%llu&quantityQNT=%llu&feeNQT=100000000&deadline=60",passphrase,account,(long long)assetid,(long long)(qtyA * ratio)); |
|||
if ( (retstr2= curl_post(&cHandle,"http://127.0.0.1:7876/nxt","",url,"","","","")) != 0 ) |
|||
{ |
|||
if ( (retjson2= cJSON_Parse(retstr2)) != 0 ) |
|||
{ |
|||
txid = j64bits(retjson2,"transaction"); |
|||
printf("%s %.6f %8llu QNT %s -> %llu %.8f txid %llu\n",account,ratio,(long long)qtyA,assetids[j][2],(long long)(qtyA * ratio),((double)(long long)(qtyA * ratio))/decimals,(long long)txid); |
|||
free_json(retjson2); |
|||
} |
|||
free(retstr2); |
|||
} |
|||
usleep(250000); |
|||
} |
|||
} |
|||
} |
|||
printf("%s distribution total %llu QNT %.8f\n",assetids[j][2],(long long)sum,(double)sum/decimals); |
|||
} |
|||
} |
|||
free_json(retjson); |
|||
} |
|||
printf("NXTventure assethodlers.%d\n",n); |
|||
free(retstr); |
|||
} |
|||
} |
|||
|
|||
cJSON *LP_NXT_redeems() |
|||
{ |
|||
char url[1024],*retstr,*recv,*method,*msgstr,assetname[128]; uint64_t totals[2][sizeof(assetids)/sizeof(*assetids)],mult,txnum,assetid,qty; int32_t i,ind,numtx=0,past_marker=0; cJSON *item,*attach,*decjson,*array,*msgjson,*encjson,*retjson=0; |
|||
uint64_t txnum_marker = calc_nxt64bits("5509605741355242617"); |
|||
uint64_t txnum_marker2 = calc_nxt64bits("7256847492742571143"); |
|||
char *passphrase = ""; |
|||
char *account = "NXT-MRBN-8DFH-PFMK-A4DBM"; |
|||
memset(totals,0,sizeof(totals)); |
|||
sprintf(url,"http://127.0.0.1:7876/nxt?requestType=getBlockchainTransactions&account=%s",account); |
|||
//printf("calling (%s)\n",url);
|
|||
if ( (retstr= issue_curlt(url,LP_HTTP_TIMEOUT)) != 0 ) |
|||
{ |
|||
if ( (retjson= cJSON_Parse(retstr)) != 0 ) |
|||
{ |
|||
if ( (array= jarray(&numtx,retjson,"transactions")) != 0 ) |
|||
{ |
|||
for (i=0; i<numtx; i++) |
|||
{ |
|||
msgjson = encjson = decjson = 0; |
|||
txnum = assetid = qty = 0; |
|||
item = jitem(array,i); |
|||
msgstr = jstr(item,"message"); |
|||
txnum = j64bits(item,"transaction"); |
|||
if ( txnum == txnum_marker ) |
|||
past_marker = 1; |
|||
//printf("%d: %s\n",i,jprint(item,0));
|
|||
if ( (recv= jstr(item,"recipientRS")) != 0 && strcmp(recv,"NXT-MRBN-8DFH-PFMK-A4DBM") == 0 ) |
|||
{ |
|||
if ( (attach= jobj(item,"attachment")) != 0 && jint(attach,"version.AssetTransfer") == 1 ) |
|||
{ |
|||
assetid = j64bits(attach,"asset"); |
|||
qty = j64bits(attach,"quantityQNT"); |
|||
//printf("txnum.%llu (%s)\n",(long long)txnum,jprint(attach,0));
|
|||
if ( (msgstr == 0 || msgstr[0] == 0) && jint(attach,"version.PrunablePlainMessage") == 1 ) |
|||
{ |
|||
method = "getPrunableMessage"; |
|||
if ( (msgjson= LP_NXT_message(method,txnum,"test")) != 0 ) |
|||
{ |
|||
msgstr = jstr(msgjson,"message"); |
|||
//printf("%d method.(%s) (%s)\n",i,method,msgstr);
|
|||
} |
|||
} |
|||
if ( msgstr == 0 || msgstr[0] == 0 ) |
|||
msgstr = jstr(attach,"message"); |
|||
if ( msgstr == 0 || msgstr[0] == 0 ) |
|||
{ |
|||
|
|||
if ( (encjson= jobj(attach,"encryptedMessage")) != 0 ) |
|||
{ |
|||
msgstr = "encryptedMessage";//jstr(encjson,"data");
|
|||
if ( (decjson= LP_NXT_decrypt(txnum,account,jstr(encjson,"data"),jstr(encjson,"nonce"),passphrase)) != 0 ) |
|||
{ |
|||
//printf("%s\n",jprint(decjson,0));
|
|||
if ( jstr(decjson,"decryptedMessage") != 0 ) |
|||
msgstr = jstr(decjson,"decryptedMessage"); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
mult = LP_assetid_mult(&ind,assetname,assetid); |
|||
if ( ind >= 0 ) |
|||
totals[past_marker][ind] += qty * mult; |
|||
if ( msgstr != 0 && assetname[0] != 0 && qty != 0 ) |
|||
{ |
|||
char validaddress[64]; int32_t z,n; |
|||
n = (int32_t)strlen(msgstr); |
|||
for (z=0; z<n; z++) |
|||
{ |
|||
if ( msgstr[z] == 'R' ) |
|||
break; |
|||
} |
|||
memset(validaddress,0,sizeof(validaddress)); |
|||
if ( n-z >= 34 ) |
|||
strncpy(validaddress,&msgstr[z],34); |
|||
if ( txnum == calc_nxt64bits("4545341872872347590") ) |
|||
strcpy(validaddress,"RKuwq4oi4mqQ2V4r54mPEthn3TBrEwu2Ni"); |
|||
if ( past_marker == 0 ) |
|||
{ |
|||
if ( strlen(validaddress) == 34 || strlen(validaddress) == 33 ) |
|||
{ |
|||
//printf("%-4d: (%34s) <- %13.5f %10s tx.%llu past_marker.%d\n",i,validaddress,dstr(qty * mult),assetname,(long long)txnum,past_marker);
|
|||
LP_sendtoaddress_line(validaddress,assetname,(qty * mult),txnum); |
|||
} else printf("%-4d: (%34s) <- %13.5f %10s tx.%llu\n",i,msgstr!=0?msgstr:jprint(item,0),dstr(qty * mult),assetname,(long long)txnum); |
|||
} |
|||
} |
|||
if ( msgjson != 0 ) |
|||
free_json(msgjson); |
|||
if ( decjson != 0 ) |
|||
free_json(decjson); |
|||
} |
|||
if ( txnum == txnum_marker2 ) |
|||
break; |
|||
} |
|||
} |
|||
//free_json(retjson);
|
|||
} |
|||
free(retstr); |
|||
} |
|||
printf("\nTotal redeemed.%d\n",numtx); |
|||
for (past_marker=0; past_marker<2; past_marker++) |
|||
{ |
|||
for (i=0; i<sizeof(totals[0])/sizeof(*totals[0]); i++) |
|||
{ |
|||
if ( totals[past_marker][i] != 0 ) |
|||
printf("%-10s %13.5f past_marker.%d\n",assetids[i][1],dstr(totals[past_marker][i]),past_marker); |
|||
} |
|||
printf("\n>>>>>>>>>> already processed:\n"); |
|||
} |
|||
return(retjson); |
|||
} |
|||
|
|||
cJSON *LP_assethbla(char *assetid) |
|||
{ |
|||
char url[1024],*retstr; int32_t n; cJSON *array,*bid=0,*ask=0,*retjson; |
|||
sprintf(url,"http://%s:7876/nxt?requestType=getBidOrders&asset=%s&firstIndex=0&lastIndex=0",NXTnodes[LP_rand() % (sizeof(NXTnodes)/sizeof(*NXTnodes))],assetid); |
|||
if ( (retstr= issue_curlt(url,LP_HTTP_TIMEOUT)) != 0 ) |
|||
{ |
|||
bid = cJSON_Parse(retstr); |
|||
free(retstr); |
|||
} |
|||
sprintf(url,"http://%s:7876/nxt?requestType=getAskOrders&asset=%s&firstIndex=0&lastIndex=0",NXTnodes[LP_rand() % (sizeof(NXTnodes)/sizeof(*NXTnodes))],assetid); |
|||
if ( (retstr= issue_curlt(url,LP_HTTP_TIMEOUT)) != 0 ) |
|||
{ |
|||
ask = cJSON_Parse(retstr); |
|||
free(retstr); |
|||
} |
|||
retjson = cJSON_CreateObject(); |
|||
if ( bid != 0 && ask != 0 ) |
|||
{ |
|||
if ( (array= jarray(&n,bid,"bidOrders")) != 0 ) |
|||
jadd(retjson,"bid",jduplicate(jitem(array,0))); |
|||
if ( (array= jarray(&n,ask,"askOrders")) != 0 ) |
|||
jadd(retjson,"ask",jduplicate(jitem(array,0))); |
|||
} |
|||
if ( bid != 0 ) |
|||
free_json(bid); |
|||
if ( ask != 0 ) |
|||
free_json(ask); |
|||
return(retjson); |
|||
} |
|||
|
@ -0,0 +1,350 @@ |
|||
|
|||
/******************************************************************************
|
|||
* 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_cache.c
|
|||
// marketmaker
|
|||
//
|
|||
|
|||
cJSON *LP_transaction_fromdata(struct iguana_info *coin,bits256 txid,uint8_t *serialized,int32_t len) |
|||
{ |
|||
uint8_t *extraspace; cJSON *txobj; char str[65],str2[65]; struct iguana_msgtx msgtx; bits256 checktxid; |
|||
extraspace = calloc(1,4000000); |
|||
memset(&msgtx,0,sizeof(msgtx)); |
|||
txobj = bitcoin_data2json(coin->symbol,coin->taddr,coin->pubtype,coin->p2shtype,coin->isPoS,coin->height,&checktxid,&msgtx,extraspace,4000000,serialized,len,0,0,coin->zcash); |
|||
//printf("TX.(%s) match.%d\n",jprint(txobj,0),bits256_cmp(txid,checktxid));
|
|||
free(extraspace); |
|||
if ( bits256_cmp(txid,checktxid) != 0 ) |
|||
{ |
|||
printf("%s LP_transaction_fromdata mismatched txid %s vs %s\n",coin->symbol,bits256_str(str,txid),bits256_str(str2,checktxid)); |
|||
free_json(txobj); |
|||
txobj = 0; |
|||
} |
|||
return(txobj); |
|||
} |
|||
|
|||
struct LP_transaction *LP_create_transaction(struct iguana_info *coin,bits256 txid,uint8_t *serialized,int32_t len,int32_t height,long fpos) |
|||
{ |
|||
cJSON *txobj; bits256 spenttxid; int32_t i,spentvout,numvins,numvouts; cJSON *vout,*vin,*vins,*vouts; struct LP_transaction *tx; char str[65]; |
|||
if ( (tx= LP_transactionfind(coin,txid)) != 0 ) |
|||
return(tx); |
|||
if ( (txobj= LP_transaction_fromdata(coin,txid,serialized,len)) != 0 ) |
|||
{ |
|||
vins = jarray(&numvins,txobj,"vin"); |
|||
vouts = jarray(&numvouts,txobj,"vout"); |
|||
tx = LP_transactionadd(coin,txid,height,numvouts,numvins); |
|||
tx->serialized = serialized, tx->len = len; |
|||
// free(serialized), tx->len = 0;
|
|||
tx->fpos = fpos; |
|||
tx->SPV = tx->height = height; |
|||
//printf("tx.%s numvins.%d numvouts.%d\n",bits256_str(str,txid),numvins,numvouts);
|
|||
for (i=0; i<numvouts; i++) |
|||
{ |
|||
vout = jitem(vouts,i); |
|||
tx->outpoints[i].value = LP_value_extract(vout,0); |
|||
tx->outpoints[i].interest = SATOSHIDEN * jdouble(vout,"interest"); |
|||
LP_destaddr(tx->outpoints[i].coinaddr,vout); |
|||
//printf("from transaction init %s %s %s/v%d <- %.8f\n",coin->symbol,tx->outpoints[i].coinaddr,bits256_str(str,txid),i,dstr(tx->outpoints[i].value));
|
|||
LP_address_utxoadd((uint32_t)time(NULL),"LP_create_transaction",coin,tx->outpoints[i].coinaddr,txid,i,tx->outpoints[i].value,height,-1); |
|||
} |
|||
for (i=0; i<numvins; i++) |
|||
{ |
|||
vin = jitem(vins,i); |
|||
spenttxid = jbits256(vin,"txid"); |
|||
spentvout = jint(vin,"vout"); |
|||
if ( i == 0 && bits256_nonz(spenttxid) == 0 ) |
|||
continue; |
|||
if ( (tx= LP_transactionfind(coin,spenttxid)) != 0 ) |
|||
{ |
|||
if ( spentvout < tx->numvouts ) |
|||
{ |
|||
if ( tx->outpoints[spentvout].spendheight <= 0 ) |
|||
{ |
|||
tx->outpoints[spentvout].spendtxid = txid; |
|||
tx->outpoints[spentvout].spendvini = i; |
|||
tx->outpoints[spentvout].spendheight = height > 0 ? height : 1; |
|||
LP_address_utxoadd((uint32_t)time(NULL),"LP_transactioninit iter1",coin,tx->outpoints[spentvout].coinaddr,spenttxid,spentvout,tx->outpoints[spentvout].value,-1,height>0?height:1); |
|||
if ( 0 && strcmp(coin->symbol,"REVS") == 0 ) |
|||
printf("spend %s %s/v%d at ht.%d\n",coin->symbol,bits256_str(str,tx->txid),spentvout,height); |
|||
} |
|||
} else printf("LP_transactioninit: %s spentvout.%d < numvouts.%d spendheight.%d\n",bits256_str(str,spenttxid),spentvout,tx->numvouts,tx->outpoints[spentvout].spendheight); |
|||
} //else printf("LP_transactioninit: couldnt find (%s) ht.%d %s\n",bits256_str(str,spenttxid),height,jprint(vin,0));
|
|||
if ( bits256_cmp(spenttxid,txid) == 0 ) |
|||
printf("spending same tx's %p vout ht.%d %s.[%d] s%d\n",tx,height,bits256_str(str,txid),tx!=0?tx->numvouts:0,spentvout); |
|||
} |
|||
free_json(txobj); |
|||
} |
|||
return(tx); |
|||
} |
|||
|
|||
void LP_SPV_store(struct iguana_info *coin,bits256 txid,int32_t height) |
|||
{ |
|||
FILE *fp; char fname[512]; struct LP_transaction *tx = 0; |
|||
if ( (tx= LP_transactionfind(coin,txid)) != 0 && tx->serialized != 0 && tx->len > 0 && tx->fpos == 0 ) |
|||
{ |
|||
sprintf(fname,"%s/UNSPENTS/%s.SPV",GLOBAL_DBDIR,coin->symbol), OS_portable_path(fname); |
|||
if ( (fp= OS_appendfile(fname)) != 0 ) |
|||
{ |
|||
fwrite(&tx->txid,1,sizeof(tx->txid),fp); |
|||
fwrite(&tx->len,1,sizeof(tx->len),fp); |
|||
fwrite(&tx->height,1,sizeof(tx->height),fp); |
|||
tx->fpos = ftell(fp); |
|||
fwrite(tx->serialized,1,tx->len,fp); |
|||
fclose(fp); |
|||
} |
|||
} //else printf("cant store %s %s tx.%p [%d] fpos.%ld SPV.%d\n",coin->symbol,bits256_str(str,txid),tx,tx!=0?tx->len:-1,tx!=0?tx->fpos:-1,tx!=0?tx->SPV:-1);
|
|||
} |
|||
|
|||
int32_t LP_cacheitem(struct iguana_info *coin,FILE *fp) |
|||
{ |
|||
bits256 txid,hash; long fpos; int32_t offset,retval,height,len; uint8_t *serialized; char str[65],str2[65]; |
|||
fpos = ftell(fp); |
|||
if ( fread(&txid,1,sizeof(txid),fp) == sizeof(txid) && fread(&len,1,sizeof(len),fp) == sizeof(len) && fread(&height,1,sizeof(height),fp) == sizeof(height) && len < 100000 ) |
|||
{ |
|||
offset = (int32_t)(sizeof(txid) + sizeof(len) + sizeof(height)); |
|||
serialized = malloc(len); |
|||
if ( (retval= (int32_t)fread(serialized,1,len,fp)) == len ) |
|||
{ |
|||
hash = bits256_doublesha256(0,serialized,len); |
|||
if ( bits256_cmp(hash,txid) == 0 ) |
|||
{ |
|||
//printf("%s validated in cache\n",bits256_str(str,hash));
|
|||
LP_create_transaction(coin,txid,serialized,len,height,fpos+offset); |
|||
return((int32_t)(ftell(fp) - fpos)); |
|||
} |
|||
printf("%s vs %s did not validated in cache\n",bits256_str(str,hash),bits256_str(str2,txid)); |
|||
} else printf("retval.%d vs len.%d\n",retval,len); |
|||
} else printf("fread error\n"); |
|||
return(-1); |
|||
} |
|||
|
|||
void LP_cacheptrs_init(struct iguana_info *coin) |
|||
{ |
|||
char fname[1024]; FILE *fp; int32_t count,tflag=0; long n,fsize=0,len = 0; |
|||
sprintf(fname,"%s/UNSPENTS/%s.SPV",GLOBAL_DBDIR,coin->symbol), OS_portable_path(fname); |
|||
fp = fopen(fname,"rb"); |
|||
count = 0; |
|||
if ( fp != 0 ) |
|||
{ |
|||
fseek(fp,0,SEEK_END); |
|||
fsize = ftell(fp); |
|||
rewind(fp); |
|||
while ( len < fsize ) |
|||
{ |
|||
if ( (n= LP_cacheitem(coin,fp)) < 0 ) |
|||
{ |
|||
printf("cacheitem error at %s offset.%ld when fsize.%ld\n",coin->symbol,len,fsize); |
|||
tflag = 1; |
|||
break; |
|||
} |
|||
count++; |
|||
len += n; |
|||
} |
|||
printf("loaded %s %d entries total len.%ld\n",fname,count,len); |
|||
fclose(fp); |
|||
} //else printf("couldnt find.(%s)\n",fname);
|
|||
if ( tflag != 0 ) |
|||
OS_truncate(fname,len); |
|||
} |
|||
|
|||
bits256 iguana_merkle(bits256 *tree,int32_t txn_count) |
|||
{ |
|||
int32_t i,n=0,prev; uint8_t serialized[sizeof(bits256) * 2]; |
|||
if ( txn_count == 1 ) |
|||
return(tree[0]); |
|||
prev = 0; |
|||
while ( txn_count > 1 ) |
|||
{ |
|||
if ( (txn_count & 1) != 0 ) |
|||
tree[prev + txn_count] = tree[prev + txn_count-1], txn_count++; |
|||
n += txn_count; |
|||
for (i=0; i<txn_count; i+=2) |
|||
{ |
|||
iguana_rwbignum(1,serialized,sizeof(*tree),tree[prev + i].bytes); |
|||
iguana_rwbignum(1,&serialized[sizeof(*tree)],sizeof(*tree),tree[prev + i + 1].bytes); |
|||
tree[n + (i >> 1)] = bits256_doublesha256(0,serialized,sizeof(serialized)); |
|||
} |
|||
prev = n; |
|||
txn_count >>= 1; |
|||
} |
|||
return(tree[n]); |
|||
} |
|||
|
|||
bits256 validate_merkle(int32_t pos,bits256 txid,cJSON *proofarray,int32_t proofsize) |
|||
{ |
|||
int32_t i; uint8_t serialized[sizeof(bits256) * 2]; bits256 hash,proof; |
|||
hash = txid; |
|||
for (i=0; i<proofsize; i++) |
|||
{ |
|||
proof = jbits256i(proofarray,i); |
|||
if ( (pos & 1) == 0 ) |
|||
{ |
|||
iguana_rwbignum(1,&serialized[0],sizeof(hash),hash.bytes); |
|||
iguana_rwbignum(1,&serialized[sizeof(hash)],sizeof(proof),proof.bytes); |
|||
} |
|||
else |
|||
{ |
|||
iguana_rwbignum(1,&serialized[0],sizeof(proof),proof.bytes); |
|||
iguana_rwbignum(1,&serialized[sizeof(hash)],sizeof(hash),hash.bytes); |
|||
} |
|||
hash = bits256_doublesha256(0,serialized,sizeof(serialized)); |
|||
pos >>= 1; |
|||
} |
|||
return(hash); |
|||
} |
|||
|
|||
bits256 LP_merkleroot(struct iguana_info *coin,struct electrum_info *ep,int32_t height) |
|||
{ |
|||
cJSON *hdrobj; bits256 merkleroot; |
|||
memset(merkleroot.bytes,0,sizeof(merkleroot)); |
|||
if ( coin->cachedmerkleheight == height ) |
|||
return(coin->cachedmerkle); |
|||
if ( (hdrobj= electrum_getheader(coin->symbol,ep,&hdrobj,height)) != 0 ) |
|||
{ |
|||
if ( jobj(hdrobj,"merkle_root") != 0 ) |
|||
{ |
|||
merkleroot = jbits256(hdrobj,"merkle_root"); |
|||
if ( bits256_nonz(merkleroot) != 0 ) |
|||
{ |
|||
coin->cachedmerkle = merkleroot; |
|||
coin->cachedmerkleheight = height; |
|||
} |
|||
} |
|||
free_json(hdrobj); |
|||
} else printf("couldnt get header for ht.%d\n",height); |
|||
return(merkleroot); |
|||
} |
|||
|
|||
int32_t LP_merkleproof(struct iguana_info *coin,char *coinaddr,struct electrum_info *ep,bits256 txid,int32_t height) |
|||
{ |
|||
struct LP_transaction *tx=0; cJSON *merkobj,*merkles,*retjson; bits256 roothash,merkleroot; int32_t m,ht=0,SPV = 0; |
|||
if ( height <= 0 ) |
|||
return(0); |
|||
if ( (tx= LP_transactionfind(coin,txid)) == 0 && strcmp(coinaddr,coin->smartaddr) == 0 ) |
|||
{ |
|||
if ( (retjson= electrum_transaction(&ht,coin->symbol,ep,&retjson,txid,0)) != 0 ) |
|||
free_json(retjson); |
|||
} |
|||
if ( tx != 0 ) |
|||
{ |
|||
if ( tx->height == 0 ) |
|||
{ |
|||
if ( height != 0 ) |
|||
tx->height = height; |
|||
else if ( ht != 0 ) |
|||
tx->height = ht; |
|||
height = tx->height; |
|||
} |
|||
if ( tx->SPV > 0 ) |
|||
return(tx->SPV); |
|||
} |
|||
if ( (merkobj= electrum_getmerkle(coin->symbol,ep,&merkobj,txid,height)) != 0 ) |
|||
{ |
|||
char str[65],str2[65],str3[65]; |
|||
SPV = 0; |
|||
memset(roothash.bytes,0,sizeof(roothash)); |
|||
if ( (merkles= jarray(&m,merkobj,"merkle")) != 0 ) |
|||
{ |
|||
roothash = validate_merkle(jint(merkobj,"pos"),txid,merkles,m); |
|||
merkleroot = LP_merkleroot(coin,ep,height); |
|||
if ( bits256_nonz(merkleroot) != 0 ) |
|||
{ |
|||
if ( bits256_cmp(merkleroot,roothash) == 0 ) |
|||
{ |
|||
SPV = height; |
|||
LP_SPV_store(coin,txid,height); |
|||
if ( tx != 0 ) |
|||
{ |
|||
tx->SPV = height; |
|||
if ( strcmp(coinaddr,coin->smartaddr) != 0 && tx->serialized != 0 ) |
|||
{ |
|||
free(tx->serialized); |
|||
tx->serialized = 0; |
|||
tx->len = 0; |
|||
} |
|||
} |
|||
//printf("validated MERK %s ht.%d -> %s root.(%s)\n",bits256_str(str,txid),height,jprint(merkobj,0),bits256_str(str2,roothash));
|
|||
} |
|||
else |
|||
{ |
|||
SPV = -1; |
|||
printf("ERROR MERK %s ht.%d -> %s root.(%s) vs %s\n",bits256_str(str,txid),height,jprint(merkobj,0),bits256_str(str2,roothash),bits256_str(str3,merkleroot)); |
|||
} |
|||
} else SPV = 0; |
|||
} |
|||
if ( SPV < 0 ) |
|||
{ |
|||
printf("MERKLE DIDNT VERIFY.%s %s ht.%d (%s)\n",coin->symbol,bits256_str(str,txid),height,jprint(merkobj,0)); |
|||
if ( jobj(merkobj,"error") != 0 ) |
|||
SPV = 0; // try again later
|
|||
} |
|||
free_json(merkobj); |
|||
} |
|||
return(SPV); |
|||
} |
|||
|
|||
char *LP_unspents_filestr(char *symbol,char *addr) |
|||
{ |
|||
char fname[1024]; long fsize; |
|||
sprintf(fname,"%s/UNSPENTS/%s_%s",GLOBAL_DBDIR,symbol,addr), OS_portable_path(fname); |
|||
return(OS_filestr(&fsize,fname)); |
|||
} |
|||
|
|||
void LP_unspents_cache(char *symbol,char *addr,char *arraystr,int32_t updatedflag) |
|||
{ |
|||
char fname[1024]; FILE *fp=0; |
|||
sprintf(fname,"%s/UNSPENTS/%s_%s",GLOBAL_DBDIR,symbol,addr), OS_portable_path(fname); |
|||
//printf("unspents cache.(%s) for %s %s, updated.%d\n",fname,symbol,addr,updatedflag);
|
|||
if ( updatedflag == 0 && (fp= fopen(fname,"rb")) == 0 ) |
|||
updatedflag = 1; |
|||
else if ( fp != 0 ) |
|||
fclose(fp); |
|||
if ( updatedflag != 0 && (fp= fopen(fname,"wb")) != 0 ) |
|||
{ |
|||
fwrite(arraystr,1,strlen(arraystr),fp); |
|||
fclose(fp); |
|||
} |
|||
} |
|||
|
|||
uint64_t LP_unspents_load(char *symbol,char *addr) |
|||
{ |
|||
char *arraystr; uint64_t balance = 0; int32_t i,n; bits256 zero; cJSON *retjson,*item; struct iguana_info *coin; |
|||
if ( (coin= LP_coinfind(symbol)) != 0 ) |
|||
{ |
|||
if ( (arraystr= LP_unspents_filestr(symbol,addr)) != 0 ) |
|||
{ |
|||
if ( (retjson= cJSON_Parse(arraystr)) != 0 ) |
|||
{ |
|||
//printf("PROCESS UNSPENTS %s\n",arraystr);
|
|||
if ( (n= cJSON_GetArraySize(retjson)) > 0 ) |
|||
{ |
|||
for (i=0; i<n; i++) |
|||
{ |
|||
item = jitem(retjson,i); |
|||
balance += j64bits(item,"value"); |
|||
} |
|||
} |
|||
memset(zero.bytes,0,sizeof(zero)); |
|||
electrum_process_array(coin,coin->electrum,addr,retjson,1,zero,zero); |
|||
free_json(retjson); |
|||
} |
|||
free(arraystr); |
|||
} |
|||
} |
|||
return(balance); |
|||
} |
|||
|
|||
|
|||
|
@ -0,0 +1,650 @@ |
|||
|
|||
/******************************************************************************
|
|||
* 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_instantdex.c
|
|||
// marketmaker
|
|||
//
|
|||
|
|||
void LP_instantdex_txidaddfname(char *fname,char *afname,char *coinaddr) |
|||
{ |
|||
if ( coinaddr == 0 || coinaddr[0] == 0 ) |
|||
{ |
|||
sprintf(fname,"%s/instantdex.json",GLOBAL_DBDIR); |
|||
sprintf(afname,"%s/instantdex_append.json",GLOBAL_DBDIR); |
|||
} |
|||
else |
|||
{ |
|||
sprintf(fname,"%s/instantdex_%s.json",GLOBAL_DBDIR,coinaddr); |
|||
sprintf(afname,"%s/instantdex_%s_append.json",GLOBAL_DBDIR,coinaddr); |
|||
} |
|||
} |
|||
|
|||
cJSON *LP_instantdex_txids(int32_t appendonly,char *coinaddr) |
|||
{ |
|||
char *filestr,fname[1024],afname[1024]; long fsize; cJSON *retjson=0; |
|||
LP_instantdex_txidaddfname(fname,afname,coinaddr); |
|||
if ( (filestr= OS_filestr(&fsize,appendonly != 0 ? afname : fname)) != 0 ) |
|||
{ |
|||
retjson = cJSON_Parse(filestr); |
|||
free(filestr); |
|||
} else printf("couldnt open (%s) or (%s)\n",fname,afname); |
|||
return(retjson); |
|||
} |
|||
|
|||
void LP_instantdex_filewrite(int32_t appendfile,cJSON *array,char *coinaddr) |
|||
{ |
|||
FILE *fp; char *filestr,fname[1024],afname[1024]; |
|||
LP_instantdex_txidaddfname(fname,afname,coinaddr); |
|||
if ( (fp= fopen(appendfile == 0 ? fname : afname,"wb")) != 0 ) |
|||
{ |
|||
filestr = jprint(array,0); |
|||
fwrite(filestr,1,strlen(filestr)+1,fp); |
|||
fclose(fp); |
|||
free(filestr); |
|||
} |
|||
} |
|||
|
|||
void LP_instantdex_deposituniq(FILE *fp,bits256 txid) |
|||
{ |
|||
int32_t i,n; bits256 prevtxid; char str[65]; |
|||
n = (int32_t)(ftell(fp) / sizeof(txid)); |
|||
for (i=0; i<n; i++) |
|||
{ |
|||
fseek(fp,sizeof(prevtxid) * i,SEEK_SET); |
|||
fread(&prevtxid,1,sizeof(prevtxid),fp); |
|||
if ( bits256_cmp(prevtxid,txid) == 0 ) |
|||
{ |
|||
//printf("%s duplicate of deposits[%d]\n",bits256_str(str,prevtxid),i);
|
|||
break; |
|||
} |
|||
} |
|||
if ( i == n ) |
|||
{ |
|||
fwrite(&txid,1,sizeof(txid),fp); |
|||
printf("uniq %s, ftell.%ld\n",bits256_str(str,txid),ftell(fp)); |
|||
} else fseek(fp,n * sizeof(txid),SEEK_SET); |
|||
} |
|||
|
|||
void LP_instantdex_filescreate(char *coinaddr) |
|||
{ |
|||
char fname[512]; FILE *fp; bits256 txid; int32_t i,n; cJSON *array,*newarray,*txobj; |
|||
sprintf(fname,"%s/deposits.%s",GLOBAL_DBDIR,coinaddr), OS_compatible_path(fname); |
|||
if ( (fp= fopen(fname,"rb")) != 0 ) |
|||
{ |
|||
array = cJSON_CreateArray(); |
|||
newarray = cJSON_CreateArray(); |
|||
fseek(fp,0,SEEK_END); |
|||
n = (int32_t)(ftell(fp) / sizeof(txid)); |
|||
for (i=0; i<n; i++) |
|||
{ |
|||
fseek(fp,sizeof(txid) * i,SEEK_SET); |
|||
fread(&txid,1,sizeof(txid),fp); |
|||
jaddibits256(array,txid); |
|||
if ( (txobj= LP_gettxout("KMD",coinaddr,txid,0)) != 0 ) |
|||
free_json(txobj); |
|||
else |
|||
{ |
|||
char str[65]; printf("%s/v%d is already spent\n",bits256_str(str,txid),0); |
|||
continue; |
|||
} |
|||
jaddibits256(newarray,txid); |
|||
} |
|||
fclose(fp); |
|||
LP_instantdex_filewrite(0,newarray,coinaddr); |
|||
free_json(newarray); |
|||
LP_instantdex_filewrite(1,array,coinaddr); |
|||
free_json(array); |
|||
} |
|||
} |
|||
|
|||
void LP_instantdex_depositadd(char *coinaddr,bits256 txid) |
|||
{ |
|||
FILE *fp; struct iguana_info *coin; char fname[512],*addr; bits256 prevtxid; cJSON *array; int32_t i,n,iter; |
|||
coin = LP_coinfind("KMD"); |
|||
sprintf(fname,"%s/deposits.%s",GLOBAL_DBDIR,coinaddr), OS_compatible_path(fname); |
|||
if ( (fp= fopen(fname,"rb+")) == 0 ) |
|||
{ |
|||
if ( (fp= fopen(fname,"wb+")) != 0 ) |
|||
{ |
|||
for (iter=0; iter<4; iter++) |
|||
{ |
|||
if ( iter < 2 ) |
|||
addr = coinaddr; |
|||
else addr = ""; |
|||
if ( coin != 0 && (array= LP_instantdex_txids(iter&1,addr)) != 0 ) |
|||
{ |
|||
if ( (n= cJSON_GetArraySize(array)) > 0 ) |
|||
{ |
|||
for (i=0; i<n; i++) |
|||
{ |
|||
prevtxid = jbits256i(array,i); |
|||
//char str[65]; printf("instantdex iter.%d i.%d check %s\n",iter,i,bits256_str(str,prevtxid));
|
|||
if ( LP_instantdex_creditcalc(coin,0,prevtxid,coinaddr) > 0 ) |
|||
{ |
|||
LP_instantdex_deposituniq(fp,prevtxid); |
|||
fflush(fp); |
|||
} |
|||
} |
|||
} |
|||
free_json(array); |
|||
} |
|||
} |
|||
} |
|||
} else fseek(fp,0,SEEK_END); |
|||
if ( fp != 0 && bits256_nonz(txid) != 0 ) |
|||
{ |
|||
LP_instantdex_deposituniq(fp,txid); |
|||
fclose(fp); |
|||
} |
|||
LP_instantdex_filescreate(coinaddr); |
|||
} |
|||
|
|||
int32_t LP_deposit_addr(char *p2shaddr,uint8_t *script,uint8_t taddr,uint8_t p2shtype,uint32_t timestamp,uint8_t *pubsecp33) |
|||
{ |
|||
uint8_t elsepub33[33],p2sh_rmd160[20]; int32_t n; |
|||
decode_hex(elsepub33,33,BOTS_BONDPUBKEY33); |
|||
n = bitcoin_performancebond(p2sh_rmd160,script,0,timestamp,pubsecp33,elsepub33); |
|||
bitcoin_address(p2shaddr,taddr,p2shtype,script,n); |
|||
return(n); |
|||
} |
|||
|
|||
char *LP_instantdex_deposit(struct iguana_info *coin,int32_t weeks,double amount,int32_t broadcast) |
|||
{ |
|||
char p2shaddr[64],*retstr,*hexstr; uint8_t script[512]; int32_t weeki,scriptlen; cJSON *argjson,*retjson,*array,*item,*obj; uint32_t timestamp; bits256 txid,sendtxid; uint64_t amount64; |
|||
if ( strcmp(coin->symbol,"KMD") != 0 ) |
|||
return(clonestr("{\"error\":\"instantdex deposit must be in KMD\"}")); |
|||
if ( amount < 10.0 ) |
|||
return(clonestr("{\"error\":\"minimum instantdex deposit is 10 KMD\"}")); |
|||
if ( weeks <= 0 || weeks > 52 ) |
|||
return(clonestr("{\"error\":\"weeks must be between 1 and 52\"}")); |
|||
if ( weeks > 0 ) |
|||
{ |
|||
timestamp = (uint32_t)time(NULL); |
|||
timestamp /= LP_WEEKMULT; |
|||
timestamp += weeks+2; |
|||
timestamp *= LP_WEEKMULT; |
|||
weeki = (timestamp - LP_FIRSTWEEKTIME) / LP_WEEKMULT; |
|||
if ( weeks >= 10000 ) |
|||
return(clonestr("{\"error\":\"numweeks must be less than 10000\"}")); |
|||
} else timestamp = (uint32_t)time(NULL) + 300, weeki = 0; |
|||
scriptlen = LP_deposit_addr(p2shaddr,script,coin->taddr,coin->p2shtype,timestamp,G.LP_pubsecp); |
|||
argjson = cJSON_CreateObject(); |
|||
array = cJSON_CreateArray(); |
|||
item = cJSON_CreateObject(); |
|||
jaddnum(item,p2shaddr,amount); |
|||
jaddi(array,item); |
|||
item = cJSON_CreateObject(); |
|||
amount64 = (amount * SATOSHIDEN) / 1000; |
|||
amount64 = (amount64 / 10000) * 10000 + weeki; |
|||
jaddnum(item,BOTS_BONDADDRESS,dstr(amount64)); |
|||
jaddi(array,item); |
|||
item = cJSON_CreateObject(); |
|||
jaddnum(item,coin->smartaddr,0.0001); |
|||
jaddi(array,item); |
|||
jadd(argjson,"outputs",array); |
|||
//printf("deposit.(%s)\n",jprint(argjson,0));
|
|||
if ( (retstr= LP_withdraw(coin,argjson)) != 0 ) |
|||
{ |
|||
if ( (retjson= cJSON_Parse(retstr)) != 0 ) |
|||
{ |
|||
if ( jobj(retjson,"result") != 0 ) |
|||
jdelete(retjson,"result"); |
|||
jaddstr(retjson,"address",p2shaddr); |
|||
jaddnum(retjson,"expiration",timestamp); |
|||
jaddnum(retjson,"deposit",amount); |
|||
if ( (obj= jobj(retjson,"complete")) != 0 && is_cJSON_True(obj) != 0 && (hexstr= jstr(retjson,"hex")) != 0 ) |
|||
{ |
|||
txid = jbits256(retjson,"txid"); |
|||
if ( broadcast != 0 ) |
|||
{ |
|||
if (bits256_nonz(txid) != 0 ) |
|||
{ |
|||
sendtxid = LP_broadcast("deposit","KMD",hexstr,txid); |
|||
if ( bits256_cmp(sendtxid,txid) != 0 ) |
|||
{ |
|||
jaddstr(retjson,"error","broadcast txid mismatch"); |
|||
jaddbits256(retjson,"broadcast",sendtxid); |
|||
free(retstr); |
|||
return(jprint(retjson,1)); |
|||
} |
|||
else |
|||
{ |
|||
jaddstr(retjson,"result","success"); |
|||
jaddbits256(retjson,"broadcast",sendtxid); |
|||
LP_instantdex_depositadd(coin->smartaddr,txid); |
|||
free(retstr); |
|||
return(jprint(retjson,1)); |
|||
} |
|||
} |
|||
else |
|||
{ |
|||
jaddstr(retjson,"error","couldnt broadcast since no txid created"); |
|||
free(retstr); |
|||
return(jprint(retjson,1)); |
|||
} |
|||
} |
|||
else |
|||
{ |
|||
jaddstr(retjson,"result","success"); |
|||
free(retstr); |
|||
return(jprint(retjson,1)); |
|||
} |
|||
} |
|||
else |
|||
{ |
|||
jaddstr(retjson,"error","couldnt create deposit txid"); |
|||
free(retstr); |
|||
return(jprint(retjson,1)); |
|||
} |
|||
free_json(retjson); |
|||
} |
|||
free(retstr); |
|||
} |
|||
return(clonestr("{\"error\":\"error with LP_withdraw for instantdex deposit\"}")); |
|||
} |
|||
|
|||
int64_t LP_claimtx(void *ctx,struct iguana_info *coin,bits256 *claimtxidp,bits256 utxotxid,int32_t utxovout,uint64_t satoshis,char *vinaddr,uint32_t claimtime,uint8_t *redeemscript,int32_t redeemlen) |
|||
{ |
|||
uint8_t userdata[2]; char *signedtx; bits256 signedtxid,sendtxid; int32_t isbots,userdatalen; int64_t destamount,sum = 0; |
|||
if ( strcmp(coin->smartaddr,BOTS_BONDADDRESS) == 0 ) |
|||
isbots = 1; |
|||
else isbots = 0; |
|||
userdata[0] = (isbots == 0) ? 0x51 : 0; |
|||
userdatalen = 1; |
|||
utxovout = 0; |
|||
memset(claimtxidp,0,sizeof(*claimtxidp)); |
|||
char str[65]; printf("LP_claimtx satoshis %.8f %s/v%d\n",dstr(satoshis),bits256_str(str,utxotxid),utxovout); |
|||
if ( (signedtx= basilisk_swap_bobtxspend(&signedtxid,10000,"instantdexclaim",coin->symbol,coin->wiftaddr,coin->taddr,coin->pubtype,coin->p2shtype,coin->isPoS,coin->wiftype,ctx,G.LP_privkey,0,redeemscript,redeemlen,userdata,userdatalen,utxotxid,utxovout,coin->smartaddr,G.LP_pubsecp,0,claimtime,&destamount,0,0,vinaddr,1,coin->zcash)) != 0 ) |
|||
{ |
|||
printf("signedtx.(%s)\n",signedtx); |
|||
sendtxid = LP_broadcast("claim","KMD",signedtx,signedtxid); |
|||
if ( bits256_cmp(sendtxid,signedtxid) == 0 ) |
|||
{ |
|||
*claimtxidp = sendtxid; |
|||
sum += (satoshis - coin->txfee); |
|||
} |
|||
else printf("error sending %s\n",bits256_str(str,signedtxid)); |
|||
free(signedtx); |
|||
} else printf("error claiming instantdex deposit %s/v%d %.8f\n",bits256_str(str,utxotxid),utxovout,dstr(satoshis)); |
|||
return(sum); |
|||
} |
|||
|
|||
int32_t LP_claim_submit(void *ctx,cJSON *txids,int64_t *sump,struct iguana_info *coin,bits256 utxotxid) |
|||
{ |
|||
uint8_t redeemscript[512]; bits256 claimtxid; cJSON *txjson,*vout0,*vout1,*vout2,*vouts,*item; int32_t numvouts; char str[65],vinaddr[64],destaddr[64],checkaddr[64]; int32_t j,utxovout,flagi = 0,redeemlen,weeki,iter; int64_t weeksatoshis,satoshis; uint32_t expiration,claimtime; |
|||
if ( (txjson= LP_gettx(coin->symbol,utxotxid,1)) != 0 ) |
|||
{ |
|||
if ( (vouts= jarray(&numvouts,txjson,"vout")) != 0 && numvouts >= 3 ) |
|||
{ |
|||
vout0 = jitem(vouts,0); |
|||
LP_destaddr(vinaddr,vout0); |
|||
satoshis = LP_value_extract(vout0,1); |
|||
vout2 = jitem(vouts,2); |
|||
LP_destaddr(destaddr,vout2); |
|||
if ( strcmp(destaddr,coin->smartaddr) == 0 ) |
|||
{ |
|||
vout1 = jitem(vouts,1); |
|||
weeksatoshis = LP_value_extract(vout1,0); |
|||
weeki = (int32_t)(weeksatoshis % 10000); |
|||
for (iter=0; iter<2; iter++) |
|||
for (j=-168; j<=168; j++) |
|||
{ |
|||
if ( iter == 1 ) |
|||
expiration = ((weeki * LP_WEEKMULTBAD + j*3600) + LP_FIRSTWEEKTIME); |
|||
else expiration = ((weeki * LP_WEEKMULT + j*3600) + LP_FIRSTWEEKTIME); |
|||
redeemlen = LP_deposit_addr(checkaddr,redeemscript,coin->taddr,coin->p2shtype,expiration,G.LP_pubsecp); |
|||
if ( strcmp(checkaddr,vinaddr) == 0 ) |
|||
{ |
|||
flagi = 1; |
|||
claimtime = (uint32_t)time(NULL)-777; |
|||
item = cJSON_CreateObject(); |
|||
jaddbits256(item,"txid",utxotxid); |
|||
jaddnum(item,"deposit",dstr(LP_value_extract(vout0,0))); |
|||
if ( coin->electrum == 0 ) |
|||
jaddnum(item,"interest",dstr(satoshis)-dstr(LP_value_extract(vout0,0))); |
|||
else jaddnum(item,"interest",dstr(LP_komodo_interest(utxotxid,satoshis))); |
|||
if ( claimtime <= expiration ) |
|||
{ |
|||
printf("iter.%d j.%d claimtime.%u vs %u, wait %d seconds to %s claim %.8f\n",iter,j,claimtime,expiration,(int32_t)expiration-claimtime,bits256_str(str,utxotxid),dstr(satoshis)); |
|||
jaddnum(item,"waittime",(int32_t)expiration-claimtime); |
|||
jaddi(txids,item); |
|||
break; |
|||
} |
|||
else |
|||
{ |
|||
utxovout = 0; |
|||
*sump += LP_claimtx(ctx,coin,&claimtxid,utxotxid,utxovout,satoshis,vinaddr,claimtime,redeemscript,redeemlen); |
|||
if ( bits256_nonz(claimtxid) != 0 ) |
|||
{ |
|||
jaddbits256(item,"claimtxid",claimtxid); |
|||
jaddi(txids,item); |
|||
} |
|||
} |
|||
} //else printf("expiration.%u j.%d checkaddr.(%s) != vinaddr.%s\n",expiration,j,checkaddr,vinaddr);
|
|||
if ( flagi != 0 ) |
|||
break; |
|||
} |
|||
} else printf("vout2 dest.(%s) != %s\n",destaddr,coin->smartaddr); |
|||
} else printf("numvouts %d != 3\n",numvouts); |
|||
free_json(txjson); |
|||
} else printf("cant get transaction flagi.%d\n",flagi); |
|||
return(flagi); |
|||
} |
|||
|
|||
char *LP_instantdex_claim(struct iguana_info *coin) |
|||
{ |
|||
static void *ctx; static int32_t firsttime = 1; |
|||
int32_t i,n; cJSON *array,*txids,*newarray,*retjson; int64_t sum; bits256 utxotxid; |
|||
if ( ctx == 0 ) |
|||
ctx = bitcoin_ctx(); |
|||
if ( strcmp(coin->symbol,"KMD") != 0 ) |
|||
return(clonestr("{\"error\":\"instantdex deposit must be in KMD\"}")); |
|||
sum = 0; |
|||
txids = cJSON_CreateArray(); |
|||
newarray = cJSON_CreateArray(); |
|||
if ( (array= LP_instantdex_txids(firsttime,coin->smartaddr)) != 0 ) |
|||
{ |
|||
printf("claiming from.(%s)\n",jprint(array,0)); |
|||
if ( (n= cJSON_GetArraySize(array)) > 0 ) |
|||
{ |
|||
for (i=0; i<n; i++) |
|||
{ |
|||
utxotxid = jbits256i(array,i); |
|||
//char str[65]; printf("%s\n",bits256_str(str,utxotxid));
|
|||
if ( LP_claim_submit(ctx,txids,&sum,coin,utxotxid) == 0 ) |
|||
jaddibits256(newarray,utxotxid); |
|||
} |
|||
} |
|||
free_json(array); |
|||
} |
|||
firsttime = 0; |
|||
if ( cJSON_GetArraySize(newarray) > 0 ) |
|||
LP_instantdex_filewrite(0,newarray,coin->smartaddr); |
|||
free_json(newarray); |
|||
retjson = cJSON_CreateObject(); |
|||
jaddstr(retjson,"result","success"); |
|||
jaddnum(retjson,"claimed",dstr(sum)); |
|||
jadd(retjson,"txids",txids); |
|||
return(jprint(retjson,1)); |
|||
} |
|||
|
|||
int64_t LP_instantdex_credit(int32_t dispflag,char *coinaddr,int64_t satoshis,int32_t weeki,char *p2shaddr,bits256 txid) |
|||
{ |
|||
uint32_t timestamp; struct LP_address *ap; struct iguana_info *coin = LP_coinfind("KMD"); |
|||
if ( coin != 0 ) |
|||
{ |
|||
timestamp = LP_FIRSTWEEKTIME + weeki*LP_WEEKMULT; |
|||
if ( (ap= LP_address(coin,coinaddr)) != 0 && time(NULL) < timestamp-60*3600 ) |
|||
{ |
|||
ap->instantdex_credits += satoshis; |
|||
ap->didinstantdex = 1; |
|||
if ( 0 && dispflag != 0 ) |
|||
printf("InstantDEX credit.(%s) %.8f weeki.%d (%s) -> sum %.8f\n",coinaddr,dstr(satoshis),weeki,p2shaddr,dstr(ap->instantdex_credits)); |
|||
return(satoshis); |
|||
} else printf("null ap.%p or expired %ld\n",ap,time(NULL) - (timestamp-60*3600)); |
|||
} |
|||
return(0); |
|||
} |
|||
|
|||
int64_t LP_instantdex_creditcalc(struct iguana_info *coin,int32_t dispflag,bits256 txid,char *refaddr) |
|||
{ |
|||
cJSON *txjson,*vouts,*txobj,*item; int64_t satoshis=0,amount64; int32_t weeki,numvouts; char destaddr[64],p2shaddr[64]; |
|||
if ( (txjson= LP_gettx(coin->symbol,txid,0)) != 0 ) |
|||
{ |
|||
// vout0 deposit, vout1 botsfee, vout2 smartaddress
|
|||
if ( (vouts= jarray(&numvouts,txjson,"vout")) > 0 && numvouts >= 3 && LP_destaddr(destaddr,jitem(vouts,2)) == 0 ) |
|||
{ |
|||
if ( refaddr != 0 && strcmp(refaddr,destaddr) != 0 ) |
|||
{ |
|||
printf("LP_instantdex_creditcalc for (%s) but deposit sent for (%s)\n",refaddr,destaddr); |
|||
} |
|||
else |
|||
{ |
|||
amount64 = LP_value_extract(jitem(vouts,1),0); |
|||
weeki = (amount64 % 10000); |
|||
item = jitem(vouts,0); |
|||
satoshis = LP_value_extract(item,0); |
|||
//char str[65]; printf("%s %s funded %.8f weeki.%d (%s)\n",bits256_str(str,txid),destaddr,dstr(satoshis),weeki,jprint(item,0));
|
|||
if ( LP_destaddr(p2shaddr,item) == 0 ) |
|||
{ |
|||
if ( (txobj= LP_gettxout(coin->symbol,p2shaddr,txid,0)) != 0 ) |
|||
{ |
|||
free_json(txobj); |
|||
LP_instantdex_credit(dispflag,destaddr,satoshis,weeki,p2shaddr,txid); |
|||
} else printf("already spent\n"); |
|||
} else printf("error getting p2shaddr.(%s)\n",p2shaddr); |
|||
} |
|||
} |
|||
free_json(txjson); |
|||
} |
|||
return(satoshis); |
|||
} |
|||
|
|||
#ifdef bruteforce |
|||
void LP_instantdex_deposits(struct iguana_info *coin) |
|||
{ |
|||
static int dispflag = 1; |
|||
cJSON *array,*item; int32_t i,n,height,vout; bits256 txid; struct LP_address *ap,*tmp; |
|||
if ( coin->electrum != 0 )//&& coin->electruminstantdex != 0 )
|
|||
return; |
|||
HASH_ITER(hh,coin->addresses,ap,tmp) |
|||
{ |
|||
ap->instantdex_credits = 0; |
|||
} |
|||
if ( (array= LP_listreceivedbyaddress("KMD",BOTS_BONDADDRESS)) != 0 ) |
|||
{ |
|||
//printf("instantdex.(%s)\n",jprint(array,0));
|
|||
if ( (n= cJSON_GetArraySize(array)) > 0 ) |
|||
{ |
|||
for (i=0; i<n; i++) |
|||
{ |
|||
if ( coin->electrum != 0 ) |
|||
{ |
|||
item = jitem(array,i); |
|||
LP_listunspent_parseitem(coin,&txid,&vout,&height,item); |
|||
} else txid = jbits256i(array,i); |
|||
LP_instantdex_creditcalc(coin,dispflag,txid,0); |
|||
} |
|||
} |
|||
free_json(array); |
|||
} |
|||
dispflag = 0; |
|||
} |
|||
#endif |
|||
|
|||
int64_t LP_dynamictrust(int64_t credits,bits256 pubkey,int64_t kmdvalue) |
|||
{ |
|||
struct LP_pubswap *ptr,*tmp; struct LP_swapstats *sp; struct LP_pubkey_info *pubp; struct LP_address *ap; char coinaddr[64]; struct iguana_info *coin; int64_t swaps_kmdvalue = 0; |
|||
if ( (coin= LP_coinfind("KMD")) != 0 && (pubp= LP_pubkeyfind(pubkey)) != 0 ) |
|||
{ |
|||
bitcoin_address(coinaddr,coin->taddr,coin->pubtype,pubp->pubsecp,33); |
|||
DL_FOREACH_SAFE(pubp->bobswaps,ptr,tmp) |
|||
{ |
|||
if ( (sp= ptr->swap) != 0 && LP_swap_finished(sp,1) == 0 ) |
|||
swaps_kmdvalue += LP_kmdvalue(sp->Q.srccoin,sp->Q.satoshis); |
|||
} |
|||
DL_FOREACH_SAFE(pubp->aliceswaps,ptr,tmp) |
|||
{ |
|||
if ( (sp= ptr->swap) != 0 && LP_swap_finished(sp,1) == 0 ) |
|||
swaps_kmdvalue += LP_kmdvalue(sp->Q.destcoin,sp->Q.destsatoshis); |
|||
} |
|||
if ( credits == 0 && (ap= LP_address(coin,coinaddr)) != 0 ) |
|||
credits = ap->instantdex_credits; |
|||
if ( credits != 0 && (swaps_kmdvalue+kmdvalue) > credits ) |
|||
{ |
|||
if ( 0 ) |
|||
{ |
|||
DL_FOREACH_SAFE(pubp->bobswaps,ptr,tmp) |
|||
{ |
|||
if ( (sp= ptr->swap) != 0 && LP_swap_finished(sp,1) == 0 ) |
|||
printf("unfinished bob %llu r%u-r%u src.%s %.8f dest.%s %.8f -> price %.8f value %.8f\n",(long long)sp->aliceid,sp->Q.R.requestid,sp->Q.R.quoteid,sp->Q.srccoin,dstr(sp->Q.satoshis),sp->Q.destcoin,dstr(sp->Q.destsatoshis),(double)sp->Q.destsatoshis/(sp->Q.satoshis+1),dstr(LP_kmdvalue(sp->Q.destcoin,sp->Q.destsatoshis))); |
|||
} |
|||
DL_FOREACH_SAFE(pubp->aliceswaps,ptr,tmp) |
|||
{ |
|||
if ( (sp= ptr->swap) != 0 && LP_swap_finished(sp,1) == 0 ) |
|||
printf("unfinished alice %llu r%u-r%u src.%s %.8f dest.%s %.8f -> price %.8f value %.8f\n",(long long)sp->aliceid,sp->Q.R.requestid,sp->Q.R.quoteid,sp->Q.srccoin,dstr(sp->Q.satoshis),sp->Q.destcoin,dstr(sp->Q.destsatoshis),(double)sp->Q.destsatoshis/(sp->Q.satoshis+1),dstr(LP_kmdvalue(sp->Q.destcoin,sp->Q.destsatoshis))); |
|||
} |
|||
} |
|||
printf("REJECT: %s instantdex_credits %.8f vs (%.8f + current %.8f)\n",coinaddr,dstr(credits),dstr(swaps_kmdvalue),dstr(kmdvalue)); |
|||
} |
|||
if ( 0 && credits != 0 ) |
|||
printf("%s %s othercredits %.8f debits %.8f + %.8f -> %.8f\n",coin->symbol,coinaddr,dstr(credits),dstr(swaps_kmdvalue),dstr(kmdvalue),dstr(credits - (swaps_kmdvalue+kmdvalue))); |
|||
return(credits - (swaps_kmdvalue+kmdvalue)); |
|||
} |
|||
return(0); |
|||
} |
|||
|
|||
int64_t LP_instantdex_proofcheck(char *coinaddr,cJSON *proof,int32_t num) |
|||
{ |
|||
uint8_t rmd160[20],addrtype; int64_t credits=0; int32_t i,j; bits256 prevtxid,txid; char othersmartaddr[64]; struct iguana_info *coin; struct LP_address *ap = 0; |
|||
if ( (coin= LP_coinfind("KMD")) != 0 ) |
|||
{ |
|||
bitcoin_addr2rmd160(0,&addrtype,rmd160,coinaddr); |
|||
bitcoin_address(othersmartaddr,0,60,rmd160,20); |
|||
printf("proofcheck addrtype.%d (%s) -> %s\n",addrtype,coinaddr,othersmartaddr); |
|||
if ((ap= LP_address(coin,othersmartaddr)) != 0 ) |
|||
{ |
|||
ap->instantdex_credits = 0; |
|||
for (i=0; i<num; i++) |
|||
{ |
|||
txid = jbits256i(proof,i); |
|||
for (j=0; j<i; j++) |
|||
{ |
|||
prevtxid = jbits256i(proof,j); |
|||
if ( bits256_cmp(prevtxid,txid) == 0 ) |
|||
break; |
|||
} |
|||
if ( j == i ) |
|||
LP_instantdex_creditcalc(coin,1,txid,othersmartaddr); |
|||
} |
|||
credits = ap->instantdex_credits; |
|||
ap->didinstantdex = 1; |
|||
if ( ap->instantdex_credits > 0 ) |
|||
printf("validated instantdex %s.[%d] proof.(%s) credits %.8f\n",othersmartaddr,num,jprint(proof,0),dstr(ap->instantdex_credits)); |
|||
} //else printf("cant find ap.%p or already did %d %.8f\n",ap,ap!=0?ap->didinstantdex:-1,ap!=0?dstr(ap->instantdex_credits):-1);
|
|||
} |
|||
return(credits); |
|||
} |
|||
|
|||
int64_t LP_myzcredits() |
|||
{ |
|||
cJSON *proof; struct iguana_info *coin; int64_t zcredits; |
|||
if ( (coin= LP_coinfind("KMD")) != 0 ) |
|||
{ |
|||
if ( (proof= LP_instantdex_txids(0,coin->smartaddr)) != 0 ) |
|||
{ |
|||
zcredits = LP_instantdex_proofcheck(coin->smartaddr,proof,cJSON_GetArraySize(proof)); |
|||
free_json(proof); |
|||
return(zcredits); |
|||
} |
|||
} |
|||
return(0); |
|||
} |
|||
|
|||
cJSON *LP_swapstats_item(struct LP_swapstats *sp,int32_t iambob) |
|||
{ |
|||
struct iguana_info *bob,*alice; int32_t flag = 0; char *retstr,*swapstr; bits256 zero; cJSON *item,*reqjson,*swapjson; |
|||
item = cJSON_CreateObject(); |
|||
jaddnum(item,"iambob",iambob); |
|||
jaddnum(item,"aliceid",sp->aliceid); |
|||
jaddnum(item,"requestid",sp->Q.R.requestid); |
|||
jaddnum(item,"quoteid",sp->Q.R.quoteid); |
|||
jaddstr(item,"base",sp->Q.srccoin); |
|||
jaddnum(item,"satoshis",sp->Q.satoshis); |
|||
jaddstr(item,"rel",sp->Q.destcoin); |
|||
jaddnum(item,"destsatoshis",sp->Q.destsatoshis); |
|||
jaddnum(item,"price",sp->Q.destsatoshis/((double)sp->Q.satoshis+1)); |
|||
if ( LP_swap_finished(sp,1) == 0 ) |
|||
{ |
|||
jaddnum(item,"finished",sp->finished); |
|||
if ( sp->bobneeds_dPoW != 0 && (bob= LP_coinfind(sp->Q.srccoin)) != 0 ) |
|||
{ |
|||
jaddnum(item,"bobneeds_dPoW",sp->bobneeds_dPoW); |
|||
jaddnum(item,"bob_dPoWheight",bob->notarized); |
|||
if ( sp->bobneeds_dPoW == 1 ) |
|||
flag = 1; |
|||
if ( bob->notarized == 0 ) |
|||
LP_dPoW_request(bob); |
|||
} |
|||
if ( sp->aliceneeds_dPoW != 0 && (alice= LP_coinfind(sp->Q.destcoin)) != 0 ) |
|||
{ |
|||
jaddnum(item,"aliceneeds_dPoW",sp->aliceneeds_dPoW); |
|||
jaddnum(item,"alice_dPoWheight",alice->notarized); |
|||
if ( sp->aliceneeds_dPoW == 1 ) |
|||
flag = 1; |
|||
if ( alice->notarized == 0 ) |
|||
LP_dPoW_request(alice); |
|||
} |
|||
if ( flag != 0 ) |
|||
{ |
|||
reqjson = cJSON_CreateObject(); |
|||
jaddstr(reqjson,"method","gettradestatus"); |
|||
jadd64bits(reqjson,"aliceid",sp->aliceid); |
|||
memset(zero.bytes,0,sizeof(zero)); |
|||
LP_reserved_msg(0,"","",zero,jprint(reqjson,1)); |
|||
if ( (swapstr= basilisk_swapentry(sp->Q.R.requestid,sp->Q.R.quoteid,0)) != 0 ) |
|||
{ |
|||
if ( (swapjson= cJSON_Parse(swapstr)) != 0 ) |
|||
{ |
|||
if ( (retstr= LP_swapstatus_recv(swapjson)) != 0 ) |
|||
free(retstr); |
|||
free_json(swapjson); |
|||
} |
|||
free(swapstr); |
|||
} |
|||
} |
|||
} |
|||
return(item); |
|||
} |
|||
|
|||
cJSON *LP_myzdebits() |
|||
{ |
|||
struct LP_pubswap *ptr,*tmp; struct LP_pubkey_info *pubp; struct LP_swapstats *sp; int64_t kmdvalue,swaps_kmdvalue = 0; struct iguana_info *coin; cJSON *retjson,*array,*item; |
|||
array = cJSON_CreateArray(); |
|||
if ( (coin= LP_coinfind("KMD")) != 0 ) |
|||
{ |
|||
if ( (pubp= LP_pubkeyfind(G.LP_mypub25519)) != 0 ) |
|||
{ |
|||
DL_FOREACH_SAFE(pubp->bobswaps,ptr,tmp) |
|||
{ |
|||
if ( (sp= ptr->swap) != 0 && LP_swap_finished(sp,1) == 0 ) |
|||
{ |
|||
kmdvalue = LP_kmdvalue(sp->Q.srccoin,sp->Q.satoshis); |
|||
item = LP_swapstats_item(sp,1); |
|||
jaddnum(item,"kmdvalue",dstr(kmdvalue)); |
|||
jaddi(array,item); |
|||
swaps_kmdvalue += kmdvalue; |
|||
} |
|||
} |
|||
DL_FOREACH_SAFE(pubp->aliceswaps,ptr,tmp) |
|||
{ |
|||
if ( (sp= ptr->swap) != 0 && LP_swap_finished(sp,1) == 0 ) |
|||
{ |
|||
kmdvalue = LP_kmdvalue(sp->Q.destcoin,sp->Q.destsatoshis); |
|||
item = LP_swapstats_item(sp,0); |
|||
jaddnum(item,"kmdvalue",dstr(kmdvalue)); |
|||
jaddi(array,item); |
|||
swaps_kmdvalue += kmdvalue; |
|||
} |
|||
} |
|||
} |
|||
} |
|||
retjson = cJSON_CreateObject(); |
|||
jadd(retjson,"swaps",array); |
|||
jaddnum(retjson,"pendingswaps",dstr(swaps_kmdvalue)); |
|||
return(retjson); |
|||
} |
File diff suppressed because it is too large
File diff suppressed because it is too large
@ -0,0 +1,337 @@ |
|||
|
|||
/******************************************************************************
|
|||
* 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_utxos.c
|
|||
// marketmaker
|
|||
//
|
|||
|
|||
int32_t LP_privkey_init(int32_t mypubsock,struct iguana_info *coin,bits256 myprivkey,bits256 mypub) |
|||
{ |
|||
int32_t enable_utxos = 0; |
|||
char *script,destaddr[64]; cJSON *array,*item; bits256 txid,deposittxid,zero; int32_t used,i,flag=0,height,n,cmpflag,iambob,vout,depositvout; uint64_t *values=0,satoshis,txfee,biggerval,value,total = 0; int64_t targetval; //struct LP_utxoinfo *utxo;
|
|||
if ( coin == 0 || (IAMLP == 0 && coin->inactive != 0) ) |
|||
{ |
|||
//printf("coin not active\n");
|
|||
return(0); |
|||
} |
|||
if ( coin->privkeydepth > 0 ) |
|||
return(0); |
|||
coin->privkeydepth++; |
|||
LP_address(coin,coin->smartaddr); |
|||
//if ( coin->inactive == 0 )
|
|||
// LP_listunspent_issue(coin->symbol,coin->smartaddr,0);
|
|||
memset(zero.bytes,0,sizeof(zero)); |
|||
array = LP_listunspent(coin->symbol,coin->smartaddr,zero,zero); |
|||
if ( array != 0 ) |
|||
{ |
|||
txfee = LP_txfeecalc(coin,0,0); |
|||
if ( is_cJSON_Array(array) != 0 && (n= cJSON_GetArraySize(array)) > 0 ) |
|||
{ |
|||
coin->numutxos = n; |
|||
//printf("LP_privkey_init %s %d\n",coin->symbol,n);
|
|||
for (iambob=0; iambob<=1; iambob++) |
|||
{ |
|||
if ( iambob == 0 ) |
|||
values = calloc(n,sizeof(*values)); |
|||
else memset(values,0,n * sizeof(*values)); |
|||
used = 0; |
|||
for (i=0; i<n; i++) |
|||
{ |
|||
item = jitem(array,i); |
|||
value = LP_listunspent_parseitem(coin,&txid,&vout,&height,item); |
|||
satoshis = LP_txvalue(destaddr,coin->symbol,txid,vout); |
|||
if ( satoshis != 0 && satoshis != value ) |
|||
printf("%s %s privkey_init value %.8f vs %.8f (%s) %.8f %.8f\n",coin->symbol,coin->smartaddr,dstr(satoshis),dstr(value),jprint(item,0),jdouble(item,"amount"),jdouble(item,"interest")); |
|||
if ( coin->electrum != 0 || LP_inventory_prevent(iambob,coin->symbol,txid,vout) == 0 )//&& height > 0 )
|
|||
{ |
|||
values[i] = satoshis; |
|||
//flag += LP_address_utxoadd(coin,destaddr,txid,vout,satoshis,height,-1);
|
|||
} else used++; |
|||
} |
|||
//printf("array.%d\n",n);
|
|||
while ( used < n-1 ) |
|||
{ |
|||
//for (i=0; i<n; i++)
|
|||
// printf("%.8f ",dstr(values[i]));
|
|||
//printf("used.%d of n.%d\n",used,n);
|
|||
if ( (i= LP_maxvalue(values,n)) >= 0 ) |
|||
{ |
|||
item = jitem(array,i); |
|||
if ( coin->electrum == 0 ) |
|||
{ |
|||
deposittxid = jbits256(item,"txid"); |
|||
depositvout = juint(item,"vout"); |
|||
script = jstr(item,"scriptPubKey"); |
|||
} |
|||
else |
|||
{ |
|||
deposittxid = jbits256(item,"tx_hash"); |
|||
depositvout = juint(item,"tx_pos"); |
|||
script = coin->smartaddr; |
|||
} |
|||
biggerval = values[i]; |
|||
values[i] = 0, used++; |
|||
if ( iambob == 0 ) |
|||
targetval = (biggerval / 776) + txfee; |
|||
else targetval = (biggerval / 9) * 8 + 2*txfee; |
|||
if ( targetval < txfee*2 ) |
|||
targetval = txfee*2; |
|||
//printf("iambob.%d i.%d deposit %.8f min %.8f target %.8f\n",iambob,i,dstr(biggerval),dstr((1+LP_MINSIZE_TXFEEMULT)*txfee),dstr(targetval));
|
|||
if ( biggerval < (1+LP_MINSIZE_TXFEEMULT)*txfee ) |
|||
continue; |
|||
i = -1; |
|||
if ( iambob != 0 ) |
|||
{ |
|||
if ( (i= LP_nearestvalue(iambob,values,n,targetval)) < 0 ) |
|||
targetval /= 4; |
|||
if ( targetval < txfee*(1+LP_MINSIZE_TXFEEMULT) ) |
|||
continue; |
|||
} |
|||
if ( i >= 0 || (i= LP_nearestvalue(iambob,values,n,targetval)) >= 0 ) |
|||
{ |
|||
//printf("iambob.%d i.%d %.8f target %.8f\n",iambob,i,dstr(biggerval),dstr(targetval));
|
|||
item = jitem(array,i); |
|||
cmpflag = 0; |
|||
if ( coin->electrum == 0 ) |
|||
{ |
|||
txid = jbits256(item,"txid"); |
|||
vout = juint(item,"vout"); |
|||
if ( jstr(item,"scriptPubKey") != 0 && strcmp(script,jstr(item,"scriptPubKey")) == 0 ) |
|||
cmpflag = 1; |
|||
} |
|||
else |
|||
{ |
|||
txid = jbits256(item,"tx_hash"); |
|||
vout = juint(item,"tx_pos"); |
|||
cmpflag = 1; |
|||
} |
|||
if ( cmpflag != 0 ) |
|||
{ |
|||
value = values[i]; |
|||
values[i] = 0, used++; |
|||
/*portable_mutex_lock(&LP_UTXOmutex);
|
|||
if ( iambob != 0 ) |
|||
{ |
|||
if ( (utxo= LP_utxoadd(1,coin->symbol,txid,vout,value,deposittxid,depositvout,biggerval,coin->smartaddr,mypub,LP_gui,G.LP_sessionid,value)) != 0 ) |
|||
{ |
|||
} |
|||
} |
|||
else |
|||
{ |
|||
//printf("call utxoadd\n");
|
|||
if ( (utxo= LP_utxoadd(0,coin->symbol,deposittxid,depositvout,biggerval,txid,vout,value,coin->smartaddr,mypub,LP_gui,G.LP_sessionid,biggerval)) != 0 ) |
|||
{ |
|||
} |
|||
} |
|||
portable_mutex_unlock(&LP_UTXOmutex);*/ |
|||
total += value; |
|||
} // else printf("scriptmismatch.(%s) vs %s\n",script,jprint(item,0));
|
|||
} //else printf("nothing near i.%d\n",i);
|
|||
} else break; |
|||
} |
|||
if ( enable_utxos == 0 ) |
|||
break; |
|||
} |
|||
} |
|||
free_json(array); |
|||
if ( 0 && flag != 0 ) |
|||
LP_postutxos(coin->symbol,coin->smartaddr); |
|||
} |
|||
if ( values != 0 ) |
|||
free(values); |
|||
if ( coin->privkeydepth > 0 ) |
|||
coin->privkeydepth--; |
|||
//printf("privkey.%s %.8f\n",symbol,dstr(total));
|
|||
return(flag); |
|||
} |
|||
|
|||
char *LP_secretaddresses(void *ctx,char *prefix,char *passphrase,int32_t n,uint8_t taddr,uint8_t pubtype) |
|||
{ |
|||
int32_t i; uint8_t tmptype,pubkey33[33],rmd160[20]; char output[777*45],str[65],str2[65],buf[8192],wifstr[128],coinaddr[64]; bits256 checkprivkey,privkey,pubkey; cJSON *retjson; |
|||
retjson = cJSON_CreateObject(); |
|||
if ( prefix == 0 || prefix[0] == 0 ) |
|||
prefix = "secretaddress"; |
|||
if ( passphrase == 0 || passphrase[0] == 0 ) |
|||
passphrase = "password"; |
|||
if ( n <= 0 ) |
|||
n = 16; |
|||
else if ( n > 777 ) |
|||
n = 777; |
|||
conv_NXTpassword(privkey.bytes,pubkey.bytes,(uint8_t *)passphrase,(int32_t)strlen(passphrase)); |
|||
bitcoin_priv2pub(ctx,pubkey33,coinaddr,privkey,taddr,pubtype); |
|||
printf("generator (%s) secrets.[%d] <%s> t.%u p.%u\n",coinaddr,n,passphrase,taddr,pubtype); |
|||
sprintf(output,"\"addresses\":["); |
|||
for (i=0; i<n; i++) |
|||
{ |
|||
sprintf(buf,"%s %s %03d",prefix,passphrase,i); |
|||
conv_NXTpassword(privkey.bytes,pubkey.bytes,(uint8_t *)buf,(int32_t)strlen(buf)); |
|||
bitcoin_priv2pub(ctx,pubkey33,coinaddr,privkey,taddr,pubtype); |
|||
bitcoin_priv2wif(0,wifstr,privkey,188); |
|||
bitcoin_wif2priv(0,&tmptype,&checkprivkey,wifstr); |
|||
bitcoin_addr2rmd160(taddr,&tmptype,rmd160,coinaddr); |
|||
if ( bits256_cmp(checkprivkey,privkey) != 0 ) |
|||
{ |
|||
printf("WIF.(%s) error -> %s vs %s?\n",wifstr,bits256_str(str,privkey),bits256_str(str2,checkprivkey)); |
|||
free_json(retjson); |
|||
return(clonestr("{\"error\":\"couldnt validate wifstr\"}")); |
|||
} |
|||
else if ( tmptype != pubtype ) |
|||
{ |
|||
printf("checktype.%d != pubtype.%d\n",tmptype,pubtype); |
|||
free_json(retjson); |
|||
return(clonestr("{\"error\":\"couldnt validate pubtype\"}")); |
|||
} |
|||
jaddstr(retjson,coinaddr,wifstr); |
|||
sprintf(output+strlen(output),"\\\"%s\\\"%c ",coinaddr,i<n-1?',':' '); |
|||
printf("./komodo-cli jumblr_secret %s\n",coinaddr); |
|||
} |
|||
printf("%s]\n",output); |
|||
return(jprint(retjson,1)); |
|||
} |
|||
|
|||
bits256 LP_privkeycalc(void *ctx,uint8_t *pubkey33,bits256 *pubkeyp,struct iguana_info *coin,char *passphrase,char *wifstr) |
|||
{ |
|||
//static uint32_t counter;
|
|||
bits256 privkey,userpub,zero,userpass,checkkey; char tmpstr[128]; cJSON *retjson; uint8_t tmptype; int32_t notarized; |
|||
if ( passphrase != 0 && passphrase[0] != 0 ) |
|||
{ |
|||
calc_NXTaddr(G.LP_NXTaddr,userpub.bytes,(uint8_t *)passphrase,(int32_t)strlen(passphrase)); |
|||
conv_NXTpassword(privkey.bytes,pubkeyp->bytes,(uint8_t *)passphrase,(int32_t)strlen(passphrase)); |
|||
//vcalc_sha256(0,checkkey.bytes,(uint8_t *)passphrase,(int32_t)strlen(passphrase));
|
|||
//printf("SHA256.(%s) ",bits256_str(pstr,checkkey));
|
|||
//printf("privkey.(%s)\n",bits256_str(pstr,privkey));
|
|||
} |
|||
else |
|||
{ |
|||
bitcoin_wif2priv(coin->wiftaddr,&tmptype,&privkey,wifstr); |
|||
if ( 0 ) |
|||
{ |
|||
char str[65],str2[65]; |
|||
checkkey = iguana_wif2privkey(wifstr); |
|||
if ( bits256_cmp(checkkey,privkey) != 0 ) |
|||
printf("WIF.(%s) -> %s or %s?\n",wifstr,bits256_str(str,privkey),bits256_str(str2,checkkey)); |
|||
} |
|||
} |
|||
privkey.bytes[0] &= 248, privkey.bytes[31] &= 127, privkey.bytes[31] |= 64; |
|||
bitcoin_priv2pub(ctx,coin->pubkey33,coin->smartaddr,privkey,coin->taddr,coin->pubtype); |
|||
if ( coin->counter == 0 ) |
|||
{ |
|||
coin->counter++; |
|||
memcpy(G.LP_pubsecp,coin->pubkey33,33); |
|||
bitcoin_priv2wif(coin->wiftaddr,tmpstr,privkey,coin->wiftype); |
|||
bitcoin_addr2rmd160(coin->taddr,&tmptype,G.LP_myrmd160,coin->smartaddr); |
|||
LP_privkeyadd(privkey,G.LP_myrmd160); |
|||
G.LP_privkey = privkey; |
|||
if ( 0 && (coin->pubtype != 60 || strcmp(coin->symbol,"KMD") == 0) ) |
|||
printf("%s (%s) %d wif.(%s) (%s)\n",coin->symbol,coin->smartaddr,coin->pubtype,tmpstr,passphrase); |
|||
if ( G.counter++ == 0 ) |
|||
{ |
|||
bitcoin_priv2wif(coin->wiftaddr,G.USERPASS_WIFSTR,privkey,188); |
|||
bitcoin_wif2priv(coin->wiftaddr,&tmptype,&checkkey,G.USERPASS_WIFSTR); |
|||
if ( bits256_cmp(checkkey,privkey) != 0 ) |
|||
{ |
|||
char str[65],str2[65]; |
|||
printf("FATAL ERROR converting USERPASS_WIFSTR %s -> %s != %s\n",G.USERPASS_WIFSTR,bits256_str(str,checkkey),bits256_str(str2,privkey)); |
|||
exit(-1); |
|||
} |
|||
conv_NXTpassword(userpass.bytes,pubkeyp->bytes,(uint8_t *)G.USERPASS_WIFSTR,(int32_t)strlen(G.USERPASS_WIFSTR)); |
|||
userpub = curve25519(userpass,curve25519_basepoint9()); |
|||
printf("userpass.(%s)\n",bits256_str(G.USERPASS,userpub)); |
|||
} |
|||
} |
|||
if ( coin->importedprivkey == 0 && coin->electrum == 0 && coin->userpass[0] != 0 && LP_getheight(¬arized,coin) > 0 ) |
|||
{ |
|||
memset(zero.bytes,0,sizeof(zero)); |
|||
LP_listunspent_issue(coin->symbol,coin->smartaddr,0,zero,zero); |
|||
if ( (retjson= LP_importprivkey(coin->symbol,tmpstr,coin->smartaddr,-1)) != 0 ) |
|||
{ |
|||
if ( jobj(retjson,"error") != 0 ) |
|||
{ |
|||
printf("cant importprivkey.%s -> (%s), abort session\n",coin->symbol,jprint(retjson,1)); |
|||
exit(-1); |
|||
} |
|||
free_json(retjson); |
|||
} |
|||
coin->importedprivkey = (uint32_t)time(NULL); |
|||
} |
|||
vcalc_sha256(0,checkkey.bytes,privkey.bytes,sizeof(privkey)); |
|||
checkkey.bytes[0] &= 248, checkkey.bytes[31] &= 127, checkkey.bytes[31] |= 64; |
|||
G.LP_mypub25519 = *pubkeyp = curve25519(checkkey,curve25519_basepoint9()); |
|||
G.LP_mypriv25519 = checkkey; |
|||
LP_pubkeyadd(G.LP_mypub25519); |
|||
return(privkey); |
|||
} |
|||
|
|||
void LP_privkey_updates(void *ctx,int32_t pubsock,char *passphrase) |
|||
{ |
|||
struct iguana_info *coin,*tmp; bits256 pubkey,privkey; uint8_t pubkey33[33]; int32_t initonly; |
|||
initonly = (passphrase != 0); |
|||
memset(privkey.bytes,0,sizeof(privkey)); |
|||
memset(pubkey.bytes,0,sizeof(pubkey)); |
|||
//printf("Total coins: %d\n", HASH_COUNT(LP_coins));
|
|||
//int num_iter = 0;
|
|||
HASH_ITER(hh,LP_coins,coin,tmp) |
|||
{ |
|||
//printf("LP_privkey_updates [%02d / %02d]\n", num_iter++, HASH_COUNT(LP_coins));
|
|||
if ( initonly != 0 ) |
|||
{ |
|||
coin->counter = 0; |
|||
memset(coin->smartaddr,0,sizeof(coin->smartaddr)); |
|||
if ( bits256_nonz(privkey) == 0 || coin->smartaddr[0] == 0 ) |
|||
privkey = LP_privkeycalc(ctx,pubkey33,&pubkey,coin,passphrase,""); |
|||
} |
|||
//printf("i.%d of %d\n",i,LP_numcoins);
|
|||
else if ( IAMLP == 0 || coin->inactive == 0 ) |
|||
{ |
|||
//printf("from updates %s\n",coin->symbol);
|
|||
if ( 0 && LP_privkey_init(pubsock,coin,G.LP_privkey,G.LP_mypub25519) == 0 && (LP_rand() % 10) == 0 ) |
|||
{ |
|||
//LP_postutxos(coin->symbol,coin->smartaddr);
|
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
|||
int32_t LP_passphrase_init(char *passphrase,char *gui) |
|||
{ |
|||
static void *ctx; int32_t counter; //iambob,; struct LP_utxoinfo *utxo,*tmp;
|
|||
if ( ctx == 0 ) |
|||
ctx = bitcoin_ctx(); |
|||
if ( G.LP_pendingswaps != 0 ) |
|||
return(-1); |
|||
G.initializing = 1; |
|||
if ( gui == 0 ) |
|||
gui = "cli"; |
|||
counter = G.USERPASS_COUNTER; |
|||
while ( G.waiting == 0 ) |
|||
{ |
|||
printf("waiting for G.waiting\n"); |
|||
sleep(5); |
|||
} |
|||
memset(&G,0,sizeof(G)); |
|||
LP_privkey_updates(ctx,LP_mypubsock,passphrase); |
|||
init_hexbytes_noT(G.LP_myrmd160str,G.LP_myrmd160,20); |
|||
G.LP_sessionid = (uint32_t)time(NULL); |
|||
safecopy(G.gui,gui,sizeof(G.gui)); |
|||
LP_tradebot_pauseall(); |
|||
LP_portfolio_reset(); |
|||
LP_priceinfos_clear(); |
|||
G.USERPASS_COUNTER = counter; |
|||
G.initializing = 0; |
|||
return(0); |
|||
} |
|||
|
|||
|
File diff suppressed because it is too large
@ -0,0 +1,694 @@ |
|||
|
|||
/******************************************************************************
|
|||
* 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_tradebots.c
|
|||
// marketmaker
|
|||
//
|
|||
|
|||
#define TRADEBOTS_GAPTIME 120 |
|||
#define LP_TRADEBOTS_MAXTRADES 10 |
|||
|
|||
struct LP_tradebot_trade |
|||
{ |
|||
double maxprice,totalrelvolume,basevol,relvol; |
|||
uint64_t aliceid; |
|||
int32_t dispdir; |
|||
uint32_t started,finished,requestid,quoteid,tradeid,expired; |
|||
char base[65],rel[65],event[32]; |
|||
}; |
|||
|
|||
struct LP_tradebot |
|||
{ |
|||
struct LP_tradebot *next,*prev; |
|||
char name[128],base[65],rel[65]; |
|||
int32_t numtrades,numpending,completed,dispdir; |
|||
double maxprice,totalrelvolume,totalbasevolume,basesum,relsum,pendbasesum,pendrelsum; |
|||
uint32_t lasttime,dead,pause,userpause,started,id; |
|||
struct LP_tradebot_trade *trades[LP_TRADEBOTS_MAXTRADES]; |
|||
} *LP_tradebots; |
|||
|
|||
void LP_tradebot_pauseall() |
|||
{ |
|||
struct LP_tradebot *bot,*tmp; |
|||
DL_FOREACH_SAFE(LP_tradebots,bot,tmp) |
|||
{ |
|||
bot->userpause = bot->pause = (uint32_t)time(NULL); |
|||
} |
|||
} |
|||
|
|||
void LP_tradebot_updatestats(struct LP_tradebot *bot,struct LP_tradebot_trade *tp) |
|||
{ |
|||
char *swapstr,*status; int32_t flag; cJSON *swapjson; |
|||
if ( (swapstr= basilisk_swapentry(tp->requestid,tp->quoteid,1)) != 0 ) |
|||
{ |
|||
flag = 0; |
|||
if ( (swapjson= cJSON_Parse(swapstr)) != 0 ) |
|||
{ |
|||
tp->basevol = dstr(j64bits(swapjson,"satoshis")); |
|||
tp->relvol = dstr(j64bits(swapjson,"destsatoshis")); |
|||
tp->aliceid = j64bits(swapjson,"aliceid"); |
|||
if ( (status= jstr(swapjson,"status")) != 0 ) |
|||
{ |
|||
if ( strcmp(status,"finished") == 0 ) |
|||
{ |
|||
if ( tp->finished == 0 ) |
|||
tp->finished = (uint32_t)time(NULL); |
|||
} |
|||
} |
|||
free_json(swapjson); |
|||
} |
|||
free(swapstr); |
|||
} |
|||
} |
|||
|
|||
void LP_tradebot_calcstats(struct LP_tradebot *bot) |
|||
{ |
|||
int32_t i; struct LP_tradebot_trade *tp; |
|||
bot->basesum = bot->relsum = bot->pendbasesum = bot->pendrelsum = 0.; |
|||
bot->numpending = bot->completed = 0; |
|||
for (i=0; i<bot->numtrades; i++) |
|||
{ |
|||
if ( (tp= bot->trades[i]) == 0 ) |
|||
continue; |
|||
if ( tp->finished == 0 && time(NULL) > tp->started+LP_atomic_locktime(bot->base,bot->rel)*2 ) |
|||
{ |
|||
tp->expired = tp->finished = (uint32_t)time(NULL); |
|||
printf("tradeid.%u expired\n",tp->tradeid); |
|||
} |
|||
if ( tp->finished != 0 ) |
|||
{ |
|||
if ( tp->expired == 0 ) |
|||
{ |
|||
bot->basesum += tp->basevol; |
|||
bot->relsum += tp->relvol; |
|||
bot->completed++; |
|||
} |
|||
} |
|||
else |
|||
{ |
|||
if ( tp->requestid != 0 && tp->quoteid != 0 ) |
|||
{ |
|||
bot->pendbasesum += tp->basevol; |
|||
bot->pendrelsum += tp->relvol; |
|||
bot->numpending++; |
|||
} |
|||
} |
|||
//LP_tradebot_updatestats(bot,bot->trades[i]);
|
|||
} |
|||
//printf("completed.%d (%.8f / %.8f) pending.%d (%.8f / %.8f)\n",bot->completed,bot->basesum,bot->relsum,bot->numpending,bot->pendbasesum,bot->pendrelsum);
|
|||
} |
|||
|
|||
double LP_pricevol_invert(double *basevolumep,double maxprice,double relvolume) |
|||
{ |
|||
double price; |
|||
*basevolumep = 0.; |
|||
if ( maxprice > SMALLVAL && maxprice < SATOSHIDEN ) |
|||
{ |
|||
price = (1. / maxprice); |
|||
*basevolumep = (relvolume * price); |
|||
return(price); |
|||
} |
|||
return(0.); |
|||
} |
|||
|
|||
cJSON *LP_tradebot_tradejson(struct LP_tradebot_trade *tp,int32_t dispflag) |
|||
{ |
|||
double price,basevol; cJSON *item = cJSON_CreateObject(); |
|||
if ( tp == 0 ) |
|||
return(cJSON_Parse("{}")); |
|||
if ( tp->event[0] != 0 ) |
|||
jaddstr(item,"status",tp->event); |
|||
if ( tp->requestid != 0 && tp->quoteid != 0 ) |
|||
{ |
|||
jaddnum(item,"requestid",tp->requestid); |
|||
jaddnum(item,"quoteid",tp->quoteid); |
|||
} else jaddnum(item,"tradeid",tp->tradeid); |
|||
if ( tp->aliceid != 0 ) |
|||
jadd64bits(item,"aliceid",tp->aliceid); |
|||
if ( tp->basevol > SMALLVAL && tp->relvol > SMALLVAL ) |
|||
{ |
|||
if ( dispflag > 0 ) |
|||
{ |
|||
jaddnum(item,"price",tp->relvol/tp->basevol); |
|||
jaddnum(item,"volume",tp->relvol); |
|||
} |
|||
else |
|||
{ |
|||
price = LP_pricevol_invert(&basevol,tp->relvol / tp->basevol,tp->relvol); |
|||
jaddnum(item,"price",price); |
|||
jaddnum(item,"volume",basevol); |
|||
} |
|||
} |
|||
return(item); |
|||
} |
|||
|
|||
cJSON *LP_tradebot_json(struct LP_tradebot *bot) |
|||
{ |
|||
int32_t i; double aveprice,basevolume,vol; cJSON *json,*array; |
|||
LP_tradebot_calcstats(bot); |
|||
json = cJSON_CreateObject(); |
|||
jaddstr(json,"result","success"); |
|||
jaddstr(json,"name",bot->name); |
|||
jaddnum(json,"botid",bot->id); |
|||
jaddnum(json,"started",bot->started); |
|||
if ( bot->pause != 0 || bot->userpause != 0 ) |
|||
jaddnum(json,"paused",bot->userpause != 0 ? bot->userpause : bot->pause); |
|||
if ( bot->dead != 0 ) |
|||
jaddnum(json,"stopped",bot->dead); |
|||
if ( bot->dispdir > 0 ) |
|||
{ |
|||
jaddstr(json,"action","buy"); |
|||
jaddstr(json,"base",bot->base); |
|||
jaddstr(json,"rel",bot->rel); |
|||
jaddnum(json,"maxprice",bot->maxprice); |
|||
jaddnum(json,"totalrelvolume",bot->totalrelvolume); |
|||
jaddnum(json,"totalbasevolume",bot->totalbasevolume); |
|||
if ( (vol= bot->relsum) > SMALLVAL && bot->basesum > SMALLVAL ) |
|||
{ |
|||
jaddnum(json,"aveprice",vol/bot->basesum); |
|||
jaddnum(json,"volume",vol); |
|||
} |
|||
} |
|||
else |
|||
{ |
|||
jaddstr(json,"action","sell"); |
|||
jaddstr(json,"base",bot->rel); |
|||
jaddstr(json,"rel",bot->base); |
|||
aveprice = LP_pricevol_invert(&basevolume,bot->maxprice,bot->totalrelvolume); |
|||
jaddnum(json,"minprice",aveprice); |
|||
jaddnum(json,"totalbasevolume",bot->totalrelvolume); |
|||
jaddnum(json,"totalrelvolume",basevolume); |
|||
if ( (vol= bot->relsum) > SMALLVAL && bot->basesum > SMALLVAL ) |
|||
{ |
|||
aveprice = LP_pricevol_invert(&basevolume,vol/bot->basesum,vol); |
|||
jaddnum(json,"aveprice",aveprice); |
|||
jaddnum(json,"volume",basevolume); |
|||
} |
|||
} |
|||
array = cJSON_CreateArray(); |
|||
for (i=0; i<bot->numtrades; i++) |
|||
jaddi(array,LP_tradebot_tradejson(bot->trades[i],bot->dispdir)); |
|||
jadd(json,"trades",array); |
|||
if ( bot->basesum > SMALLVAL && bot->relsum > SMALLVAL && bot->completed > 0 ) |
|||
{ |
|||
jadd(json,"complete",bot->completed!=0?jtrue():jfalse()); |
|||
jaddnum(json,"percentage",100. * (bot->relsum / bot->totalrelvolume)); |
|||
if ( bot->dispdir > 0 ) |
|||
{ |
|||
jaddnum(json,"aveprice",bot->relsum / bot->basesum); |
|||
jaddnum(json,"volume",bot->relsum); |
|||
} |
|||
else |
|||
{ |
|||
jaddnum(json,"aveprice",bot->basesum / bot->relsum); |
|||
jaddnum(json,"volume",bot->basesum); |
|||
} |
|||
} |
|||
if ( bot->pendbasesum > SMALLVAL && bot->pendrelsum > SMALLVAL && bot->numpending > 0 ) |
|||
{ |
|||
jaddnum(json,"pending",bot->numpending); |
|||
if ( bot->dispdir > 0 ) |
|||
{ |
|||
jaddnum(json,"pendingprice",bot->pendrelsum / bot->pendbasesum); |
|||
jaddnum(json,"pendingvolume",bot->pendrelsum); |
|||
} |
|||
else |
|||
{ |
|||
jaddnum(json,"pendingprice",bot->pendbasesum / bot->pendrelsum); |
|||
jaddnum(json,"pendingvolume",bot->pendbasesum); |
|||
} |
|||
} |
|||
return(json); |
|||
} |
|||
|
|||
struct LP_tradebot *_LP_tradebotfind(uint32_t botid) |
|||
{ |
|||
struct LP_tradebot *tmp,*bot,*retbot = 0; |
|||
DL_FOREACH_SAFE(LP_tradebots,bot,tmp) |
|||
{ |
|||
if ( botid == bot->id ) |
|||
{ |
|||
retbot = bot; |
|||
break; |
|||
} |
|||
} |
|||
return(retbot); |
|||
} |
|||
|
|||
struct LP_tradebot *LP_tradebotfind(uint32_t botid) |
|||
{ |
|||
struct LP_tradebot *retbot = 0; |
|||
portable_mutex_lock(&LP_tradebotsmutex); |
|||
retbot = _LP_tradebotfind(botid); |
|||
portable_mutex_unlock(&LP_tradebotsmutex); |
|||
return(retbot); |
|||
} |
|||
|
|||
void LP_tradebotadd(struct LP_tradebot *bot) |
|||
{ |
|||
portable_mutex_lock(&LP_tradebotsmutex); |
|||
while ( _LP_tradebotfind(bot->id) != 0 ) |
|||
{ |
|||
printf("BOT collision at %u, ok if rare\n",bot->id); |
|||
bot->id++; |
|||
} |
|||
DL_APPEND(LP_tradebots,bot); |
|||
portable_mutex_unlock(&LP_tradebotsmutex); |
|||
} |
|||
|
|||
struct LP_tradebot_trade *LP_tradebot_pending(struct LP_tradebot *bot,cJSON *pending,uint32_t tradeid) |
|||
{ |
|||
struct LP_tradebot_trade *tp; |
|||
tp = calloc(1,sizeof(*tp)); |
|||
tp->tradeid = tradeid; |
|||
tp->maxprice = bot->maxprice; |
|||
tp->totalrelvolume = bot->totalrelvolume; |
|||
tp->started = (uint32_t)time(NULL); |
|||
tp->dispdir = bot->dispdir; |
|||
strcpy(tp->base,bot->base); |
|||
strcpy(tp->rel,bot->rel); |
|||
tp->aliceid = j64bits(pending,"aliceid"); |
|||
tp->basevol = jdouble(pending,"basevalue"); |
|||
tp->relvol = jdouble(pending,"relvalue"); |
|||
printf("tradebot pending basevol %.8f relvol %.8f\n",tp->basevol,tp->relvol); |
|||
return(tp); |
|||
} |
|||
|
|||
double LP_orderbook_maxrel(char *base,char *rel,double maxprice) |
|||
{ |
|||
char *retstr; int32_t i,numasks; cJSON *retjson,*asks,*item; double maxvol,maxrel = 0.; |
|||
if ( (retstr= LP_orderbook(base,rel,0)) != 0 ) |
|||
{ |
|||
//printf("maxprice %.8f %s/%s\n",maxprice,base,rel);
|
|||
if ( (retjson= cJSON_Parse(retstr)) != 0 ) |
|||
{ |
|||
if ( (asks= jarray(&numasks,retjson,"asks")) != 0 ) |
|||
{ |
|||
for (i=0; i<numasks; i++) |
|||
{ |
|||
item = jitem(asks,i); |
|||
if ( jdouble(item,"price") > maxprice ) |
|||
break; |
|||
maxvol = jdouble(item,"maxvolume"); |
|||
//printf("(%s) -> %.8f\n",jprint(item,0),maxvol);
|
|||
if ( maxvol > maxrel ) |
|||
maxrel = maxvol; |
|||
} |
|||
} |
|||
free_json(retjson); |
|||
} |
|||
free(retstr); |
|||
} |
|||
return(maxrel); |
|||
} |
|||
|
|||
void LP_tradebot_timeslice(void *ctx,struct LP_tradebot *bot) |
|||
{ |
|||
double remaining,maxrel; struct LP_tradebot_trade *tp; int32_t i,maxiters = 10; uint32_t tradeid; bits256 destpubkey; char *retstr,*liststr; cJSON *retjson,*retjson2,*pending; |
|||
memset(destpubkey.bytes,0,sizeof(destpubkey)); |
|||
LP_tradebot_calcstats(bot); |
|||
if ( bot->dead == 0 && bot->pause == 0 && bot->userpause == 0 && bot->numtrades < sizeof(bot->trades)/sizeof(*bot->trades) ) |
|||
{ |
|||
if ( (liststr= LP_recent_swaps(0)) != 0 ) |
|||
{ |
|||
if ( (retjson= cJSON_Parse(liststr)) != 0 ) |
|||
{ |
|||
if ( jobj(retjson,"pending") == 0 ) |
|||
{ |
|||
remaining = bot->totalrelvolume - (bot->relsum + bot->pendrelsum); |
|||
maxrel = LP_orderbook_maxrel(bot->base,bot->rel,bot->maxprice); |
|||
printf("try autobuy %s/%s remaining %.8f maxprice %.8f maxrel %.8f\n",bot->base,bot->rel,remaining,bot->maxprice,maxrel); |
|||
if ( maxrel < remaining ) |
|||
remaining = maxrel; |
|||
tradeid = LP_rand(); |
|||
for (i=1; i<=maxiters; i++) |
|||
{ |
|||
if ( remaining < 0.001 ) |
|||
break; |
|||
if ( (retstr= LP_autobuy(ctx,LP_myipaddr,LP_mypubsock,bot->base,bot->rel,bot->maxprice,remaining/i,0,0,G.gui,0,destpubkey,tradeid)) != 0 ) |
|||
{ |
|||
if ( (retjson2= cJSON_Parse(retstr)) != 0 ) |
|||
{ |
|||
if ( (pending= jobj(retjson2,"pending")) != 0 && juint(pending,"tradeid") == tradeid ) |
|||
{ |
|||
bot->trades[bot->numtrades++] = tp = LP_tradebot_pending(bot,pending,tradeid); |
|||
printf("issued bot trade.%u %s\n",tradeid,retstr); |
|||
free_json(retjson2); |
|||
free(retstr); |
|||
break; |
|||
} else printf("iter.%d/%d %.8f didnt get any trade pending %s %s\n\n",i,maxiters,remaining/i,bot->name,retstr); |
|||
free_json(retjson2); |
|||
} else printf("iter.%d/%d %.8f %s\n",i,maxiters,remaining/i,retstr); |
|||
free(retstr); |
|||
} |
|||
} |
|||
LP_tradebot_calcstats(bot); |
|||
} |
|||
free_json(retjson); |
|||
} |
|||
free(liststr); |
|||
} |
|||
} |
|||
else if ( bot->pause == 0 ) |
|||
bot->pause = (uint32_t)time(NULL); |
|||
} |
|||
|
|||
void LP_aliceid(uint32_t tradeid,uint64_t aliceid,char *event,uint32_t requestid,uint32_t quoteid) |
|||
{ |
|||
struct LP_tradebot *bot,*tmp; int32_t i,matched = 0; struct LP_tradebot_trade *tp; |
|||
if ( tradeid == 0 ) |
|||
return; |
|||
DL_FOREACH_SAFE(LP_tradebots,bot,tmp) |
|||
{ |
|||
for (i=0; i<bot->numtrades; i++) |
|||
{ |
|||
if ( (tp= bot->trades[i]) != 0 ) |
|||
{ |
|||
if ( tp->finished == 0 && tp->tradeid == tradeid ) |
|||
{ |
|||
tp->aliceid = aliceid; |
|||
printf("bot event tradeid.%u aliceid.%llu (%s) r.%u q.%u\n",tradeid,(long long)aliceid,event,requestid,quoteid); |
|||
if ( requestid != 0 && quoteid != 0 ) |
|||
{ |
|||
tp->requestid = requestid; |
|||
tp->quoteid = quoteid; |
|||
} |
|||
strcpy(tp->event,event); |
|||
matched = 1; |
|||
break; |
|||
} else printf("tradeid.%u finished.%u\n",tp->tradeid,tp->finished); |
|||
} |
|||
} |
|||
if ( matched != 0 ) |
|||
break; |
|||
} |
|||
if ( 0 && matched == 0 ) |
|||
printf("NO MATCH: bot event tradeid.%u aliceid.%llu (%s) r.%u q.%u\n",tradeid,(long long)aliceid,event,requestid,quoteid); |
|||
} |
|||
|
|||
void LP_tradebot_finished(uint32_t tradeid,uint32_t requestid,uint32_t quoteid) |
|||
{ |
|||
struct LP_tradebot *bot,*tmp; int32_t i; struct LP_tradebot_trade *tp; |
|||
DL_FOREACH_SAFE(LP_tradebots,bot,tmp) |
|||
{ |
|||
for (i=0; i<bot->numtrades; i++) |
|||
{ |
|||
if ( (tp= bot->trades[i]) != 0 && tp->finished == 0 && tp->tradeid == tradeid ) |
|||
{ |
|||
tp->requestid = requestid; |
|||
tp->quoteid = quoteid; |
|||
printf("bot.%u detected completion tradeid.%u aliceid.%llu r.%u q.%u, numpending.%d completed.%d\n",bot->id,tp->tradeid,(long long)tp->aliceid,tp->requestid,tp->quoteid,bot->numpending,bot->completed); |
|||
tp->finished = (uint32_t)time(NULL); |
|||
strcpy(tp->event,"finished"); |
|||
break; |
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
|||
void LP_tradebots_timeslice(void *ctx) |
|||
{ |
|||
static uint32_t lastnumfinished = 0; |
|||
struct iguana_info *relcoin; bits256 zero; struct LP_tradebot *bot,*tmp; |
|||
DL_FOREACH_SAFE(LP_tradebots,bot,tmp) |
|||
{ |
|||
memset(zero.bytes,0,sizeof(zero)); |
|||
if ( (relcoin= LP_coinfind(bot->rel)) != 0 ) |
|||
LP_listunspent_issue(bot->rel,relcoin->smartaddr,1,zero,zero); |
|||
if ( bot->relsum >= 0.99*bot->totalrelvolume-SMALLVAL || bot->basesum >= 0.99*bot->totalbasevolume-SMALLVAL ) |
|||
bot->dead = (uint32_t)time(NULL); |
|||
else if ( (bot->pendrelsum+bot->relsum) >= 0.99*bot->totalrelvolume-SMALLVAL || (bot->basesum+bot->pendbasesum) >= 0.99*bot->totalbasevolume-SMALLVAL ) |
|||
bot->pause = (uint32_t)time(NULL); |
|||
else if ( bot->userpause == 0 ) |
|||
bot->pause = 0; |
|||
if ( bot->numpending == 0 && time(NULL) > bot->lasttime+TRADEBOTS_GAPTIME ) |
|||
{ |
|||
LP_tradebot_timeslice(ctx,bot); |
|||
bot->lasttime = (uint32_t)time(NULL); |
|||
} |
|||
} |
|||
lastnumfinished = LP_numfinished; |
|||
} |
|||
|
|||
char *LP_tradebot_list(void *ctx,int32_t pubsock,cJSON *argjson) |
|||
{ |
|||
struct LP_tradebot *bot,*tmp; cJSON *array = cJSON_CreateArray(); |
|||
DL_FOREACH_SAFE(LP_tradebots,bot,tmp) |
|||
{ |
|||
jaddinum(array,bot->id); |
|||
} |
|||
return(jprint(array,1)); |
|||
} |
|||
|
|||
char *LP_tradebot_statuslist(void *ctx,int32_t pubsock,cJSON *argjson) |
|||
{ |
|||
struct LP_tradebot *bot,*tmp; cJSON *array = cJSON_CreateArray(); |
|||
DL_FOREACH_SAFE(LP_tradebots,bot,tmp) |
|||
{ |
|||
jaddi(array,LP_tradebot_json(bot)); |
|||
} |
|||
return(jprint(array,1)); |
|||
} |
|||
|
|||
char *LP_tradebot_buy(int32_t dispdir,char *base,char *rel,double maxprice,double relvolume) |
|||
{ |
|||
struct LP_tradebot *bot; char *retstr; double shortfall; cJSON *retjson; uint64_t sum,txfee,txfees,balance=0,abalance=0; struct iguana_info *basecoin,*relcoin; |
|||
basecoin = LP_coinfind(base); |
|||
relcoin = LP_coinfind(rel); |
|||
if ( basecoin == 0 || relcoin == 0 || basecoin->inactive != 0 || relcoin->inactive != 0 ) |
|||
return(clonestr("{\"error\":\"one or more coins inactive\"}")); |
|||
/*if ( (array= LP_inventory(rel)) != 0 )
|
|||
{ |
|||
if ( (n= cJSON_GetArraySize(array)) > 0 && is_cJSON_Array(array) != 0 ) |
|||
{ |
|||
for (i=0; i<n; i++) |
|||
{ |
|||
item = jitem(array,i); |
|||
abalance += j64bits(item,"satoshis"); |
|||
} |
|||
} |
|||
free_json(array); |
|||
}*/ |
|||
if ( (retstr= LP_orderbook(base,rel,0)) != 0 ) |
|||
free(retstr); |
|||
txfee = LP_txfeecalc(relcoin,0,0); |
|||
txfees = 10 * txfee; |
|||
if ( relcoin->electrum != 0 ) |
|||
balance = LP_unspents_load(relcoin->symbol,relcoin->smartaddr); |
|||
else balance = LP_RTsmartbalance(relcoin); |
|||
sum = (SATOSHIDEN*relvolume+2*dstr(txfees)) + 3 * ((SATOSHIDEN*relvolume+2*dstr(txfees))/777); |
|||
printf("%s inventory balance %.8f, relvolume %.8f + txfees %.8f, utxobal %.8f sum %.8f\n",rel,dstr(abalance),relvolume,dstr(txfees),dstr(balance),dstr(sum)); |
|||
//if ( (abalance < SATOSHIDEN*relvolume + txfees) || ((balance-abalance) < (uint64_t)(SATOSHIDEN*relvolume)/777 + txfees) )
|
|||
if ( balance < sum+2*txfee ) |
|||
{ |
|||
retjson = cJSON_CreateObject(); |
|||
jaddstr(retjson,"error","not enough funds"); |
|||
jaddstr(retjson,"coin",rel); |
|||
jaddnum(retjson,"abalance",dstr(abalance)); |
|||
jaddnum(retjson,"balance",dstr(balance)); |
|||
jaddnum(retjson,"relvolume",relvolume); |
|||
jaddnum(retjson,"txfees",dstr(txfees)); |
|||
shortfall = (relvolume + dstr(txfees)) - dstr(balance); |
|||
jaddnum(retjson,"shortfall",shortfall); |
|||
/*if ( balance > sum+2*txfee )
|
|||
{ |
|||
char *withdrawstr; cJSON *outputjson,*withdrawjson,*outputs,*item; |
|||
outputjson = cJSON_CreateObject(); |
|||
outputs = cJSON_CreateArray(); |
|||
item = cJSON_CreateObject(); |
|||
jaddnum(item,relcoin->smartaddr,relvolume+2*dstr(txfees)); |
|||
jaddi(outputs,item); |
|||
item = cJSON_CreateObject(); |
|||
jaddnum(item,relcoin->smartaddr,(relvolume+2*dstr(txfees))/777); |
|||
jaddi(outputs,item); |
|||
item = cJSON_CreateObject(); |
|||
jaddnum(item,relcoin->smartaddr,(relvolume+2*dstr(txfees))/777); |
|||
jaddi(outputs,item); |
|||
item = cJSON_CreateObject(); |
|||
jaddnum(item,relcoin->smartaddr,(relvolume+2*dstr(txfees))/777); |
|||
jaddi(outputs,item); |
|||
jadd(outputjson,"outputs",outputs); |
|||
if ( (withdrawstr= LP_withdraw(relcoin,outputjson)) != 0 ) |
|||
{ |
|||
if ( (withdrawjson= cJSON_Parse(withdrawstr)) != 0 ) |
|||
jadd(retjson,"withdraw",withdrawjson); |
|||
free(withdrawstr); |
|||
} |
|||
free_json(outputjson); |
|||
}*/ |
|||
return(jprint(retjson,1)); |
|||
} |
|||
printf("disp.%d tradebot_buy(%s / %s) maxprice %.8f relvolume %.8f\n",dispdir,base,rel,maxprice,relvolume); |
|||
if ( (bot= calloc(1,sizeof(*bot))) != 0 ) |
|||
{ |
|||
safecopy(bot->base,base,sizeof(bot->base)); |
|||
safecopy(bot->rel,rel,sizeof(bot->rel)); |
|||
bot->dispdir = dispdir; |
|||
bot->maxprice = maxprice; |
|||
bot->totalrelvolume = relvolume; |
|||
LP_pricevol_invert(&bot->totalbasevolume,maxprice,relvolume); |
|||
bot->started = (uint32_t)time(NULL); |
|||
if ( dispdir > 0 ) |
|||
sprintf(bot->name,"buy_%s_%s.%d",base,rel,bot->started); |
|||
else sprintf(bot->name,"sell_%s_%s.%d",rel,base,bot->started); |
|||
bot->id = calc_crc32(0,(uint8_t *)bot,sizeof(*bot)); |
|||
LP_tradebotadd(bot); |
|||
return(jprint(LP_tradebot_json(bot),1)); |
|||
} |
|||
return(0); |
|||
} |
|||
|
|||
char *LP_tradebot_limitbuy(void *ctx,int32_t pubsock,cJSON *argjson) |
|||
{ |
|||
double relvolume,maxprice; char *base,*rel; |
|||
base = jstr(argjson,"base"); |
|||
rel = jstr(argjson,"rel"); |
|||
maxprice = jdouble(argjson,"maxprice"); |
|||
relvolume = jdouble(argjson,"relvolume"); |
|||
printf("limit buy %s/%s %.8f %.8f\n",base,rel,maxprice,relvolume); |
|||
if ( LP_priceinfofind(base) != 0 && LP_priceinfofind(rel) != 0 && maxprice > SMALLVAL && maxprice < SATOSHIDEN && relvolume > 0.0001 && relvolume < SATOSHIDEN ) |
|||
return(LP_tradebot_buy(1,base,rel,maxprice,relvolume)); |
|||
return(clonestr("{\"error\":\"invalid parameter\"}")); |
|||
} |
|||
|
|||
char *LP_tradebot_limitsell(void *ctx,int32_t pubsock,cJSON *argjson) |
|||
{ |
|||
double relvolume,maxprice,price,basevolume,p,v; char *base,*rel; |
|||
base = jstr(argjson,"base"); |
|||
rel = jstr(argjson,"rel"); |
|||
price = jdouble(argjson,"minprice"); |
|||
basevolume = jdouble(argjson,"basevolume"); |
|||
if ( LP_priceinfofind(base) != 0 && LP_priceinfofind(rel) != 0 && price > SMALLVAL && price < SATOSHIDEN && basevolume > 0.0001 && basevolume < SATOSHIDEN ) |
|||
{ |
|||
maxprice = price; |
|||
relvolume = (price * basevolume); |
|||
p = LP_pricevol_invert(&v,maxprice,relvolume); |
|||
printf("minprice %.8f basevolume %.8f -> (%.8f %.8f) -> (%.8f %.8f)\n",price,basevolume,maxprice,relvolume,1./p,v); |
|||
return(LP_tradebot_buy(-1,rel,base,p,v)); |
|||
} |
|||
return(clonestr("{\"error\":\"invalid parameter\"}")); |
|||
} |
|||
|
|||
char *LP_tradebot_settings(void *ctx,int32_t pubsock,cJSON *argjson,uint32_t botid) |
|||
{ |
|||
struct LP_tradebot *bot; double newprice,newvolume; |
|||
if ( (bot= LP_tradebotfind(botid)) != 0 ) |
|||
{ |
|||
if ( bot->dead != 0 ) |
|||
return(clonestr("{\"error\":\"botid aleady stopped\"}")); |
|||
newprice = jdouble(argjson,"newprice"); |
|||
newvolume = jdouble(argjson,"newvolume"); |
|||
if ( (newprice > SMALLVAL && newprice < SATOSHIDEN) || (newvolume > 0.0001 && newvolume < SATOSHIDEN) ) |
|||
{ |
|||
if ( bot->dispdir < 0 ) |
|||
{ |
|||
if ( newprice > SMALLVAL ) |
|||
bot->maxprice = 1. / newprice; |
|||
if ( newvolume > SMALLVAL ) |
|||
bot->totalrelvolume = (bot->maxprice * newvolume); |
|||
} |
|||
else |
|||
{ |
|||
if ( newprice > SMALLVAL ) |
|||
bot->maxprice = newprice; |
|||
if ( newvolume > SMALLVAL ) |
|||
bot->totalrelvolume = newvolume; |
|||
} |
|||
} |
|||
return(jprint(LP_tradebot_json(bot),1)); |
|||
} |
|||
return(clonestr("{\"error\":\"couldnt find botid\"}")); |
|||
} |
|||
|
|||
char *LP_tradebot_status(void *ctx,int32_t pubsock,cJSON *argjson,uint32_t botid) |
|||
{ |
|||
struct LP_tradebot *bot; |
|||
if ( (bot= LP_tradebotfind(botid)) != 0 ) |
|||
return(jprint(LP_tradebot_json(bot),1)); |
|||
return(clonestr("{\"error\":\"couldnt find botid\"}")); |
|||
} |
|||
|
|||
char *LP_tradebot_stop(void *ctx,int32_t pubsock,cJSON *argjson,uint32_t botid) |
|||
{ |
|||
struct LP_tradebot *bot; |
|||
if ( (bot= LP_tradebotfind(botid)) != 0 ) |
|||
{ |
|||
bot->dead = (uint32_t)time(NULL); |
|||
return(clonestr("{\"result\":\"success\"}")); |
|||
} |
|||
return(clonestr("{\"error\":\"couldnt find botid\"}")); |
|||
} |
|||
|
|||
char *LP_tradebot_pause(void *ctx,int32_t pubsock,cJSON *argjson,uint32_t botid) |
|||
{ |
|||
struct LP_tradebot *bot; |
|||
if ( (bot= LP_tradebotfind(botid)) != 0 ) |
|||
{ |
|||
if ( bot->dead != 0 ) |
|||
return(clonestr("{\"error\":\"botid aleady stopped\"}")); |
|||
bot->userpause = (uint32_t)time(NULL); |
|||
return(clonestr("{\"result\":\"success\"}")); |
|||
} |
|||
return(clonestr("{\"error\":\"couldnt find botid\"}")); |
|||
} |
|||
|
|||
char *LP_tradebot_resume(void *ctx,int32_t pubsock,cJSON *argjson,uint32_t botid) |
|||
{ |
|||
struct LP_tradebot *bot; |
|||
if ( (bot= LP_tradebotfind(botid)) != 0 ) |
|||
{ |
|||
if ( bot->dead != 0 ) |
|||
return(clonestr("{\"error\":\"botid aleady stopped\"}")); |
|||
if ( bot->userpause == 0 ) |
|||
return(clonestr("{\"result\":\"success\",\"status\":\"botid not paused\"}")); |
|||
bot->userpause = 0; |
|||
return(clonestr("{\"result\":\"success\"}")); |
|||
} |
|||
return(clonestr("{\"error\":\"couldnt find botid\"}")); |
|||
} |
|||
|
|||
char *LP_istradebots_command(void *ctx,int32_t pubsock,char *method,cJSON *argjson) |
|||
{ |
|||
uint32_t botid; |
|||
//printf("LP_istradebots_command check %s\n",method);
|
|||
if ( strncmp("bot_",method,strlen("bot_")) != 0 ) |
|||
return(0); |
|||
if ( strcmp(method,"bot_list") == 0 ) |
|||
return(LP_tradebot_list(ctx,pubsock,argjson)); |
|||
else if ( strcmp(method,"bot_statuslist") == 0 ) |
|||
return(LP_tradebot_statuslist(ctx,pubsock,argjson)); |
|||
else if ( strcmp(method,"bot_buy") == 0 ) |
|||
return(LP_tradebot_limitbuy(ctx,pubsock,argjson)); |
|||
else if ( strcmp(method,"bot_sell") == 0 ) |
|||
return(LP_tradebot_limitsell(ctx,pubsock,argjson)); |
|||
if ( (botid= juint(argjson,"botid")) == 0 ) |
|||
return(clonestr("{\"error\":\"no botid specified\"}")); |
|||
else |
|||
{ |
|||
if ( strcmp(method,"bot_status") == 0 ) |
|||
return(LP_tradebot_status(ctx,pubsock,argjson,botid)); |
|||
else if ( strcmp(method,"bot_settings") == 0 ) |
|||
return(LP_tradebot_settings(ctx,pubsock,argjson,botid)); |
|||
else if ( strcmp(method,"bot_stop") == 0 ) |
|||
return(LP_tradebot_stop(ctx,pubsock,argjson,botid)); |
|||
else if ( strcmp(method,"bot_pause") == 0 ) |
|||
return(LP_tradebot_pause(ctx,pubsock,argjson,botid)); |
|||
else if ( strcmp(method,"bot_resume") == 0 ) |
|||
return(LP_tradebot_resume(ctx,pubsock,argjson,botid)); |
|||
} |
|||
return(0); |
|||
} |
|||
|
File diff suppressed because it is too large
@ -1,808 +0,0 @@ |
|||
|
|||
/******************************************************************************
|
|||
* 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_utxos.c
|
|||
// marketmaker
|
|||
//
|
|||
|
|||
|
|||
|
|||
|
|||
int32_t LP_ismine(struct LP_utxoinfo *utxo) |
|||
{ |
|||
if ( utxo != 0 && bits256_cmp(utxo->pubkey,G.LP_mypub25519) == 0 ) |
|||
return(1); |
|||
else return(0); |
|||
} |
|||
|
|||
int32_t LP_isavailable(struct LP_utxoinfo *utxo) |
|||
{ |
|||
if ( time(NULL) > utxo->T.swappending ) |
|||
utxo->T.swappending = 0; |
|||
if ( utxo != 0 && utxo->T.swappending == 0 && utxo->S.swap == 0 ) |
|||
return(1); |
|||
else return(0); |
|||
} |
|||
|
|||
int32_t LP_isunspent(struct LP_utxoinfo *utxo) |
|||
{ |
|||
struct LP_address_utxo *up; struct _LP_utxoinfo u; struct iguana_info *coin; |
|||
if ( (coin= LP_coinfind(utxo->coin)) == 0 ) |
|||
return(0); |
|||
if ( (up= LP_address_utxofind(coin,utxo->coinaddr,utxo->payment.txid,utxo->payment.vout)) != 0 && up->spendheight > 0 ) |
|||
{ |
|||
utxo->T.spentflag = up->spendheight; |
|||
return(0); |
|||
} |
|||
u = (utxo->iambob != 0) ? utxo->deposit : utxo->fee; |
|||
if ( (up= LP_address_utxofind(coin,utxo->coinaddr,u.txid,u.vout)) != 0 && up->spendheight > 0 ) |
|||
{ |
|||
utxo->T.spentflag = up->spendheight; |
|||
return(0); |
|||
} |
|||
if ( utxo != 0 && utxo->T.spentflag == 0 && LP_isavailable(utxo) > 0 ) |
|||
return(1); |
|||
else return(0); |
|||
} |
|||
|
|||
struct LP_utxoinfo *LP_utxopairfind(int32_t iambob,bits256 txid,int32_t vout,bits256 txid2,int32_t vout2) |
|||
{ |
|||
struct LP_utxoinfo *utxo=0; struct _LP_utxoinfo u; |
|||
if ( (utxo= LP_utxofind(iambob,txid,vout)) != 0 ) |
|||
{ |
|||
u = (iambob != 0) ? utxo->deposit : utxo->fee; |
|||
if (vout2 == u.vout && bits256_cmp(u.txid,txid2) == 0 ) |
|||
return(utxo); |
|||
} |
|||
return(0); |
|||
} |
|||
|
|||
struct LP_utxoinfo *LP_utxofinds(int32_t iambob,bits256 txid,int32_t vout,bits256 txid2,int32_t vout2) |
|||
{ |
|||
struct LP_utxoinfo *utxo; |
|||
if ( (utxo= LP_utxofind(iambob,txid,vout)) != 0 || (utxo= LP_utxofind(iambob,txid2,vout2)) != 0 || (utxo= LP_utxo2find(iambob,txid,vout)) != 0 || (utxo= LP_utxo2find(iambob,txid2,vout2)) != 0 ) |
|||
return(utxo); |
|||
else return(0); |
|||
} |
|||
|
|||
int32_t LP_utxoaddptrs(struct LP_utxoinfo *ptrs[],int32_t n,struct LP_utxoinfo *utxo) |
|||
{ |
|||
int32_t i; |
|||
for (i=0; i<n; i++) |
|||
if ( ptrs[i] == utxo ) |
|||
return(n); |
|||
ptrs[n++] = utxo; |
|||
return(n); |
|||
} |
|||
|
|||
int32_t LP_utxocollisions(struct LP_utxoinfo *ptrs[],struct LP_utxoinfo *refutxo) |
|||
{ |
|||
int32_t iambob,n = 0; struct LP_utxoinfo *utxo; struct _LP_utxoinfo u; |
|||
if ( refutxo == 0 ) |
|||
return(0); |
|||
portable_mutex_lock(&LP_utxomutex); |
|||
for (iambob=0; iambob<=1; iambob++) |
|||
{ |
|||
if ( (utxo= _LP_utxofind(iambob,refutxo->payment.txid,refutxo->payment.vout)) != 0 && utxo != refutxo ) |
|||
n = LP_utxoaddptrs(ptrs,n,utxo); |
|||
if ( (utxo= _LP_utxo2find(iambob,refutxo->payment.txid,refutxo->payment.vout)) != 0 && utxo != refutxo ) |
|||
n = LP_utxoaddptrs(ptrs,n,utxo); |
|||
u = (refutxo->iambob != 0) ? refutxo->deposit : refutxo->fee; |
|||
if ( (utxo= _LP_utxofind(iambob,u.txid,u.vout)) != 0 && utxo != refutxo ) |
|||
n = LP_utxoaddptrs(ptrs,n,utxo); |
|||
if ( (utxo= _LP_utxo2find(iambob,u.txid,u.vout)) != 0 && utxo != refutxo ) |
|||
n = LP_utxoaddptrs(ptrs,n,utxo); |
|||
} |
|||
portable_mutex_unlock(&LP_utxomutex); |
|||
if ( 0 && n > 0 ) |
|||
printf("LP_utxocollisions n.%d\n",n); |
|||
return(n); |
|||
} |
|||
|
|||
int32_t _LP_availableset(struct LP_utxoinfo *utxo) |
|||
{ |
|||
int32_t flag = 0; |
|||
if ( utxo != 0 ) |
|||
{ |
|||
if ( bits256_nonz(utxo->S.otherpubkey) != 0 ) |
|||
flag = 1, memset(&utxo->S.otherpubkey,0,sizeof(utxo->S.otherpubkey)); |
|||
if ( utxo->S.swap != 0 ) |
|||
flag = 1, utxo->S.swap = 0; |
|||
if ( utxo->T.swappending != 0 ) |
|||
flag = 1, utxo->T.swappending = 0; |
|||
return(flag); |
|||
} |
|||
return(0); |
|||
} |
|||
|
|||
void _LP_unavailableset(struct LP_utxoinfo *utxo,bits256 otherpubkey) |
|||
{ |
|||
if ( utxo != 0 ) |
|||
{ |
|||
utxo->T.swappending = (uint32_t)(time(NULL) + LP_RESERVETIME); |
|||
utxo->S.otherpubkey = otherpubkey; |
|||
} |
|||
} |
|||
|
|||
void LP_unavailableset(struct LP_utxoinfo *utxo,bits256 otherpubkey) |
|||
{ |
|||
struct LP_utxoinfo *ptrs[8]; int32_t i,n; struct _LP_utxoinfo u; |
|||
memset(ptrs,0,sizeof(ptrs)); |
|||
if ( (n= LP_utxocollisions(ptrs,utxo)) > 0 ) |
|||
{ |
|||
for (i=0; i<n; i++) |
|||
_LP_unavailableset(ptrs[i],otherpubkey); |
|||
} |
|||
u = (utxo->iambob != 0) ? utxo->deposit : utxo->fee; |
|||
char str[65],str2[65]; printf("UTXO.[%d] RESERVED %s/v%d %s/v%d collisions.%d\n",utxo->iambob,bits256_str(str,utxo->payment.txid),utxo->payment.vout,bits256_str(str2,u.txid),u.vout,n); |
|||
_LP_unavailableset(utxo,otherpubkey); |
|||
} |
|||
|
|||
void LP_availableset(struct LP_utxoinfo *utxo) |
|||
{ |
|||
struct LP_utxoinfo *ptrs[8]; int32_t i,n,count = 0; struct _LP_utxoinfo u; |
|||
if ( utxo != 0 ) |
|||
{ |
|||
memset(ptrs,0,sizeof(ptrs)); |
|||
if ( (n= LP_utxocollisions(ptrs,utxo)) > 0 ) |
|||
{ |
|||
for (i=0; i<n; i++) |
|||
count += _LP_availableset(ptrs[i]); |
|||
} |
|||
count += _LP_availableset(utxo); |
|||
if ( count > 0 ) |
|||
{ |
|||
u = (utxo->iambob != 0) ? utxo->deposit : utxo->fee; |
|||
char str[65],str2[65]; printf("UTXO.[%d] AVAIL %s/v%d %s/v%d collisions.%d\n",utxo->iambob,bits256_str(str,utxo->payment.txid),utxo->payment.vout,bits256_str(str2,u.txid),u.vout,n); |
|||
} |
|||
} |
|||
} |
|||
|
|||
cJSON *LP_inventoryjson(cJSON *item,struct LP_utxoinfo *utxo) |
|||
{ |
|||
struct _LP_utxoinfo u; |
|||
//jaddstr(item,"method","oldutxo");
|
|||
if ( utxo == 0 ) |
|||
return(item); |
|||
if ( utxo->gui[0] != 0 ) |
|||
jaddstr(item,"gui",utxo->gui); |
|||
jaddstr(item,"coin",utxo->coin); |
|||
//jaddnum(item,"now",time(NULL));
|
|||
jaddnum(item,"iambob",utxo->iambob); |
|||
jaddstr(item,"address",utxo->coinaddr); |
|||
jaddbits256(item,"txid",utxo->payment.txid); |
|||
jaddnum(item,"vout",utxo->payment.vout); |
|||
jadd64bits(item,"value",utxo->payment.value); |
|||
jadd64bits(item,"satoshis",utxo->S.satoshis); |
|||
u = (utxo->iambob != 0) ? utxo->deposit : utxo->fee; |
|||
if ( bits256_nonz(u.txid) != 0 ) |
|||
{ |
|||
jaddbits256(item,"txid2",u.txid); |
|||
jaddnum(item,"vout2",u.vout); |
|||
jadd64bits(item,"value2",u.value); |
|||
} |
|||
if ( utxo->T.swappending != 0 ) |
|||
jaddnum(item,"pending",utxo->T.swappending); |
|||
if ( utxo->iambob != 0 ) |
|||
{ |
|||
jaddbits256(item,"srchash",utxo->pubkey);//LP_mypub25519);
|
|||
if ( bits256_nonz(utxo->S.otherpubkey) != 0 ) |
|||
jaddbits256(item,"desthash",utxo->S.otherpubkey); |
|||
} |
|||
else |
|||
{ |
|||
jaddbits256(item,"desthash",utxo->pubkey);//LP_mypub25519);
|
|||
if ( bits256_nonz(utxo->S.otherpubkey) != 0 ) |
|||
jaddbits256(item,"srchash",utxo->S.otherpubkey); |
|||
} |
|||
if ( utxo->S.swap != 0 ) |
|||
jaddstr(item,"swap","in progress"); |
|||
if ( utxo->T.spentflag != 0 ) |
|||
jaddnum(item,"spent",utxo->T.spentflag); |
|||
jaddnum(item,"session",utxo->T.sessionid); |
|||
return(item); |
|||
} |
|||
|
|||
cJSON *LP_utxojson(struct LP_utxoinfo *utxo) |
|||
{ |
|||
cJSON *item = cJSON_CreateObject(); |
|||
item = LP_inventoryjson(item,utxo); |
|||
jaddbits256(item,"pubkey",utxo->pubkey); |
|||
//jaddnum(item,"profit",utxo->S.profitmargin);
|
|||
jaddstr(item,"base",utxo->coin); |
|||
//jaddstr(item,"script",utxo->spendscript);
|
|||
return(item); |
|||
} |
|||
|
|||
struct LP_utxoinfo *LP_utxo_bestfit(char *symbol,uint64_t destsatoshis) |
|||
{ |
|||
uint64_t srcvalue,srcvalue2; struct LP_utxoinfo *utxo,*tmp,*bestutxo = 0; int32_t iambob = 0; |
|||
if ( symbol == 0 || destsatoshis == 0 ) |
|||
{ |
|||
printf("LP_utxo_bestfit error symbol.%p %.8f\n",symbol,dstr(destsatoshis)); |
|||
return(0); |
|||
} |
|||
// jl777 remove mempool
|
|||
HASH_ITER(hh,G.LP_utxoinfos[iambob],utxo,tmp) |
|||
{ |
|||
//char str[65]; printf("s%u %d [%.8f vs %.8f] check %s.%s avail.%d ismine.%d >= %d\n",utxo->T.spentflag,LP_iseligible(&srcvalue,&srcvalue2,utxo->iambob,symbol,utxo->payment.txid,utxo->payment.vout,utxo->S.satoshis,utxo->fee.txid,utxo->fee.vout),dstr(destsatoshis),dstr(utxo->S.satoshis),utxo->coin,bits256_str(str,utxo->payment.txid),LP_isavailable(utxo) > 0,LP_ismine(utxo) > 0,utxo->S.satoshis >= destsatoshis);
|
|||
if ( strcmp(symbol,utxo->coin) != 0 ) |
|||
continue; |
|||
if ( LP_isavailable(utxo) > 0 && LP_ismine(utxo) > 0 ) |
|||
{ |
|||
if ( utxo->S.satoshis >= destsatoshis && (bestutxo == 0 || (bestutxo->S.satoshis < destsatoshis && utxo->S.satoshis >= destsatoshis) || (bestutxo->S.satoshis >= destsatoshis && utxo->S.satoshis < bestutxo->S.satoshis)) ) |
|||
{ |
|||
if ( LP_iseligible(&srcvalue,&srcvalue2,utxo->iambob,symbol,utxo->payment.txid,utxo->payment.vout,utxo->S.satoshis,utxo->fee.txid,utxo->fee.vout) == 0 ) |
|||
{ |
|||
//if ( utxo->T.spentflag == 0 )
|
|||
// utxo->T.spentflag = (uint32_t)time(NULL);
|
|||
continue; |
|||
} |
|||
bestutxo = utxo; |
|||
} //else printf("skip alice utxo %.8f vs dest %.8f\n",dstr(utxo->S.satoshis),dstr(destsatoshis));
|
|||
} |
|||
} |
|||
return(bestutxo); |
|||
} |
|||
|
|||
void LP_spentnotify(struct LP_utxoinfo *utxo,int32_t selector) |
|||
{ |
|||
if ( utxo == 0 ) |
|||
return; |
|||
utxo->T.spentflag = (uint32_t)time(NULL); |
|||
} |
|||
|
|||
struct LP_utxoinfo *LP_utxoadd(int32_t iambob,char *symbol,bits256 txid,int32_t vout,int64_t value,bits256 txid2,int32_t vout2,int64_t value2,char *coinaddr,bits256 pubkey,char *gui,uint32_t sessionid) |
|||
{ |
|||
uint64_t val,val2=0,tmpsatoshis,txfee; int32_t spendvini,numconfirms,selector; bits256 spendtxid; struct iguana_info *coin; struct _LP_utxoinfo u; struct LP_utxoinfo *utxo = 0; |
|||
if ( symbol == 0 || symbol[0] == 0 || coinaddr == 0 || coinaddr[0] == 0 || bits256_nonz(txid) == 0 || bits256_nonz(txid2) == 0 || vout < 0 || vout2 < 0 || value <= 0 || value2 <= 0 )//|| sessionid == 0 )
|
|||
{ |
|||
char str[65],str2[65]; printf("REJECT %s iambob.%d %s utxoadd.(%.8f %.8f) %s/v%d %s/v%d\n",coinaddr,iambob,symbol,dstr(value),dstr(value2),bits256_str(str,txid),vout,bits256_str(str2,txid2),vout2); |
|||
printf("session.%u addutxo %d %d %d %d %d %d %d %d\n",sessionid,symbol == 0,coinaddr == 0,bits256_nonz(txid) == 0,bits256_nonz(txid2) == 0,vout < 0,vout2 < 0,value <= 0,value2 <= 0); |
|||
return(0); |
|||
} |
|||
if ( (coin= LP_coinfind(symbol)) == 0 || (IAMLP == 0 && coin->inactive != 0) ) |
|||
{ |
|||
//printf("LP_utxoadd reject inactive %s\n",symbol);
|
|||
return(0); |
|||
} |
|||
txfee = LP_txfeecalc(coin,0,0); |
|||
if ( iambob != 0 && value2 < 9 * (value >> 3) + 2*txfee ) // big txfee padding
|
|||
{ |
|||
if ( value2 > 2*txfee ) |
|||
tmpsatoshis = (((value2 - 2*txfee) / 9) << 3); |
|||
else |
|||
{ |
|||
printf("value2 %.8f <= 2 * %.8f\n",dstr(value2),dstr(txfee)); |
|||
return(0); |
|||
} |
|||
} else tmpsatoshis = (value - txfee); |
|||
char str[65],str2[65],dispflag = 0;//(iambob == 0);
|
|||
if ( iambob == 0 && bits256_cmp(pubkey,G.LP_mypub25519) != 0 ) |
|||
{ |
|||
printf("trying to add Alice utxo when not mine? %s/v%d\n",bits256_str(str,txid),vout); |
|||
return(0); |
|||
} |
|||
if ( coin->inactive == 0 ) |
|||
{ |
|||
if ( LP_iseligible(&val,&val2,iambob,symbol,txid,vout,tmpsatoshis,txid2,vout2) <= 0 ) |
|||
{ |
|||
static uint32_t counter; |
|||
if ( counter++ < 3 ) |
|||
printf("iambob.%d utxoadd %s inactive.%u got ineligible txid value %.8f:%.8f, value2 %.8f:%.8f, tmpsatoshis %.8f\n",iambob,symbol,coin->inactive,dstr(value),dstr(val),dstr(value2),dstr(val2),dstr(tmpsatoshis)); |
|||
return(0); |
|||
} |
|||
if ( (numconfirms= LP_numconfirms(symbol,coinaddr,txid,vout,0)) <= 0 ) |
|||
{ |
|||
printf("LP_utxoadd reject numconfirms.%d %s.%s\n",numconfirms,symbol,bits256_str(str,txid)); |
|||
return(0); |
|||
} |
|||
if ( (numconfirms= LP_numconfirms(symbol,coinaddr,txid2,vout2,0)) <= 0 ) |
|||
{ |
|||
printf("LP_utxoadd reject2 numconfirms.%d %s %s/v%d\n",numconfirms,symbol,bits256_str(str,txid2),vout2); |
|||
return(0); |
|||
} |
|||
} |
|||
else |
|||
{ |
|||
val = value; |
|||
val2 = value2; |
|||
} |
|||
dispflag = 0; |
|||
if ( dispflag != 0 ) |
|||
printf("%.8f %.8f %s iambob.%d %s utxoadd.(%.8f %.8f) %s %s\n",dstr(val),dstr(val2),coinaddr,iambob,symbol,dstr(value),dstr(value2),bits256_str(str,txid),bits256_str(str2,txid2)); |
|||
dispflag = 1; |
|||
if ( (utxo= LP_utxofinds(iambob,txid,vout,txid2,vout2)) != 0 ) |
|||
{ |
|||
if ( 0 && LP_ismine(utxo) == 0 ) |
|||
{ |
|||
char str2[65],str3[65]; printf("iambob.%d %s %s utxoadd.(%.8f %.8f) %s %s\n",iambob,bits256_str(str3,pubkey),symbol,dstr(value),dstr(value2),bits256_str(str,txid),bits256_str(str2,txid2)); |
|||
printf("duplicate %.8f %.8f %.8f vs utxo.(%.8f %.8f %.8f)\n",dstr(value),dstr(value2),dstr(tmpsatoshis),dstr(utxo->payment.value),dstr(utxo->deposit.value),dstr(utxo->S.satoshis)); |
|||
} |
|||
u = (utxo->iambob != 0) ? utxo->deposit : utxo->fee; |
|||
if ( bits256_cmp(txid,utxo->payment.txid) != 0 || bits256_cmp(txid2,u.txid) != 0 || vout != utxo->payment.vout || value != utxo->payment.value || tmpsatoshis != utxo->S.satoshis || vout2 != u.vout || value2 != u.value || strcmp(symbol,utxo->coin) != 0 || strcmp(coinaddr,utxo->coinaddr) != 0 || bits256_cmp(pubkey,utxo->pubkey) != 0 ) |
|||
{ |
|||
utxo->T.errors++; |
|||
char str[65],str2[65],str3[65],str4[65],str5[65],str6[65]; |
|||
if ( utxo->T.spentflag != 0 || LP_txvalue(0,utxo->coin,utxo->payment.txid,utxo->payment.vout) < utxo->payment.value || LP_txvalue(0,utxo->coin,u.txid,u.vout) < u.value ) |
|||
{ |
|||
//if ( utxo->T.spentflag == 0 )
|
|||
// utxo->T.spentflag = (uint32_t)time(NULL);
|
|||
printf("original utxo pair not valid\n"); |
|||
if ( dispflag != 0 ) |
|||
printf("error on subsequent utxo iambob.%d %.8f %.8f add.(%s %s) when.(%s %s) %d %d %d %d %d %d %d %d %d %d pubkeys.(%s vs %s)\n",iambob,dstr(val),dstr(val2),bits256_str(str,txid),bits256_str(str2,txid2),bits256_str(str3,utxo->payment.txid),bits256_str(str4,utxo->deposit.txid),bits256_cmp(txid,utxo->payment.txid) != 0,bits256_cmp(txid2,u.txid) != 0,vout != utxo->payment.vout,tmpsatoshis != utxo->S.satoshis,vout2 != u.vout,value2 != u.value,strcmp(symbol,utxo->coin) != 0,strcmp(coinaddr,utxo->coinaddr) != 0,bits256_cmp(pubkey,utxo->pubkey) != 0,value != utxo->payment.value,bits256_str(str5,pubkey),bits256_str(str6,utxo->pubkey)); |
|||
utxo = 0; |
|||
} |
|||
} |
|||
if ( utxo != 0 ) |
|||
{ |
|||
if ( utxo->T.sessionid == 0 ) |
|||
utxo->T.sessionid = sessionid; |
|||
//else if ( profitmargin > SMALLVAL )
|
|||
// utxo->S.profitmargin = profitmargin;
|
|||
utxo->T.lasttime = (uint32_t)time(NULL); |
|||
//printf("return existing utxo[%d] %s %s\n",iambob,bits256_str(str,utxo->payment.txid),bits256_str(str2,iambob != 0 ? utxo->deposit.txid : utxo->fee.txid));
|
|||
return(utxo); |
|||
} |
|||
} |
|||
utxo = calloc(1,sizeof(*utxo)); |
|||
//utxo->S.profitmargin = profitmargin;
|
|||
utxo->pubkey = pubkey; |
|||
safecopy(utxo->gui,gui,sizeof(utxo->gui)); |
|||
safecopy(utxo->coin,symbol,sizeof(utxo->coin)); |
|||
safecopy(utxo->coinaddr,coinaddr,sizeof(utxo->coinaddr)); |
|||
//safecopy(utxo->spendscript,spendscript,sizeof(utxo->spendscript));
|
|||
utxo->payment.txid = txid; |
|||
utxo->payment.vout = vout; |
|||
utxo->payment.value = value; |
|||
utxo->S.satoshis = tmpsatoshis; |
|||
if ( (utxo->iambob= iambob) != 0 ) |
|||
{ |
|||
utxo->deposit.txid = txid2; |
|||
utxo->deposit.vout = vout2; |
|||
utxo->deposit.value = value2; |
|||
} |
|||
else |
|||
{ |
|||
utxo->fee.txid = txid2; |
|||
utxo->fee.vout = vout2; |
|||
utxo->fee.value = value2; |
|||
} |
|||
LP_utxosetkey(utxo->key,txid,vout); |
|||
LP_utxosetkey(utxo->key2,txid2,vout2); |
|||
if ( LP_ismine(utxo) > 0 ) |
|||
utxo->T.sessionid = G.LP_sessionid; |
|||
else utxo->T.sessionid = sessionid; |
|||
if ( coin->inactive == 0 && (selector= LP_mempool_vinscan(&spendtxid,&spendvini,symbol,coinaddr,txid,vout,txid2,vout2)) >= 0 ) |
|||
{ |
|||
printf("utxoadd selector.%d spent in mempool %s vini.%d",selector,bits256_str(str,spendtxid),spendvini); |
|||
utxo->T.spentflag = (uint32_t)time(NULL); |
|||
} |
|||
//printf(" %s %.8f %.8f %p addutxo.%d (%s %s) session.%u iambob.%d <<<<<<<<<<<<<<<\n",symbol,dstr(value),dstr(value2),utxo,LP_ismine(utxo) > 0,bits256_str(str,utxo->payment.txid),bits256_str(str2,iambob != 0 ? utxo->deposit.txid : utxo->fee.txid),utxo->T.sessionid,iambob);
|
|||
portable_mutex_lock(&LP_utxomutex); |
|||
HASH_ADD_KEYPTR(hh,G.LP_utxoinfos[iambob],utxo->key,sizeof(utxo->key),utxo); |
|||
if ( _LP_utxo2find(iambob,txid2,vout2) == 0 ) |
|||
HASH_ADD_KEYPTR(hh2,G.LP_utxoinfos2[iambob],utxo->key2,sizeof(utxo->key2),utxo); |
|||
portable_mutex_unlock(&LP_utxomutex); |
|||
if ( iambob != 0 ) |
|||
{ |
|||
if ( LP_ismine(utxo) > 0 ) |
|||
{ |
|||
//LP_utxo_clientpublish(utxo);
|
|||
if ( LP_mypeer != 0 ) |
|||
utxo->T.lasttime = (uint32_t)time(NULL); |
|||
} |
|||
} |
|||
return(utxo); |
|||
} |
|||
|
|||
cJSON *LP_inventory(char *symbol) |
|||
{ |
|||
struct LP_utxoinfo *utxo,*tmp; struct _LP_utxoinfo u; char *myipaddr; cJSON *array; uint64_t val,val2; int32_t iambob = 0; struct iguana_info *coin; |
|||
array = cJSON_CreateArray(); |
|||
if ( LP_mypeer != 0 ) |
|||
myipaddr = LP_mypeer->ipaddr; |
|||
else myipaddr = "127.0.0.1"; |
|||
if ( (coin= LP_coinfind(symbol)) != 0 ) |
|||
LP_listunspent_both(symbol,coin->smartaddr,0); |
|||
HASH_ITER(hh,G.LP_utxoinfos[iambob],utxo,tmp) |
|||
{ |
|||
char str[65]; |
|||
//printf("iambob.%d iterate %s\n",iambob,bits256_str(str,LP_mypub25519));
|
|||
if ( LP_isunspent(utxo) != 0 && strcmp(symbol,utxo->coin) == 0 && utxo->iambob == iambob && LP_ismine(utxo) > 0 ) |
|||
{ |
|||
u = (iambob != 0) ? utxo->deposit : utxo->fee; |
|||
if ( LP_iseligible(&val,&val2,iambob,utxo->coin,utxo->payment.txid,utxo->payment.vout,utxo->S.satoshis,u.txid,u.vout) == 0 ) |
|||
{ |
|||
//if ( utxo->T.spentflag == 0 )
|
|||
// utxo->T.spentflag = (uint32_t)time(NULL);
|
|||
printf("%s %s ineligible %.8f %.8f\n",utxo->coin,bits256_str(str,u.txid),dstr(val),dstr(val2)); |
|||
continue; |
|||
} |
|||
//if ( iambob != 0 )
|
|||
// LP_utxo_clientpublish(utxo);
|
|||
jaddi(array,LP_inventoryjson(cJSON_CreateObject(),utxo)); |
|||
} |
|||
else if ( 0 && LP_ismine(utxo) > 0 && strcmp(symbol,utxo->coin) == 0 ) |
|||
printf("skip %s %s %d %d %d %d\n",utxo->coin,bits256_str(str,utxo->payment.txid),LP_isunspent(utxo) != 0,strcmp(symbol,utxo->coin) == 0,utxo->iambob == iambob,LP_ismine(utxo) > 0); |
|||
} |
|||
return(array); |
|||
} |
|||
|
|||
int32_t LP_maxvalue(uint64_t *values,int32_t n) |
|||
{ |
|||
int32_t i,maxi = -1; uint64_t maxval = 0; |
|||
for (i=0; i<n; i++) |
|||
if ( values[i] > maxval ) |
|||
{ |
|||
maxi = i; |
|||
maxval = values[i]; |
|||
} |
|||
return(maxi); |
|||
} |
|||
|
|||
int32_t LP_nearestvalue(int32_t iambob,uint64_t *values,int32_t n,uint64_t targetval) |
|||
{ |
|||
int32_t i,mini = -1; int64_t dist; uint64_t mindist = (1 << 31); |
|||
for (i=0; i<n; i++) |
|||
{ |
|||
dist = (values[i] - targetval); |
|||
if ( iambob != 0 && dist < 0 && -dist < values[i]/10 ) |
|||
dist = -dist; |
|||
//printf("(%.8f %.8f %.8f).%d ",dstr(values[i]),dstr(dist),dstr(mindist),mini);
|
|||
if ( dist >= 0 && dist < mindist ) |
|||
{ |
|||
mini = i; |
|||
mindist = dist; |
|||
} |
|||
} |
|||
return(mini); |
|||
} |
|||
|
|||
int32_t LP_privkey_init(int32_t mypubsock,struct iguana_info *coin,bits256 myprivkey,bits256 mypub) |
|||
{ |
|||
int32_t enable_utxos = 0; |
|||
char *script,destaddr[64]; struct LP_utxoinfo *utxo; cJSON *array,*item; bits256 txid,deposittxid; int32_t used,i,flag=0,height,n,cmpflag,iambob,vout,depositvout; uint64_t *values=0,satoshis,txfee,depositval,value,total = 0; int64_t targetval; |
|||
if ( coin == 0 || (IAMLP == 0 && coin->inactive != 0) ) |
|||
{ |
|||
//printf("coin not active\n");
|
|||
return(0); |
|||
} |
|||
//printf("privkey init.(%s) %s\n",coin->symbol,coin->smartaddr);
|
|||
if ( coin->inactive == 0 ) |
|||
LP_listunspent_issue(coin->symbol,coin->smartaddr,0); |
|||
LP_address(coin,coin->smartaddr); |
|||
if ( coin->inactive == 0 && (array= LP_listunspent(coin->symbol,coin->smartaddr)) != 0 ) |
|||
{ |
|||
txfee = LP_txfeecalc(coin,0,0); |
|||
if ( is_cJSON_Array(array) != 0 && (n= cJSON_GetArraySize(array)) > 0 ) |
|||
{ |
|||
//printf("LP_privkey_init %s %s\n",coin->symbol,jprint(array,0));
|
|||
for (iambob=0; iambob<=1; iambob++) |
|||
{ |
|||
if ( iambob == 0 ) |
|||
values = calloc(n,sizeof(*values)); |
|||
else memset(values,0,n * sizeof(*values)); |
|||
used = 0; |
|||
for (i=0; i<n; i++) |
|||
{ |
|||
item = jitem(array,i); |
|||
if ( coin->electrum == 0 ) |
|||
{ |
|||
txid = jbits256(item,"txid"); |
|||
vout = juint(item,"vout"); |
|||
value = LP_value_extract(item,0); |
|||
height = LP_txheight(coin,txid);//LP_getheight(coin) - jint(item,"confirmations") + 1;
|
|||
} |
|||
else |
|||
{ |
|||
txid = jbits256(item,"tx_hash"); |
|||
vout = juint(item,"tx_pos"); |
|||
value = j64bits(item,"value"); |
|||
height = jint(item,"height"); |
|||
} |
|||
satoshis = LP_txvalue(destaddr,coin->symbol,txid,vout); |
|||
if ( satoshis != 0 && satoshis != value ) |
|||
printf("%s %s unexpected privkey_init value mismatch %.8f vs %.8f (%s) %.8f %.8f\n",coin->symbol,coin->smartaddr,dstr(satoshis),dstr(value),jprint(item,0),jdouble(item,"amount"),jdouble(item,"interest")); |
|||
if ( LP_inventory_prevent(iambob,coin->symbol,txid,vout) == 0 && height > 0 ) |
|||
{ |
|||
//printf("%s\n",jprint(item,0));
|
|||
values[i] = satoshis; |
|||
//flag += LP_address_utxoadd(coin,destaddr,txid,vout,satoshis,height,-1);
|
|||
} else used++; |
|||
} |
|||
//printf("array.%d\n",n);
|
|||
while ( used < n-1 ) |
|||
{ |
|||
//for (i=0; i<n; i++)
|
|||
// printf("%.8f ",dstr(values[i]));
|
|||
//printf("used.%d of n.%d\n",used,n);
|
|||
if ( (i= LP_maxvalue(values,n)) >= 0 ) |
|||
{ |
|||
item = jitem(array,i); |
|||
if ( coin->electrum == 0 ) |
|||
{ |
|||
deposittxid = jbits256(item,"txid"); |
|||
depositvout = juint(item,"vout"); |
|||
script = jstr(item,"scriptPubKey"); |
|||
} |
|||
else |
|||
{ |
|||
deposittxid = jbits256(item,"tx_hash"); |
|||
depositvout = juint(item,"tx_pos"); |
|||
script = coin->smartaddr; |
|||
} |
|||
depositval = values[i]; |
|||
values[i] = 0, used++; |
|||
if ( iambob == 0 ) |
|||
targetval = (depositval / 776) + txfee; |
|||
else targetval = (depositval / 9) * 8 + 2*txfee; |
|||
if ( targetval < txfee*2 ) |
|||
targetval = txfee*2; |
|||
//printf("iambob.%d i.%d deposit %.8f min %.8f target %.8f\n",iambob,i,dstr(depositval),dstr((1+LP_MINSIZE_TXFEEMULT)*txfee),dstr(targetval));
|
|||
if ( depositval < (1+LP_MINSIZE_TXFEEMULT)*txfee ) |
|||
continue; |
|||
i = -1; |
|||
if ( iambob != 0 ) |
|||
{ |
|||
if ( (i= LP_nearestvalue(iambob,values,n,targetval)) < 0 ) |
|||
targetval /= 4; |
|||
if ( targetval < txfee*(1+LP_MINSIZE_TXFEEMULT) ) |
|||
continue; |
|||
} |
|||
if ( i >= 0 || (i= LP_nearestvalue(iambob,values,n,targetval)) >= 0 ) |
|||
{ |
|||
//printf("iambob.%d i.%d %.8f target %.8f\n",iambob,i,dstr(depositval),dstr(targetval));
|
|||
item = jitem(array,i); |
|||
cmpflag = 0; |
|||
if ( coin->electrum == 0 ) |
|||
{ |
|||
txid = jbits256(item,"txid"); |
|||
vout = juint(item,"vout"); |
|||
if ( jstr(item,"scriptPubKey") != 0 && strcmp(script,jstr(item,"scriptPubKey")) == 0 ) |
|||
cmpflag = 1; |
|||
} |
|||
else |
|||
{ |
|||
txid = jbits256(item,"tx_hash"); |
|||
vout = juint(item,"tx_pos"); |
|||
cmpflag = 1; |
|||
} |
|||
if ( cmpflag != 0 ) |
|||
{ |
|||
value = values[i]; |
|||
values[i] = 0, used++; |
|||
portable_mutex_lock(&LP_UTXOmutex); |
|||
if ( iambob != 0 ) |
|||
{ |
|||
if ( (utxo= LP_utxoadd(1,coin->symbol,txid,vout,value,deposittxid,depositvout,depositval,coin->smartaddr,mypub,LP_gui,G.LP_sessionid)) != 0 ) |
|||
{ |
|||
} |
|||
} |
|||
else |
|||
{ |
|||
//printf("call utxoadd\n");
|
|||
if ( (utxo= LP_utxoadd(0,coin->symbol,deposittxid,depositvout,depositval,txid,vout,value,coin->smartaddr,mypub,LP_gui,G.LP_sessionid)) != 0 ) |
|||
{ |
|||
} |
|||
} |
|||
portable_mutex_unlock(&LP_UTXOmutex); |
|||
total += value; |
|||
} // else printf("scriptmismatch.(%s) vs %s\n",script,jprint(item,0));
|
|||
} //else printf("nothing near i.%d\n",i);
|
|||
} else break; |
|||
} |
|||
if ( enable_utxos == 0 ) |
|||
break; |
|||
} |
|||
} |
|||
free_json(array); |
|||
if ( flag != 0 ) |
|||
LP_postutxos(coin->symbol,coin->smartaddr); |
|||
} |
|||
if ( values != 0 ) |
|||
free(values); |
|||
//printf("privkey.%s %.8f\n",symbol,dstr(total));
|
|||
return(flag); |
|||
} |
|||
|
|||
char *LP_secretaddresses(void *ctx,char *prefix,char *passphrase,int32_t n,uint8_t taddr,uint8_t pubtype) |
|||
{ |
|||
int32_t i; uint8_t tmptype,pubkey33[33],rmd160[20]; char output[777*45],str[65],str2[65],buf[8192],wifstr[128],coinaddr[64]; bits256 checkprivkey,privkey,pubkey; cJSON *retjson; |
|||
retjson = cJSON_CreateObject(); |
|||
if ( prefix == 0 || prefix[0] == 0 ) |
|||
prefix = "secretaddress"; |
|||
if ( passphrase == 0 || passphrase[0] == 0 ) |
|||
passphrase = "password"; |
|||
if ( n <= 0 ) |
|||
n = 16; |
|||
else if ( n > 777 ) |
|||
n = 777; |
|||
conv_NXTpassword(privkey.bytes,pubkey.bytes,(uint8_t *)passphrase,(int32_t)strlen(passphrase)); |
|||
bitcoin_priv2pub(ctx,pubkey33,coinaddr,privkey,taddr,pubtype); |
|||
printf("generator (%s) secrets.[%d] <%s> t.%u p.%u\n",coinaddr,n,passphrase,taddr,pubtype); |
|||
sprintf(output,"\"addresses\":["); |
|||
for (i=0; i<n; i++) |
|||
{ |
|||
sprintf(buf,"%s %s %03d",prefix,passphrase,i); |
|||
conv_NXTpassword(privkey.bytes,pubkey.bytes,(uint8_t *)buf,(int32_t)strlen(buf)); |
|||
bitcoin_priv2pub(ctx,pubkey33,coinaddr,privkey,taddr,pubtype); |
|||
bitcoin_priv2wif(0,wifstr,privkey,188); |
|||
bitcoin_wif2priv(0,&tmptype,&checkprivkey,wifstr); |
|||
bitcoin_addr2rmd160(taddr,&tmptype,rmd160,coinaddr); |
|||
if ( bits256_cmp(checkprivkey,privkey) != 0 ) |
|||
{ |
|||
printf("WIF.(%s) error -> %s vs %s?\n",wifstr,bits256_str(str,privkey),bits256_str(str2,checkprivkey)); |
|||
free_json(retjson); |
|||
return(clonestr("{\"error\":\"couldnt validate wifstr\"}")); |
|||
} |
|||
else if ( tmptype != pubtype ) |
|||
{ |
|||
printf("checktype.%d != pubtype.%d\n",tmptype,pubtype); |
|||
free_json(retjson); |
|||
return(clonestr("{\"error\":\"couldnt validate pubtype\"}")); |
|||
} |
|||
jaddstr(retjson,coinaddr,wifstr); |
|||
sprintf(output+strlen(output),"\\\"%s\\\"%c ",coinaddr,i<n-1?',':' '); |
|||
printf("./komodo-cli jumblr_secret %s\n",coinaddr); |
|||
} |
|||
printf("%s]\n",output); |
|||
return(jprint(retjson,1)); |
|||
} |
|||
|
|||
bits256 LP_privkeycalc(void *ctx,uint8_t *pubkey33,bits256 *pubkeyp,struct iguana_info *coin,char *passphrase,char *wifstr) |
|||
{ |
|||
//static uint32_t counter;
|
|||
bits256 privkey,userpub,userpass,checkkey; char tmpstr[128]; cJSON *retjson; uint8_t tmptype; |
|||
if ( passphrase != 0 && passphrase[0] != 0 ) |
|||
{ |
|||
conv_NXTpassword(privkey.bytes,pubkeyp->bytes,(uint8_t *)passphrase,(int32_t)strlen(passphrase)); |
|||
//vcalc_sha256(0,checkkey.bytes,(uint8_t *)passphrase,(int32_t)strlen(passphrase));
|
|||
//printf("SHA256.(%s) ",bits256_str(pstr,checkkey));
|
|||
//printf("privkey.(%s)\n",bits256_str(pstr,privkey));
|
|||
} |
|||
else |
|||
{ |
|||
bitcoin_wif2priv(coin->wiftaddr,&tmptype,&privkey,wifstr); |
|||
if ( 0 ) |
|||
{ |
|||
char str[65],str2[65]; |
|||
checkkey = iguana_wif2privkey(wifstr); |
|||
if ( bits256_cmp(checkkey,privkey) != 0 ) |
|||
printf("WIF.(%s) -> %s or %s?\n",wifstr,bits256_str(str,privkey),bits256_str(str2,checkkey)); |
|||
} |
|||
} |
|||
privkey.bytes[0] &= 248, privkey.bytes[31] &= 127, privkey.bytes[31] |= 64; |
|||
bitcoin_priv2pub(ctx,coin->pubkey33,coin->smartaddr,privkey,coin->taddr,coin->pubtype); |
|||
if ( coin->counter == 0 ) |
|||
{ |
|||
coin->counter++; |
|||
memcpy(G.LP_pubsecp,coin->pubkey33,33); |
|||
bitcoin_priv2wif(coin->wiftaddr,tmpstr,privkey,coin->wiftype); |
|||
bitcoin_addr2rmd160(coin->taddr,&tmptype,G.LP_myrmd160,coin->smartaddr); |
|||
LP_privkeyadd(privkey,G.LP_myrmd160); |
|||
G.LP_privkey = privkey; |
|||
if ( 0 && (coin->pubtype != 60 || strcmp(coin->symbol,"KMD") == 0) ) |
|||
printf("%s (%s) %d wif.(%s) (%s)\n",coin->symbol,coin->smartaddr,coin->pubtype,tmpstr,passphrase); |
|||
if ( G.counter++ == 0 ) |
|||
{ |
|||
bitcoin_priv2wif(coin->wiftaddr,G.USERPASS_WIFSTR,privkey,188); |
|||
bitcoin_wif2priv(coin->wiftaddr,&tmptype,&checkkey,G.USERPASS_WIFSTR); |
|||
if ( bits256_cmp(checkkey,privkey) != 0 ) |
|||
{ |
|||
char str[65],str2[65]; |
|||
printf("FATAL ERROR converting USERPASS_WIFSTR %s -> %s != %s\n",G.USERPASS_WIFSTR,bits256_str(str,checkkey),bits256_str(str2,privkey)); |
|||
exit(-1); |
|||
} |
|||
conv_NXTpassword(userpass.bytes,pubkeyp->bytes,(uint8_t *)G.USERPASS_WIFSTR,(int32_t)strlen(G.USERPASS_WIFSTR)); |
|||
userpub = curve25519(userpass,curve25519_basepoint9()); |
|||
printf("userpass.(%s)\n",bits256_str(G.USERPASS,userpub)); |
|||
} |
|||
if ( coin->electrum == 0 && coin->userpass[0] != 0 ) |
|||
{ |
|||
LP_listunspent_issue(coin->symbol,coin->smartaddr,0); |
|||
if ( (retjson= LP_importprivkey(coin->symbol,tmpstr,coin->smartaddr,-1)) != 0 ) |
|||
{ |
|||
if ( jobj(retjson,"error") != 0 ) |
|||
{ |
|||
printf("cant importprivkey.%s -> (%s), abort session\n",coin->symbol,jprint(retjson,1)); |
|||
exit(-1); |
|||
} |
|||
} else free_json(retjson); |
|||
} |
|||
} |
|||
vcalc_sha256(0,checkkey.bytes,privkey.bytes,sizeof(privkey)); |
|||
checkkey.bytes[0] &= 248, checkkey.bytes[31] &= 127, checkkey.bytes[31] |= 64; |
|||
G.LP_mypub25519 = *pubkeyp = curve25519(checkkey,curve25519_basepoint9()); |
|||
G.LP_mypriv25519 = checkkey; |
|||
LP_pubkeyadd(G.LP_mypub25519); |
|||
return(privkey); |
|||
} |
|||
|
|||
void LP_privkey_updates(void *ctx,int32_t pubsock,char *passphrase) |
|||
{ |
|||
struct iguana_info *coin,*tmp; bits256 pubkey,privkey; uint8_t pubkey33[33]; int32_t initonly; |
|||
initonly = (passphrase != 0); |
|||
memset(privkey.bytes,0,sizeof(privkey)); |
|||
memset(pubkey.bytes,0,sizeof(pubkey)); |
|||
//printf("Total coins: %d\n", HASH_COUNT(LP_coins));
|
|||
//int num_iter = 0;
|
|||
HASH_ITER(hh,LP_coins,coin,tmp) |
|||
{ |
|||
//printf("LP_privkey_updates [%02d / %02d]\n", num_iter++, HASH_COUNT(LP_coins));
|
|||
if ( initonly != 0 ) |
|||
{ |
|||
coin->counter = 0; |
|||
memset(coin->smartaddr,0,sizeof(coin->smartaddr)); |
|||
if ( bits256_nonz(privkey) == 0 || coin->smartaddr[0] == 0 ) |
|||
privkey = LP_privkeycalc(ctx,pubkey33,&pubkey,coin,passphrase,""); |
|||
} |
|||
//printf("i.%d of %d\n",i,LP_numcoins);
|
|||
else if ( IAMLP == 0 || coin->inactive == 0 ) |
|||
{ |
|||
//printf("from updates %s\n",coin->symbol);
|
|||
if ( LP_privkey_init(pubsock,coin,G.LP_privkey,G.LP_mypub25519) == 0 && (rand() % 10) == 0 ) |
|||
LP_postutxos(coin->symbol,coin->smartaddr); |
|||
} |
|||
} |
|||
} |
|||
|
|||
int32_t LP_passphrase_init(char *passphrase,char *gui) |
|||
{ |
|||
static void *ctx; int32_t iambob,counter; struct LP_utxoinfo *utxo,*tmp; |
|||
if ( ctx == 0 ) |
|||
ctx = bitcoin_ctx(); |
|||
if ( G.LP_pendingswaps != 0 ) |
|||
return(-1); |
|||
G.initializing = 1; |
|||
if ( gui == 0 ) |
|||
gui = "cli"; |
|||
counter = G.USERPASS_COUNTER; |
|||
while ( G.waiting == 0 ) |
|||
{ |
|||
printf("waiting for G.waiting\n"); |
|||
sleep(5); |
|||
} |
|||
for (iambob=0; iambob<2; iambob++) |
|||
{ |
|||
if ( G.LP_utxoinfos[iambob] != 0 ) |
|||
{ |
|||
HASH_ITER(hh,G.LP_utxoinfos[iambob],utxo,tmp) |
|||
{ |
|||
HASH_DELETE(hh,G.LP_utxoinfos[iambob],utxo); |
|||
//free(utxo);
|
|||
} |
|||
} |
|||
if ( G.LP_utxoinfos2[iambob] != 0 ) |
|||
{ |
|||
G.LP_utxoinfos2[iambob] = 0; |
|||
/*HASH_ITER(hh,G.LP_utxoinfos2[iambob],utxo,tmp)
|
|||
{ |
|||
HASH_DELETE(hh,G.LP_utxoinfos2[iambob],utxo); |
|||
free(utxo); |
|||
}*/ |
|||
} |
|||
} |
|||
memset(&G,0,sizeof(G)); |
|||
LP_privkey_updates(ctx,LP_mypubsock,passphrase); |
|||
init_hexbytes_noT(G.LP_myrmd160str,G.LP_myrmd160,20); |
|||
G.LP_sessionid = (uint32_t)time(NULL); |
|||
safecopy(G.gui,gui,sizeof(G.gui)); |
|||
G.USERPASS_COUNTER = counter; |
|||
return(0); |
|||
} |
|||
|
|||
|
@ -1,10 +1,15 @@ |
|||
#cd ..
|
|||
|
|||
#emcc -s ASSERTIONS=1 -s ASYNCIFY=1 -s TOTAL_MEMORY=134217728 --preload-file coins.json -D__PNACL -DFROM_JS -O2 -I../includes -I../crypto777 -s PTHREAD_POOL_SIZE=8 -s USE_PTHREADS=1 -o /var/www/html/index.html exchanges/mm.c $(CRYPTO777_SRCS) mini-gmp.c secp256k1/src/secp256k1.c -lm -lc
|
|||
|
|||
#include ../crypto777/crypto777.sources
|
|||
#emcc -s ASSERTIONS=1 -s ASYNCIFY=1 -s TOTAL_MEMORY=134217728 --preload-file coins.json -D__PNACL -DFROM_JS -O2 -I../includes -I../crypto777 -o /var/www/html/index.html exchanges/mm.c $(CRYPTO777_SRCS) mini-gmp.c secp256k1/src/secp256k1.c -lm -lc
|
|||
|
|||
#emcc -s WASM=1 -s EXPORTED_FUNCTIONS="['_main', '_barterDEX']" -s ABORTING_MALLOC=0 -s ASSERTIONS=1 -s ASYNCIFY=1 -s TOTAL_MEMORY=167772160 --embed-file coins.json -DFROM_JS -O2 -I../includes -I../crypto777 -o /var/www/html/index.html exchanges/mm.c ../crypto777/*.c ../crypto777/jpeg/*.c ../crypto777/jpeg/unix/*.c mini-gmp.c secp256k1/src/secp256k1.c -lm
|
|||
|
|||
#emcc -s WASM=1 -s EXPORTED_FUNCTIONS="['_barterDEX', '_main']" -s ABORTING_MALLOC=0 -s ASSERTIONS=1 -s ASYNCIFY=1 -s TOTAL_MEMORY=167772160 --embed-file coins.json -DFROM_JS -I../includes -I../crypto777 -o /var/www/html/index.hmtl exchanges/mm.c ../crypto777/*.c ../crypto777/jpeg/*.c ../crypto777/jpeg/unix/*.c mini-gmp.c secp256k1/src/secp256k1.c -lm
|
|||
|
|||
#emcc -s EXPORTED_FUNCTIONS="['_main', '_barterDEX']" -s ABORTING_MALLOC=0 -s ASSERTIONS=1 -s ASYNCIFY=1 -s TOTAL_MEMORY=167772160 --embed-file coins.json -DFROM_JS -I../includes -I../crypto777 -o /var/www/html/barterDEX.js exchanges/barterDEX.c
|
|||
|
|||
all: |
|||
emcc -s PTHREAD_POOL_SIZE=8 -s USE_PTHREADS=1 -s ABORTING_MALLOC=0 -s ASSERTIONS=1 -s ASYNCIFY=1 -s TOTAL_MEMORY=536870912 --preload-file coins.json -DFROM_JS -O2 -I../includes -I../crypto777 -s PTHREAD_POOL_SIZE=8 -s USE_PTHREADS=1 -o /var/www/html/index.html exchanges/mm.c ../crypto777/*.c ../crypto777/jpeg/*.c ../crypto777/jpeg/unix/*.c mini-gmp.c secp256k1/src/secp256k1.c -lm -lpthread |
|||
emcc -s WASM=1 -s EXPORTED_FUNCTIONS="['_main', '_barterDEX']" -s ABORTING_MALLOC=0 -s ASSERTIONS=1 -s ASYNCIFY=1 -s TOTAL_MEMORY=167772160 --embed-file coins.json -DFROM_JS -O2 -I../includes -I../crypto777 -o /var/www/html/index.html exchanges/mm.c ../crypto777/*.c ../crypto777/jpeg/*.c ../crypto777/jpeg/unix/*.c mini-gmp.c secp256k1/src/secp256k1.c -lm |
|||
|
|||
|
@ -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\"}" |
@ -0,0 +1,3 @@ |
|||
#!/bin/bash |
|||
source userpass |
|||
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"balances\"}" |
@ -0,0 +1,14 @@ |
|||
#include <stdio.h> |
|||
#include <stdlib.h> |
|||
#include <memory.h> |
|||
#include <string.h> |
|||
|
|||
char *barterDEX(char *jsonstr) |
|||
{ |
|||
char *retstr,*str = "{\"result\":\"success\"}"; |
|||
printf("barterDEX.(%s)\n",jsonstr); |
|||
retstr = malloc(strlen(str)+1); |
|||
strcpy(retstr,str); |
|||
return(retstr); |
|||
} |
|||
|
@ -0,0 +1,3 @@ |
|||
#!/bin/bash |
|||
source userpass |
|||
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"bot_buy\",\"base\":\"REVS\",\"rel\":\"KMD\",\"maxprice\":3,\"relvolume\":10.0}" |
@ -0,0 +1,3 @@ |
|||
#!/bin/bash |
|||
source userpass |
|||
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"bot_list\"}" |
@ -0,0 +1,3 @@ |
|||
#!/bin/bash |
|||
source userpass |
|||
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"bot_pause\",\"botid\":$1}" |
@ -0,0 +1,3 @@ |
|||
#!/bin/bash |
|||
source userpass |
|||
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"bot_resume\",\"botid\":$1}" |
@ -0,0 +1,3 @@ |
|||
#!/bin/bash |
|||
source userpass |
|||
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"bot_sell\",\"base\":\"REVS\",\"rel\":\"KMD\",\"minprice\":2,\"basevolume\":5.0}" |
@ -0,0 +1,3 @@ |
|||
#!/bin/bash |
|||
source userpass |
|||
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"bot_settings\",\"botid\":$1,\"newprice\":$2,\"newvolume\":$3}" |
@ -0,0 +1,3 @@ |
|||
#!/bin/bash |
|||
source userpass |
|||
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"bot_status\",\"botid\":$1}" |
@ -0,0 +1,3 @@ |
|||
#!/bin/bash |
|||
source userpass |
|||
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"bot_statuslist\"}" |
@ -0,0 +1,3 @@ |
|||
#!/bin/bash |
|||
source userpass |
|||
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"bot_stop\",\"botid\":$1}" |
@ -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}" |
@ -0,0 +1,3 @@ |
|||
#!/bin/bash |
|||
source userpass |
|||
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"instantdex_claim\"}" |
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,3 @@ |
|||
#!/bin/bash |
|||
source userpass |
|||
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"instantdex_deposit\",\"weeks\":1,\"amount\":10.0,\"broadcast\":1}" |
@ -0,0 +1,3 @@ |
|||
#!/bin/bash |
|||
source userpass |
|||
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"instantdex_deposit\",\"weeks\":10,\"amount\":10.0,\"broadcast\":1}" |
@ -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}" |
@ -0,0 +1,3 @@ |
|||
#!/bin/bash |
|||
source userpass |
|||
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"dynamictrust\",\"address\":\"RMfQwu5ey23eWJ4as2ckd8dqsQJwo836ny\"}" |
@ -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,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 |
|||
source passphrase |
|||
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"inventory\",\"coin\":\"KMD\",\"reset\":1,\"passphrase\":\"$passphrase\"}" |
@ -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}" |
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue