jl777
8 years ago
committed by
GitHub
60 changed files with 4763 additions and 1714 deletions
@ -0,0 +1,2 @@ |
|||
curl --url "http://127.0.0.1:7778" --data "{\"conf\":\"COQUI.conf\",\"path\":\"${HOME#"/"}/.komodo/COQUI\",\"unitval\":\"20\",\"zcash\":1,\"RELAY\":0,\"VALIDATE\":1,\"prefetchlag\":-1,\"poll\":100,\"active\":1,\"agent\":\"iguana\",\"method\":\"addcoin\",\"startpend\":4,\"endpend\":4,\"services\":129,\"maxpeers\":8,\"newcoin\":\"COQUI\",\"name\":\"COQUI\",\"hasheaders\":1,\"useaddmultisig\":0,\"netmagic\":\"dd5ce076\",\"p2p\":12455,\"rpc\":12456,\"pubval\":60,\"p2shval\":85,\"wifval\":188,\"txfee_satoshis\":\"10000\",\"isPoS\":0,\"minoutput\":10000,\"minconfirms\":2,\"genesishash\":\"027e3758c3a65b12aa1046462b486d0a63bfa1beae327897f56c5cfb7daaae71\",\"protover\":170002,\"genesisblock\":\"0100000000000000000000000000000000000000000000000000000000000000000000003ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a000000000000000000000000000000000000000000000000000000000000000029ab5f490f0f0f200b00000000000000000000000000000000000000000000000000000000000000fd4005000d5ba7cda5d473947263bf194285317179d2b0d307119c2e7cc4bd8ac456f0774bd52b0cd9249be9d40718b6397a4c7bbd8f2b3272fed2823cd2af4bd1632200ba4bf796727d6347b225f670f292343274cc35099466f5fb5f0cd1c105121b28213d15db2ed7bdba490b4cedc69742a57b7c25af24485e523aadbb77a0144fc76f79ef73bd8530d42b9f3b9bed1c135ad1fe152923fafe98f95f76f1615e64c4abb1137f4c31b218ba2782bc15534788dda2cc08a0ee2987c8b27ff41bd4e31cd5fb5643dfe862c9a02ca9f90c8c51a6671d681d04ad47e4b53b1518d4befafefe8cadfb912f3d03051b1efbf1dfe37b56e93a741d8dfd80d576ca250bee55fab1311fc7b3255977558cdda6f7d6f875306e43a14413facdaed2f46093e0ef1e8f8a963e1632dcbeebd8e49fd16b57d49b08f9762de89157c65233f60c8e38a1f503a48c555f8ec45dedecd574a37601323c27be597b956343107f8bd80f3a925afaf30811df83c402116bb9c1e5231c70fff899a7c82f73c902ba54da53cc459b7bf1113db65cc8f6914d3618560ea69abd13658fa7b6af92d374d6eca9529f8bd565166e4fcbf2a8dfb3c9b69539d4d2ee2e9321b85b331925df195915f2757637c2805e1d4131e1ad9ef9bc1bb1c732d8dba4738716d351ab30c996c8657bab39567ee3b29c6d054b711495c0d52e1cd5d8e55b4f0f0325b97369280755b46a02afd54be4ddd9f77c22272b8bbb17ff5118fedbae2564524e797bd28b5f74f7079d532ccc059807989f94d267f47e724b3f1ecfe00ec9e6541c961080d8891251b84b4480bc292f6a180bea089fef5bbda56e1e41390d7c0e85ba0ef530f7177413481a226465a36ef6afe1e2bca69d2078712b3912bba1a99b1fbff0d355d6ffe726d2bb6fbc103c4ac5756e5bee6e47e17424ebcbf1b63d8cb90ce2e40198b4f4198689daea254307e52a25562f4c1455340f0ffeb10f9d8e914775e37d0edca019fb1b9c6ef81255ed86bc51c5391e0591480f66e2d88c5f4fd7277697968656a9b113ab97f874fdd5f2465e5559533e01ba13ef4a8f7a21d02c30c8ded68e8c54603ab9c8084ef6d9eb4e92c75b078539e2ae786ebab6dab73a09e0aa9ac575bcefb29e930ae656e58bcb513f7e3c17e079dce4f05b5dbc18c2a872b22509740ebe6a3903e00ad1abc55076441862643f93606e3dc35e8d9f2caef3ee6be14d513b2e062b21d0061de3bd56881713a1a5c17f5ace05e1ec09da53f99442df175a49bd154aa96e4949decd52fed79ccf7ccbce32941419c314e374e4a396ac553e17b5340336a1a25c22f9e42a243ba5404450b650acfc826a6e432971ace776e15719515e1634ceb9a4a35061b668c74998d3dfb5827f6238ec015377e6f9c94f38108768cf6e5c8b132e0303fb5a200368f845ad9d46343035a6ff94031df8d8309415bb3f6cd5ede9c135fdabcc030599858d803c0f85be7661c88984d88faa3d26fb0e9aac0056a53f1b5d0baed713c853c4a2726869a0a124a8a5bbc0fc0ef80c8ae4cb53636aa02503b86a1eb9836fcc259823e2692d921d88e1ffc1e6cb2bde43939ceb3f32a611686f539f8f7c9f0bf00381f743607d40960f06d347d1cd8ac8a51969c25e37150efdf7aa4c2037a2fd0516fb444525ab157a0ed0a7412b2fa69b217fe397263153782c0f64351fbdf2678fa0dc8569912dcd8e3ccad38f34f23bbbce14c6a26ac24911b308b82c7e43062d180baeac4ba7153858365c72c63dcf5f6a5b08070b730adb017aeae925b7d0439979e2679f45ed2f25a7edcfd2fb77a8794630285ccb0a071f5cce410b46dbf9750b0354aae8b65574501cc69efb5b6a43444074fee116641bb29da56c2b4a7f456991fc92b2\",\"debug\":0,\"seedipaddr\":\"78.47.196.146\"}" |
|||
|
@ -0,0 +1 @@ |
|||
curl --url "http://127.0.0.1:7776" --data "{\"conf\":\"COQUI.conf\",\"path\":\"${HOME#"/"}/.komodo/COQUI\",\"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\":\"COQUI\",\"name\":\"COQUI\",\"hasheaders\":1,\"useaddmultisig\":0,\"netmagic\":\"fa05f107\",\"p2p\":12455,\"rpc\":12456,\"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,4 +1,4 @@ |
|||
#!/bin/bash |
|||
|
|||
curl --url "http://127.0.0.1:7776" --data "{\"RELAY\":1,\"VALIDATE\":0,\"prefetchlag\":-1,\"poll\":10,\"active\":1,\"agent\":\"iguana\",\"method\":\"addcoin\",\"startpend\":68,\"endpend\":68,\"services\":129,\"maxpeers\":256,\"newcoin\":\"LTC\",\"name\":\"Litecoin\",\"hasheaders\":1,\"useaddmultisig\":0,\"netmagic\":\"fbc0b6db\",\"p2p\":9333,\"rpc\":9332,\"pubval\":48,\"p2shval\":5,\"wifval\":176,\"txfee_satoshis\":\"100000\",\"isPoS\":0,\"minoutput\":10000,\"minconfirms\":2,\"genesishash\":\"12a765e31ffd4059bada1e25190f6e98c99d9714d334efa41a195a7e7e04bfe2\",\"genesis\":{\"version\":1,\"timestamp\":1317972665,\"nBits\":\"1e0ffff0\",\"nonce\":2084524493,\"merkle_root\":\"97ddfbbae6be97fd6cdf3e7ca13232a3afff2353e29badfab7f73011edd4ced9\"},\"alertpubkey\":\"040184710fa689ad5023690c80f3a49c8f13f8d45b8c857fbcbc8bc4a8e4d3eb4b10f4d4604fa08dce601aaf0f470216fe1b51850b4acf21b179c45070ac7b03a9\",\"protover\":70002}" |
|||
curl --url "http://127.0.0.1:7778" --data "{\"RELAY\":1,\"VALIDATE\":0,\"prefetchlag\":-1,\"poll\":10,\"active\":1,\"agent\":\"iguana\",\"method\":\"addcoin\",\"startpend\":68,\"endpend\":68,\"services\":129,\"maxpeers\":256,\"newcoin\":\"LTC\",\"name\":\"Litecoin\",\"hasheaders\":1,\"useaddmultisig\":0,\"netmagic\":\"fbc0b6db\",\"p2p\":9333,\"rpc\":9332,\"pubval\":48,\"p2shval\":5,\"wifval\":176,\"txfee_satoshis\":\"100000\",\"isPoS\":0,\"minoutput\":10000,\"minconfirms\":2,\"genesishash\":\"12a765e31ffd4059bada1e25190f6e98c99d9714d334efa41a195a7e7e04bfe2\",\"genesis\":{\"version\":1,\"timestamp\":1317972665,\"nBits\":\"1e0ffff0\",\"nonce\":2084524493,\"merkle_root\":\"97ddfbbae6be97fd6cdf3e7ca13232a3afff2353e29badfab7f73011edd4ced9\"},\"alertpubkey\":\"040184710fa689ad5023690c80f3a49c8f13f8d45b8c857fbcbc8bc4a8e4d3eb4b10f4d4604fa08dce601aaf0f470216fe1b51850b4acf21b179c45070ac7b03a9\",\"protover\":70002}" |
|||
|
|||
|
@ -1,3 +1,3 @@ |
|||
./komodod -ac_name=REVS -ac_supply=1300000 -addnode=78.47.196.146 & |
|||
~/komodo/src/komodod -ac_name=REVS -ac_supply=1300000 -addnode=78.47.196.146 & |
|||
curl --url "http://127.0.0.1:7778" --data "{\"conf\":\"REVS.conf\",\"path\":\"${HOME#"/"}/.komodo/REVS\",\"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\":\"REVS\",\"name\":\"REVS\",\"hasheaders\":1,\"useaddmultisig\":0,\"netmagic\":\"905c3498\",\"p2p\":10195,\"rpc\":10196,\"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,349 @@ |
|||
|
|||
/******************************************************************************
|
|||
* 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_forwarding.c
|
|||
// marketmaker
|
|||
//
|
|||
|
|||
struct LP_forwardinfo |
|||
{ |
|||
UT_hash_handle hh; |
|||
bits256 pubkey; |
|||
char pushaddr[64]; |
|||
int32_t pushsock; |
|||
uint32_t lasttime,hello; |
|||
} *LP_forwardinfos; |
|||
#define LP_KEEPALIVE (3600 * 24) |
|||
|
|||
struct LP_forwardinfo *LP_forwardfind(bits256 pubkey) |
|||
{ |
|||
struct LP_forwardinfo *ptr=0; |
|||
portable_mutex_lock(&LP_forwardmutex); |
|||
HASH_FIND(hh,LP_forwardinfos,&pubkey,sizeof(pubkey),ptr); |
|||
portable_mutex_unlock(&LP_forwardmutex); |
|||
if ( ptr != 0 && ptr->lasttime > time(NULL)-LP_KEEPALIVE ) |
|||
return(ptr); |
|||
else return(0); |
|||
} |
|||
|
|||
char *LP_lookup(bits256 pubkey) |
|||
{ |
|||
if ( bits256_nonz(pubkey) == 0 ) |
|||
return(clonestr("{\"error\":\"illegal pubkey\"}")); |
|||
if ( LP_forwardfind(pubkey) != 0 ) |
|||
return(clonestr("{\"result\":\"success\",\"forwarding\":1}")); |
|||
else return(clonestr("{\"error\":\"notfound\"}")); |
|||
} |
|||
|
|||
int32_t LP_hello(struct LP_forwardinfo *ptr) |
|||
{ |
|||
int32_t i,n=10; char msg[512]; struct nn_pollfd pfd; |
|||
if ( bits256_cmp(ptr->pubkey,LP_mypubkey) != 0 ) |
|||
{ |
|||
pfd.fd = ptr->pushsock; |
|||
pfd.events = NN_POLLOUT; |
|||
for (i=0; i<n; i++) |
|||
{ |
|||
if ( nn_poll(&pfd,1,1) > 0 ) |
|||
{ |
|||
sprintf(msg,"{\"method\":\"hello\",\"from\":\"%s\"}",LP_mypeer != 0 ? LP_mypeer->ipaddr : ""); |
|||
//printf("HELLO sent.%d bytes to %s on i.%d\n",LP_send(ptr->pushsock,msg,0),ptr->pushaddr,i);
|
|||
ptr->hello = (uint32_t)time(NULL); |
|||
return(i); |
|||
} |
|||
} |
|||
//printf("%d iterations on nn_poll and %s pushsock still not ready\n",i,ptr->pushaddr);
|
|||
return(-1); |
|||
} |
|||
return(0); |
|||
} |
|||
|
|||
int32_t LP_hellos() |
|||
{ |
|||
struct LP_forwardinfo *ptr,*tmp; int32_t nonz = 0; |
|||
HASH_ITER(hh,LP_forwardinfos,ptr,tmp) |
|||
{ |
|||
if ( ptr->hello == 0 && LP_hello(ptr) >= 0 ) |
|||
nonz++; |
|||
} |
|||
return(nonz); |
|||
} |
|||
|
|||
int32_t LP_pushsock_create(struct LP_forwardinfo *ptr,char *pushaddr) |
|||
{ |
|||
int32_t pushsock,timeout; |
|||
if ( (pushsock= nn_socket(AF_SP,LP_COMMAND_SENDSOCK)) < 0 ) |
|||
{ |
|||
printf("LP_pushsock_create couldnt allocate socket for %s\n",pushaddr); |
|||
return(-1); |
|||
} |
|||
else if ( nn_connect(pushsock,pushaddr) < 0 ) |
|||
{ |
|||
nn_close(pushsock); |
|||
printf("LP_pushsock_create couldnt connect to %s\n",pushaddr); |
|||
return(-1); |
|||
} |
|||
timeout = 1; |
|||
nn_setsockopt(pushsock,NN_SOL_SOCKET,NN_SNDTIMEO,&timeout,sizeof(timeout)); |
|||
nn_setsockopt(pushsock,NN_SOL_SOCKET,NN_RCVTIMEO,&timeout,sizeof(timeout)); |
|||
if ( ptr != 0 ) |
|||
LP_hello(ptr); |
|||
return(pushsock); |
|||
} |
|||
|
|||
char *LP_register(bits256 pubkey,char *ipaddr,uint16_t port) |
|||
{ |
|||
struct LP_forwardinfo *ptr=0; int32_t pushsock; char pushaddr[64]; |
|||
if ( ipaddr == 0 || ipaddr[0] == 0 || is_ipaddr(ipaddr) == 0 || bits256_nonz(pubkey) == 0 ) |
|||
return(clonestr("{\"error\":\"illegal ipaddr or null pubkey\"}")); |
|||
nanomsg_transportname(0,pushaddr,ipaddr,port); |
|||
char str[65]; printf("register.(%s) %s\n",pushaddr,bits256_str(str,pubkey)); |
|||
if ( (ptr= LP_forwardfind(pubkey)) != 0 ) |
|||
{ |
|||
ptr->lasttime = (uint32_t)time(NULL); |
|||
if ( ptr->pushsock >= 0 ) |
|||
{ |
|||
if ( strcmp(pushaddr,ptr->pushaddr) != 0 ) |
|||
{ |
|||
nn_close(ptr->pushsock); |
|||
if ( LP_psockmark(ptr->pushaddr) < 0 ) |
|||
{ |
|||
//printf("cant mark (%s)\n",ptr->pushaddr);
|
|||
} |
|||
char str[65]; printf("%u recreate pushsock for %s <- %s\n",(uint32_t)time(NULL),pushaddr,bits256_str(str,pubkey)); |
|||
strcpy(ptr->pushaddr,pushaddr); |
|||
if ( (ptr->pushsock= LP_pushsock_create(ptr,pushaddr)) < 0 ) |
|||
return(clonestr("{\"error\":\"couldnt recreate pushsock\",\"registered\":0}")); |
|||
} //else printf("no need to create identical endpoint\n");
|
|||
} |
|||
return(clonestr("{\"error\":\"already registered\",\"registered\":1}")); |
|||
} |
|||
else if ( (pushsock= LP_pushsock_create(0,pushaddr)) < 0 ) |
|||
return(clonestr("{\"error\":\"couldnt create pushsock\"}")); |
|||
else |
|||
{ |
|||
ptr = calloc(1,sizeof(*ptr)); |
|||
ptr->pubkey = pubkey; |
|||
strcpy(ptr->pushaddr,pushaddr); |
|||
ptr->pushsock = pushsock; |
|||
ptr->lasttime = (uint32_t)time(NULL); |
|||
portable_mutex_lock(&LP_forwardmutex); |
|||
HASH_ADD_KEYPTR(hh,LP_forwardinfos,&ptr->pubkey,sizeof(ptr->pubkey),ptr); |
|||
portable_mutex_unlock(&LP_forwardmutex); |
|||
char str[65]; printf("registered (%s) -> (%s) pushsock.%d\n",bits256_str(str,pubkey),pushaddr,ptr->pushsock); |
|||
LP_hello(ptr); |
|||
return(LP_lookup(pubkey)); |
|||
} |
|||
} |
|||
|
|||
int32_t LP_forwarding_register(bits256 pubkey,char *publicaddr,uint16_t publicport,int32_t max) |
|||
{ |
|||
char *retstr,ipaddr[64]; cJSON *retjson; struct LP_peerinfo *peer,*tmp; int32_t j,n=0,retval = -1; |
|||
if ( publicaddr == 0 || publicaddr[0] == 0 || bits256_nonz(pubkey) == 0 ) |
|||
{ |
|||
char str[65]; printf("LP_forwarding_register illegal publicaddr.(%s):%u or null pubkey (%s)\n",publicaddr,publicport,bits256_str(str,pubkey)); |
|||
return(0); |
|||
} |
|||
for (j=0; publicaddr[j]!=0; j++) |
|||
if ( publicaddr[j] >= '0' && publicaddr[j] <= '9' ) |
|||
break; |
|||
parse_ipaddr(ipaddr,publicaddr+j); |
|||
HASH_ITER(hh,LP_peerinfos,peer,tmp) |
|||
{ |
|||
//printf("register.(%s) %s %u with (%s)\n",publicaddr,ipaddr,publicport,peer->ipaddr);
|
|||
if ( (retstr= issue_LP_register(peer->ipaddr,peer->port,pubkey,ipaddr,publicport)) != 0 ) |
|||
{ |
|||
//printf("[%s] LP_register.(%s) returned.(%s)\n",publicaddr,peer->ipaddr,retstr);
|
|||
if ( (retjson= cJSON_Parse(retstr)) != 0 ) |
|||
{ |
|||
if ( jint(retjson,"registered") != 0 && ++n >= max ) |
|||
retval = 0; |
|||
free_json(retjson); |
|||
} |
|||
free(retstr); |
|||
} else printf("timeout registering with %s errs.%d good.%d\n",peer->ipaddr,peer->errors,peer->good); |
|||
if ( retval == 0 ) |
|||
break; |
|||
} |
|||
return(n); |
|||
} |
|||
|
|||
char *LP_registerall(int32_t numnodes) |
|||
{ |
|||
int32_t i,maxnodes,n=0; cJSON *retjson; |
|||
if ( numnodes < sizeof(default_LPnodes)/sizeof(*default_LPnodes) ) |
|||
numnodes = (int32_t)(sizeof(default_LPnodes)/sizeof(*default_LPnodes)); |
|||
if ( (maxnodes= LP_numpeers()) < numnodes ) |
|||
numnodes = maxnodes; |
|||
for (i=0; i<numnodes; i++) |
|||
if ( (n= LP_forwarding_register(LP_mypubkey,LP_publicaddr,LP_publicport,numnodes)) >= numnodes ) |
|||
break; |
|||
retjson = cJSON_CreateObject(); |
|||
if ( i == numnodes ) |
|||
jaddstr(retjson,"error","not enough nodes"); |
|||
jaddnum(retjson,"numnodes",numnodes); |
|||
jaddnum(retjson,"registered",n); |
|||
jaddnum(retjson,"iters",i); |
|||
return(jprint(retjson,1)); |
|||
} |
|||
|
|||
cJSON *LP_dereference(cJSON *argjson,char *excludemethod) |
|||
{ |
|||
cJSON *reqjson = 0; |
|||
if ( jstr(argjson,"method2") != 0 && strncmp(excludemethod,jstr(argjson,"method2"),strlen(excludemethod)) != 0 ) |
|||
{ |
|||
reqjson = jduplicate(argjson); |
|||
jdelete(reqjson,"method"); |
|||
jaddstr(reqjson,"method",jstr(argjson,"method2")); |
|||
} |
|||
return(reqjson); |
|||
} |
|||
|
|||
char *LP_forwardhex(void *ctx,int32_t pubsock,bits256 pubkey,char *hexstr) |
|||
{ |
|||
struct LP_forwardinfo *ptr=0; uint8_t *data; int32_t datalen=0,sentbytes=0; char *msg,*retstr=0; cJSON *retjson=0,*argjson=0,*reqjson=0; |
|||
if ( hexstr == 0 || hexstr[0] == 0 ) |
|||
return(clonestr("{\"error\":\"nohex\"}")); |
|||
datalen = (int32_t)strlen(hexstr) >> 1; |
|||
data = malloc(datalen); |
|||
decode_hex(data,datalen,hexstr); |
|||
if ( (argjson= cJSON_Parse((char *)data)) != 0 ) |
|||
reqjson = LP_dereference(argjson,"forward"); |
|||
if ( bits256_nonz(pubkey) == 0 || bits256_cmp(pubkey,LP_mypubkey) == 0 ) |
|||
{ |
|||
if ( reqjson != 0 ) |
|||
{ |
|||
retstr = LP_command_process(ctx,LP_mypeer != 0 ? LP_mypeer->ipaddr : "127.0.0.1",LP_mypubsock,reqjson,0,0,LP_profitratio - 1.); |
|||
printf("LP_forwardhex.(%s) -> (%s)\n",jprint(reqjson,0),retstr!=0?retstr:""); |
|||
if ( pubsock >= 0 ) |
|||
{ |
|||
msg = jprint(reqjson,0); |
|||
LP_send(pubsock,msg,(int32_t)strlen(msg)+1,0); |
|||
} |
|||
} else printf("LP_forwardhex couldnt parse (%s)\n",(char *)data); |
|||
} |
|||
else if ( (ptr= LP_forwardfind(pubkey)) != 0 ) |
|||
{ |
|||
if ( ptr->pushsock >= 0 )//&& ptr->hello != 0 )
|
|||
{ |
|||
printf("%s forwardhex.(%s)\n",ptr->pushaddr,(char *)data); |
|||
sentbytes = LP_send(ptr->pushsock,(char *)data,datalen,0); |
|||
} |
|||
retjson = cJSON_CreateObject(); |
|||
if ( sentbytes == datalen ) |
|||
{ |
|||
jaddstr(retjson,"result","success"); |
|||
jaddnum(retjson,"forwarded",sentbytes); |
|||
retstr = jprint(retjson,1); |
|||
} |
|||
else |
|||
{ |
|||
jaddstr(retjson,"error","send error"); |
|||
jaddnum(retjson,"sentbytes",sentbytes); |
|||
jaddnum(retjson,"datalen",datalen); |
|||
jaddnum(retjson,"hello",ptr->hello); |
|||
retstr = jprint(retjson,1); |
|||
} |
|||
} |
|||
else |
|||
{ |
|||
char str[65]; printf("couldnt find %s to forward to\n",bits256_str(str,pubkey)); |
|||
if ( pubsock >= 0 ) |
|||
{ |
|||
msg = jprint(reqjson,0); |
|||
LP_send(pubsock,msg,(int32_t)strlen(msg)+1,1); |
|||
} |
|||
retstr = clonestr("{\"error\":\"notfound\"}"); |
|||
} |
|||
free(data); |
|||
if ( reqjson != 0 ) |
|||
free_json(reqjson); |
|||
if ( argjson != 0 ) |
|||
free_json(argjson); |
|||
return(retstr); |
|||
} |
|||
|
|||
int32_t LP_forward(void *ctx,char *myipaddr,int32_t pubsock,double profitmargin,bits256 pubkey,char *jsonstr,int32_t freeflag) |
|||
{ |
|||
struct LP_forwardinfo *ptr; struct LP_peerinfo *peer,*tmp; char *msg,*hexstr,*retstr; int32_t len,retval = -1; cJSON *retjson,*reqjson,*argjson; |
|||
if ( jsonstr == 0 || jsonstr[0] == 0 ) |
|||
return(-1); |
|||
if ( bits256_nonz(pubkey) != 0 ) |
|||
{ |
|||
if ( bits256_cmp(pubkey,LP_mypubkey) == 0 ) |
|||
{ |
|||
printf("GOT FORWARDED.(%s)\n",myipaddr); |
|||
if ( (argjson= cJSON_Parse(jsonstr)) != 0 ) |
|||
{ |
|||
if ( (retstr= LP_command_process(ctx,myipaddr,pubsock,argjson,0,0,profitmargin)) != 0 ) |
|||
free(retstr); |
|||
free_json(argjson); |
|||
} |
|||
return(1); |
|||
} |
|||
else if ( IAMLP != 0 && (ptr= LP_forwardfind(pubkey)) != 0 && ptr->pushsock >= 0 && ptr->lasttime > time(NULL)-LP_KEEPALIVE ) |
|||
{ |
|||
printf("GOT FORWARDED.(%s) -> pushsock.%d\n",jsonstr,ptr->pushsock); |
|||
len = (int32_t)strlen(jsonstr); |
|||
if ( LP_send(ptr->pushsock,jsonstr,(int32_t)strlen(jsonstr)+1,0) == len+1 ) |
|||
return(1); |
|||
} |
|||
} |
|||
HASH_ITER(hh,LP_peerinfos,peer,tmp) |
|||
{ |
|||
if ( bits256_nonz(pubkey) != 0 ) |
|||
{ |
|||
if ( (retstr= issue_LP_lookup(peer->ipaddr,peer->port,pubkey)) != 0 ) |
|||
{ |
|||
if ( (retjson= cJSON_Parse(retstr)) != 0 ) |
|||
{ |
|||
if ( jint(retjson,"forwarding") != 0 && peer->pushsock >= 0 ) |
|||
retval = 0; |
|||
free_json(retjson); |
|||
} |
|||
free(retstr); |
|||
} |
|||
} else retval = 0; |
|||
if ( retval >= 0 && peer->pushsock >= 0 ) |
|||
{ |
|||
printf("found LPnode.(%s) forward.(%s)\n",peer->ipaddr,jsonstr); |
|||
len = (int32_t)strlen(jsonstr) + 1; |
|||
hexstr = malloc(len*2 + 1); |
|||
init_hexbytes_noT(hexstr,(uint8_t *)jsonstr,len); |
|||
if ( freeflag != 0 ) |
|||
free(jsonstr); |
|||
reqjson = cJSON_CreateObject(); |
|||
jaddstr(reqjson,"method","forwardhex"); |
|||
jaddstr(reqjson,"hex",hexstr); |
|||
jaddbits256(reqjson,"pubkey",pubkey); |
|||
free(hexstr); |
|||
msg = jprint(reqjson,1); |
|||
return(LP_send(peer->pushsock,msg,(int32_t)strlen(msg)+1,1)); |
|||
} else retval = -1; |
|||
} |
|||
if ( freeflag != 0 ) |
|||
free(jsonstr); |
|||
return(-1); |
|||
} |
|||
|
|||
|
|||
char *LP_broadcasted(cJSON *argjson) |
|||
{ |
|||
printf("RECV BROADCAST.(%s)\n",jprint(argjson,0)); |
|||
return(clonestr("{\"result\":\"need to update broadcast messages\"}")); |
|||
} |
|||
|
|||
|
@ -0,0 +1,690 @@ |
|||
|
|||
/******************************************************************************
|
|||
* 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_ordermatch.c
|
|||
// marketmaker
|
|||
//
|
|||
|
|||
|
|||
struct basilisk_request *LP_requestinit(struct basilisk_request *rp,bits256 srchash,bits256 desthash,char *src,uint64_t srcsatoshis,char *dest,uint64_t destsatoshis,uint32_t timestamp,uint32_t quotetime,int32_t DEXselector) |
|||
{ |
|||
struct basilisk_request R; |
|||
memset(rp,0,sizeof(*rp)); |
|||
rp->srchash = srchash; |
|||
rp->srcamount = srcsatoshis; |
|||
rp->timestamp = timestamp; |
|||
rp->DEXselector = DEXselector; |
|||
safecopy(rp->src,src,sizeof(rp->src)); |
|||
safecopy(rp->dest,dest,sizeof(rp->dest)); |
|||
R = *rp; |
|||
rp->requestid = basilisk_requestid(rp); |
|||
rp->quotetime = quotetime; |
|||
rp->desthash = desthash; |
|||
rp->destamount = destsatoshis; |
|||
rp->quoteid = basilisk_quoteid(rp); |
|||
printf("r.%u %u, q.%u %u: %s %.8f -> %s %.8f\n",rp->timestamp,rp->requestid,rp->quotetime,rp->quoteid,rp->src,dstr(rp->srcamount),rp->dest,dstr(rp->destamount)); |
|||
return(rp); |
|||
} |
|||
|
|||
cJSON *LP_quotejson(struct LP_quoteinfo *qp) |
|||
{ |
|||
double price; cJSON *retjson = cJSON_CreateObject(); |
|||
jaddstr(retjson,"base",qp->srccoin); |
|||
jaddstr(retjson,"rel",qp->destcoin); |
|||
if ( qp->coinaddr[0] != 0 ) |
|||
jaddstr(retjson,"address",qp->coinaddr); |
|||
if ( qp->timestamp != 0 ) |
|||
jaddnum(retjson,"timestamp",qp->timestamp); |
|||
if ( bits256_nonz(qp->txid) != 0 ) |
|||
{ |
|||
jaddbits256(retjson,"txid",qp->txid); |
|||
jaddnum(retjson,"vout",qp->vout); |
|||
} |
|||
if ( bits256_nonz(qp->srchash) != 0 ) |
|||
jaddbits256(retjson,"srchash",qp->srchash); |
|||
if ( qp->txfee != 0 ) |
|||
jadd64bits(retjson,"txfee",qp->txfee); |
|||
if ( qp->quotetime != 0 ) |
|||
jaddnum(retjson,"quotetime",qp->quotetime); |
|||
if ( qp->satoshis != 0 ) |
|||
jadd64bits(retjson,"satoshis",qp->satoshis); |
|||
if ( bits256_nonz(qp->desthash) != 0 ) |
|||
jaddbits256(retjson,"desthash",qp->desthash); |
|||
if ( bits256_nonz(qp->txid2) != 0 ) |
|||
{ |
|||
jaddbits256(retjson,"txid2",qp->txid2); |
|||
jaddnum(retjson,"vout2",qp->vout2); |
|||
} |
|||
if ( bits256_nonz(qp->desttxid) != 0 ) |
|||
{ |
|||
if ( qp->destaddr[0] != 0 ) |
|||
jaddstr(retjson,"destaddr",qp->destaddr); |
|||
jaddbits256(retjson,"desttxid",qp->desttxid); |
|||
jaddnum(retjson,"destvout",qp->destvout); |
|||
} |
|||
if ( bits256_nonz(qp->feetxid) != 0 ) |
|||
{ |
|||
jaddbits256(retjson,"feetxid",qp->feetxid); |
|||
jaddnum(retjson,"feevout",qp->feevout); |
|||
} |
|||
if ( qp->desttxfee != 0 ) |
|||
jadd64bits(retjson,"desttxfee",qp->desttxfee); |
|||
if ( qp->destsatoshis != 0 ) |
|||
{ |
|||
jadd64bits(retjson,"destsatoshis",qp->destsatoshis); |
|||
if ( qp->satoshis != 0 ) |
|||
{ |
|||
price = (double)qp->destsatoshis / qp->satoshis; |
|||
jaddnum(retjson,"price",price); |
|||
} |
|||
} |
|||
return(retjson); |
|||
} |
|||
|
|||
int32_t LP_quoteparse(struct LP_quoteinfo *qp,cJSON *argjson) |
|||
{ |
|||
safecopy(qp->srccoin,jstr(argjson,"base"),sizeof(qp->srccoin)); |
|||
safecopy(qp->coinaddr,jstr(argjson,"address"),sizeof(qp->coinaddr)); |
|||
safecopy(qp->destcoin,jstr(argjson,"rel"),sizeof(qp->destcoin)); |
|||
safecopy(qp->destaddr,jstr(argjson,"destaddr"),sizeof(qp->destaddr)); |
|||
qp->timestamp = juint(argjson,"timestamp"); |
|||
qp->quotetime = juint(argjson,"quotetime"); |
|||
qp->txid = jbits256(argjson,"txid"); |
|||
qp->txid2 = jbits256(argjson,"txid2"); |
|||
qp->vout = jint(argjson,"vout"); |
|||
qp->vout2 = jint(argjson,"vout2"); |
|||
qp->feevout = jint(argjson,"feevout"); |
|||
qp->srchash = jbits256(argjson,"srchash"); |
|||
qp->desttxid = jbits256(argjson,"desttxid"); |
|||
qp->feetxid = jbits256(argjson,"feetxid"); |
|||
qp->destvout = jint(argjson,"destvout"); |
|||
qp->desthash = jbits256(argjson,"desthash"); |
|||
qp->satoshis = j64bits(argjson,"satoshis"); |
|||
qp->destsatoshis = j64bits(argjson,"destsatoshis"); |
|||
qp->txfee = j64bits(argjson,"txfee"); |
|||
qp->desttxfee = j64bits(argjson,"desttxfee"); |
|||
return(0); |
|||
} |
|||
|
|||
int32_t LP_quoteinfoinit(struct LP_quoteinfo *qp,struct LP_utxoinfo *utxo,char *destcoin,double price,uint64_t destsatoshis) |
|||
{ |
|||
memset(qp,0,sizeof(*qp)); |
|||
if ( qp->timestamp == 0 ) |
|||
qp->timestamp = (uint32_t)time(NULL); |
|||
safecopy(qp->destcoin,destcoin,sizeof(qp->destcoin)); |
|||
if ( (qp->txfee= LP_getestimatedrate(utxo->coin)*LP_AVETXSIZE) < LP_MIN_TXFEE ) |
|||
qp->txfee = LP_MIN_TXFEE; |
|||
qp->satoshis = destsatoshis / price + 0.49; |
|||
if ( utxo->iambob == 0 || qp->txfee >= qp->satoshis || qp->txfee >= utxo->deposit.value || utxo->deposit.value < LP_DEPOSITSATOSHIS(qp->satoshis) ) |
|||
{ |
|||
printf("quoteinit error.(%d %d %d %d) %.8f vs %.8f\n",utxo->iambob == 0,qp->txfee >= qp->satoshis,qp->txfee >= utxo->deposit.value,utxo->deposit.value < LP_DEPOSITSATOSHIS(qp->satoshis),dstr(utxo->deposit.value),dstr(LP_DEPOSITSATOSHIS(qp->satoshis))); |
|||
return(-1); |
|||
} |
|||
qp->txid = utxo->payment.txid; |
|||
qp->vout = utxo->payment.vout; |
|||
qp->txid2 = utxo->deposit.txid; |
|||
qp->vout2 = utxo->deposit.vout; |
|||
qp->destsatoshis = destsatoshis; |
|||
if ( (qp->desttxfee= LP_getestimatedrate(qp->destcoin) * LP_AVETXSIZE) < LP_MIN_TXFEE ) |
|||
qp->desttxfee = LP_MIN_TXFEE; |
|||
if ( qp->desttxfee >= qp->destsatoshis ) |
|||
{ |
|||
printf("quoteinit desttxfee %.8f < %.8f destsatoshis\n",dstr(qp->desttxfee),dstr(qp->destsatoshis)); |
|||
return(-2); |
|||
} |
|||
safecopy(qp->srccoin,utxo->coin,sizeof(qp->srccoin)); |
|||
safecopy(qp->coinaddr,utxo->coinaddr,sizeof(qp->coinaddr)); |
|||
qp->srchash = utxo->pubkey; |
|||
return(0); |
|||
} |
|||
|
|||
int32_t LP_quotedestinfo(struct LP_quoteinfo *qp,bits256 desttxid,int32_t destvout,bits256 feetxid,int32_t feevout,bits256 desthash,char *destaddr) |
|||
{ |
|||
qp->desttxid = desttxid; |
|||
qp->destvout = destvout; |
|||
qp->desthash = desthash; |
|||
qp->feetxid = feetxid; |
|||
qp->feevout = feevout; |
|||
safecopy(qp->destaddr,destaddr,sizeof(qp->destaddr)); |
|||
return(0); |
|||
} |
|||
|
|||
char *LP_quotereceived(cJSON *argjson) |
|||
{ |
|||
struct LP_cacheinfo *ptr; double price; struct LP_quoteinfo Q; |
|||
LP_quoteparse(&Q,argjson); |
|||
price = (double)(Q.destsatoshis + Q.desttxfee) / (Q.satoshis + Q.txfee); |
|||
if ( (ptr= LP_cacheadd(Q.srccoin,Q.destcoin,Q.txid,Q.vout,price,&Q)) != 0 ) |
|||
{ |
|||
ptr->Q = Q; |
|||
printf(">>>>>>>>>> received quote %s/%s %.8f\n",Q.srccoin,Q.destcoin,price); |
|||
return(clonestr("{\"result\":\"updated\"}")); |
|||
} else return(clonestr("{\"error\":\"nullptr\"}")); |
|||
} |
|||
|
|||
char *LP_pricepings(void *ctx,char *myipaddr,int32_t pubsock,double profitmargin,char *base,char *rel,double price) |
|||
{ |
|||
bits256 zero; char *msg; cJSON *reqjson = cJSON_CreateObject(); |
|||
jaddbits256(reqjson,"pubkey",LP_mypubkey); |
|||
jaddstr(reqjson,"base",base); |
|||
jaddstr(reqjson,"rel",rel); |
|||
jaddnum(reqjson,"price",price); |
|||
if ( pubsock >= 0 ) |
|||
{ |
|||
jaddstr(reqjson,"method","postprice"); |
|||
//printf("%d pricepings.(%s)\n",pubsock,jprint(reqjson,0));
|
|||
msg = jprint(reqjson,1); |
|||
LP_send(pubsock,msg,(int32_t)strlen(msg)+1,1); |
|||
} |
|||
else |
|||
{ |
|||
jaddstr(reqjson,"method","forward"); |
|||
jaddstr(reqjson,"method2","postprice"); |
|||
memset(zero.bytes,0,sizeof(zero)); |
|||
LP_forward(ctx,myipaddr,pubsock,profitmargin,zero,jprint(reqjson,1),1); |
|||
} |
|||
return(clonestr("{\"result\":\"success\"}")); |
|||
} |
|||
|
|||
char *LP_postedprice(cJSON *argjson) |
|||
{ |
|||
bits256 pubkey; double price; char *base,*rel; |
|||
//printf("PRICE POSTED.(%s)\n",jprint(argjson,0));
|
|||
if ( (base= jstr(argjson,"base")) != 0 && (rel= jstr(argjson,"rel")) != 0 && (price= jdouble(argjson,"price")) > SMALLVAL ) |
|||
{ |
|||
pubkey = jbits256(argjson,"pubkey"); |
|||
if ( bits256_nonz(pubkey) != 0 ) |
|||
{ |
|||
LP_pricefeedupdate(pubkey,base,rel,price); |
|||
return(clonestr("{\"result\":\"success\"}")); |
|||
} |
|||
} |
|||
return(clonestr("{\"error\":\"missing fields in posted price\"}")); |
|||
} |
|||
|
|||
int32_t LP_quote_checkmempool(struct LP_quoteinfo *qp) |
|||
{ |
|||
int32_t selector,spendvini; bits256 spendtxid; |
|||
if ( (selector= LP_mempool_vinscan(&spendtxid,&spendvini,qp->srccoin,qp->txid,qp->vout,qp->txid2,qp->vout2)) >= 0 ) |
|||
{ |
|||
char str[65]; printf("LP_tradecommand selector.%d in mempool %s vini.%d",selector,bits256_str(str,spendtxid),spendvini); |
|||
return(-1); |
|||
} |
|||
if ( (selector= LP_mempool_vinscan(&spendtxid,&spendvini,qp->destcoin,qp->desttxid,qp->destvout,qp->feetxid,qp->feevout)) >= 0 ) |
|||
{ |
|||
char str[65]; printf("LP_tradecommand dest selector.%d in mempool %s vini.%d",selector,bits256_str(str,spendtxid),spendvini); |
|||
return(-1); |
|||
} |
|||
return(0); |
|||
} |
|||
|
|||
double LP_quote_validate(struct LP_utxoinfo **autxop,struct LP_utxoinfo **butxop,struct LP_quoteinfo *qp,int32_t iambob) |
|||
{ |
|||
double qprice; uint64_t srcvalue,srcvalue2,destvalue,destvalue2; |
|||
*autxop = *butxop = 0; |
|||
if ( LP_iseligible(&srcvalue,&srcvalue2,1,qp->srccoin,qp->txid,qp->vout,qp->satoshis,qp->txid2,qp->vout2,qp->srchash) == 0 ) |
|||
{ |
|||
printf("bob not eligible\n"); |
|||
return(-2); |
|||
} |
|||
if ( LP_iseligible(&destvalue,&destvalue2,0,qp->destcoin,qp->desttxid,qp->destvout,qp->destsatoshis,qp->feetxid,qp->feevout,qp->desthash) == 0 ) |
|||
{ |
|||
char str[65]; printf("alice not eligible (%.8f %.8f) %s/v%d\n",dstr(destvalue),dstr(destvalue2),bits256_str(str,qp->feetxid),qp->feevout); |
|||
return(-3); |
|||
} |
|||
if ( LP_quote_checkmempool(qp) < 0 ) |
|||
return(-4); |
|||
if ( (*butxop= LP_utxofind(1,qp->txid,qp->vout)) == 0 ) |
|||
return(-5); |
|||
if ( bits256_cmp((*butxop)->deposit.txid,qp->txid2) != 0 || (*butxop)->deposit.vout != qp->vout2 ) |
|||
return(-6); |
|||
if ( strcmp((*butxop)->coinaddr,qp->coinaddr) != 0 ) |
|||
return(-7); |
|||
if ( iambob == 0 ) |
|||
{ |
|||
if ( (*autxop= LP_utxofind(0,qp->desttxid,qp->destvout)) == 0 ) |
|||
return(-8); |
|||
if ( bits256_cmp((*autxop)->fee.txid,qp->feetxid) != 0 || (*autxop)->fee.vout != qp->feevout ) |
|||
return(-9); |
|||
if ( strcmp((*autxop)->coinaddr,qp->destaddr) != 0 ) |
|||
return(-10); |
|||
} |
|||
if ( destvalue < qp->desttxfee+qp->destsatoshis || srcvalue < qp->txfee+qp->satoshis ) |
|||
{ |
|||
printf("destvalue %.8f srcvalue %.8f, destsatoshis %.8f or satoshis %.8f is too small txfees %.8f %.8f?\n",dstr(destvalue),dstr(srcvalue),dstr(qp->destsatoshis),dstr(qp->satoshis),dstr(qp->desttxfee),dstr(qp->txfee)); |
|||
return(-11); |
|||
} |
|||
qprice = ((double)qp->destsatoshis / qp->satoshis); |
|||
if ( qp->satoshis < (srcvalue >> LP_MINVOL) ) |
|||
{ |
|||
printf("utxo payment %.8f is less than half covered by Q %.8f\n",dstr(srcvalue),dstr(qp->satoshis)); |
|||
return(-12); |
|||
} |
|||
if ( qp->destsatoshis < (destvalue >> LP_MINCLIENTVOL) ) |
|||
{ |
|||
printf("destsatoshis %.8f is less than half of value %.8f\n",dstr(qp->destsatoshis),dstr(destvalue)); |
|||
return(-13); |
|||
} |
|||
printf("qprice %.8f <- %.8f/%.8f txfees.(%.8f %.8f)\n",qprice,dstr(qp->destsatoshis),dstr(qp->satoshis),dstr(qp->txfee),dstr(qp->desttxfee)); |
|||
return(qprice); |
|||
} |
|||
|
|||
int32_t LP_arrayfind(cJSON *array,bits256 txid,int32_t vout) |
|||
{ |
|||
int32_t i,n = cJSON_GetArraySize(array); cJSON *item; |
|||
for (i=0; i<n; i++) |
|||
{ |
|||
item = jitem(array,i); |
|||
if ( vout == jint(item,"vout") && bits256_cmp(txid,jbits256(item,"txid")) == 0 ) |
|||
return(i); |
|||
} |
|||
return(-1); |
|||
} |
|||
|
|||
double LP_query(void *ctx,char *myipaddr,int32_t mypubsock,double profitmargin,char *method,struct LP_quoteinfo *qp) |
|||
{ |
|||
cJSON *reqjson; char *msg; int32_t i,flag = 0; double price = 0.; struct LP_utxoinfo *utxo; |
|||
if ( strcmp(method,"request") == 0 ) |
|||
{ |
|||
if ( (utxo= LP_utxofind(0,qp->desttxid,qp->destvout)) != 0 && LP_ismine(utxo) > 0 && LP_isavailable(utxo) > 0 ) |
|||
LP_unavailableset(utxo,qp->srchash); |
|||
else |
|||
{ |
|||
printf("couldnt find my txid to make request\n"); |
|||
return(0.); |
|||
} |
|||
} |
|||
reqjson = LP_quotejson(qp); |
|||
if ( bits256_nonz(qp->desthash) != 0 ) |
|||
flag = 1; |
|||
//printf("QUERY.(%s)\n",jprint(reqjson,0));
|
|||
if ( IAMLP != 0 ) |
|||
{ |
|||
jaddstr(reqjson,"method",method); |
|||
msg = jprint(reqjson,1); |
|||
LP_send(LP_mypubsock,msg,(int32_t)strlen(msg)+1,1); |
|||
} |
|||
else |
|||
{ |
|||
jaddstr(reqjson,"method2",method); |
|||
jaddstr(reqjson,"method","forward"); |
|||
jaddbits256(reqjson,"pubkey",qp->srchash); |
|||
LP_forward(ctx,myipaddr,mypubsock,profitmargin,qp->srchash,jprint(reqjson,1),1); |
|||
} |
|||
for (i=0; i<30; i++) |
|||
{ |
|||
if ( (price= LP_pricecache(qp,qp->srccoin,qp->destcoin,qp->txid,qp->vout)) > SMALLVAL ) |
|||
{ |
|||
if ( flag == 0 || bits256_nonz(qp->desthash) != 0 ) |
|||
{ |
|||
//printf("break out of loop.%d price %.8f\n",i,price);
|
|||
break; |
|||
} |
|||
} |
|||
usleep(100000); |
|||
} |
|||
return(price); |
|||
} |
|||
|
|||
int32_t LP_nanobind(void *ctx,char *pairstr) |
|||
{ |
|||
int32_t i,timeout,r,pairsock = -1; uint16_t mypullport; char bindaddr[128]; |
|||
if ( LP_canbind != 0 ) |
|||
{ |
|||
if ( (pairsock= nn_socket(AF_SP,NN_PAIR)) < 0 ) |
|||
printf("error creating utxo->pair\n"); |
|||
else |
|||
{ |
|||
for (i=0; i<10; i++) |
|||
{ |
|||
r = (10000 + (rand() % 50000)) & 0xffff; |
|||
if ( LP_fixed_pairport != 0 ) |
|||
r = LP_fixed_pairport; |
|||
nanomsg_transportname(0,pairstr,LP_myipaddr,r); |
|||
nanomsg_transportname(1,bindaddr,LP_myipaddr,r); |
|||
if ( nn_bind(pairsock,bindaddr) >= 0 ) |
|||
{ |
|||
timeout = 100; |
|||
nn_setsockopt(pairsock,NN_SOL_SOCKET,NN_SNDTIMEO,&timeout,sizeof(timeout)); |
|||
nn_setsockopt(pairsock,NN_SOL_SOCKET,NN_RCVTIMEO,&timeout,sizeof(timeout)); |
|||
printf("nanobind %s to %d\n",pairstr,pairsock); |
|||
return(pairsock); |
|||
} else printf("error binding to %s for %s\n",bindaddr,pairstr); |
|||
if ( LP_fixed_pairport != 0 ) |
|||
break; |
|||
} |
|||
} |
|||
} else pairsock = LP_initpublicaddr(ctx,&mypullport,pairstr,"127.0.0.1",0,1); |
|||
return(pairsock); |
|||
} |
|||
|
|||
int32_t LP_connectstartbob(void *ctx,int32_t pubsock,struct LP_utxoinfo *utxo,cJSON *argjson,char *myipaddr,char *base,char *rel,double profitmargin,double price,struct LP_quoteinfo *qp) |
|||
{ |
|||
char pairstr[512],*msg; cJSON *retjson; bits256 privkey; int32_t pair=-1,retval = -1,DEXselector = 0; struct basilisk_swap *swap; struct iguana_info *coin; |
|||
printf("LP_connectstartbob.(%s) with.(%s) %s\n",myipaddr,jprint(argjson,0),LP_myipaddr); |
|||
qp->quotetime = (uint32_t)time(NULL); |
|||
if ( (coin= LP_coinfind(utxo->coin)) == 0 ) |
|||
{ |
|||
printf("cant find coin.%s\n",utxo->coin); |
|||
return(-1); |
|||
} |
|||
privkey = LP_privkey(utxo->coinaddr,coin->taddr); |
|||
if ( bits256_nonz(privkey) != 0 && qp->quotetime >= qp->timestamp-3 && qp->quotetime <= utxo->T.swappending && bits256_cmp(LP_mypubkey,qp->srchash) == 0 ) |
|||
{ |
|||
if ( (pair= LP_nanobind(ctx,pairstr)) >= 0 ) |
|||
{ |
|||
LP_requestinit(&qp->R,qp->srchash,qp->desthash,base,qp->satoshis,rel,qp->destsatoshis,qp->timestamp,qp->quotetime,DEXselector); |
|||
swap = LP_swapinit(1,0,privkey,&qp->R,qp); |
|||
swap->N.pair = pair; |
|||
utxo->S.swap = swap; |
|||
swap->utxo = utxo; |
|||
if ( OS_thread_create(malloc(sizeof(pthread_t)),NULL,(void *)LP_bobloop,(void *)swap) == 0 ) |
|||
{ |
|||
retjson = LP_quotejson(qp); |
|||
jaddstr(retjson,"method","connected"); |
|||
jaddstr(retjson,"pair",pairstr); |
|||
jaddnum(retjson,"requestid",qp->R.requestid); |
|||
jaddnum(retjson,"quoteid",qp->R.quoteid); |
|||
char str[65]; printf("BOB pubsock.%d sends to (%s)\n",pubsock,bits256_str(str,utxo->S.otherpubkey)); |
|||
if ( pubsock >= 0 ) |
|||
{ |
|||
msg = jprint(retjson,0); |
|||
LP_send(pubsock,msg,(int32_t)strlen(msg)+1,1); |
|||
} |
|||
jdelete(retjson,"method"); |
|||
jaddstr(retjson,"method2","connected"); |
|||
jaddstr(retjson,"method","forward"); |
|||
LP_forward(ctx,myipaddr,pubsock,profitmargin,utxo->S.otherpubkey,jprint(retjson,1),1); |
|||
retval = 0; |
|||
} else printf("error launching swaploop\n"); |
|||
} else printf("couldnt bind to any port %s\n",pairstr); |
|||
} |
|||
else |
|||
{ |
|||
printf("dest %.8f vs required %.8f (%d %d %d %d %d)\n",dstr(qp->destsatoshis),dstr(price*(utxo->S.satoshis-qp->txfee)),bits256_nonz(privkey) != 0 ,qp->timestamp == utxo->T.swappending-LP_RESERVETIME,qp->quotetime >= qp->timestamp-3,qp->quotetime < utxo->T.swappending,bits256_cmp(LP_mypubkey,qp->srchash) == 0); |
|||
} |
|||
if ( retval < 0 ) |
|||
{ |
|||
if ( pair >= 0 ) |
|||
nn_close(pair); |
|||
LP_availableset(utxo); |
|||
} else LP_unavailableset(utxo,utxo->S.otherpubkey); |
|||
return(retval); |
|||
} |
|||
|
|||
char *LP_connectedalice(cJSON *argjson) // alice
|
|||
{ |
|||
cJSON *retjson; double bid,ask,price,qprice; int32_t timeout,pairsock = -1; char *pairstr; int32_t DEXselector = 0; struct LP_utxoinfo *autxo,*butxo; struct LP_quoteinfo Q; struct basilisk_swap *swap; struct iguana_info *coin; |
|||
if ( LP_quoteparse(&Q,argjson) < 0 ) |
|||
clonestr("{\"error\":\"cant parse quote\"}"); |
|||
if ( bits256_cmp(Q.desthash,LP_mypubkey) != 0 ) |
|||
return(clonestr("{\"result\",\"update stats\"}")); |
|||
printf("CONNECTED.(%s)\n",jprint(argjson,0)); |
|||
if ( (qprice= LP_quote_validate(&autxo,&butxo,&Q,0)) <= SMALLVAL ) |
|||
{ |
|||
LP_availableset(autxo); |
|||
printf("quote validate error %.0f\n",qprice); |
|||
return(clonestr("{\"error\":\"quote validation error\"}")); |
|||
} |
|||
if ( (price= LP_myprice(&bid,&ask,Q.destcoin,Q.srccoin)) <= SMALLVAL || ask <= SMALLVAL ) |
|||
{ |
|||
printf("this node has no price for %s/%s (%.8f %.8f)\n",Q.destcoin,Q.srccoin,bid,ask); |
|||
LP_availableset(autxo); |
|||
return(clonestr("{\"error\":\"no price set\"}")); |
|||
} |
|||
price = 1. / ask; |
|||
if ( qprice > price+0.00000001 ) |
|||
{ |
|||
printf("qprice %.8f too big vs %.8f\n",qprice,price); |
|||
LP_availableset(autxo); |
|||
return(clonestr("{\"error\":\"quote price too expensive\"}")); |
|||
} |
|||
if ( (coin= LP_coinfind(Q.destcoin)) == 0 ) |
|||
{ |
|||
return(clonestr("{\"error\":\"cant get alicecoin\"}")); |
|||
} |
|||
Q.privkey = LP_privkey(Q.destaddr,coin->taddr); |
|||
if ( bits256_nonz(Q.privkey) != 0 && Q.quotetime >= Q.timestamp-3 ) |
|||
{ |
|||
retjson = cJSON_CreateObject(); |
|||
if ( (pairstr= jstr(argjson,"pair")) == 0 || (pairsock= nn_socket(AF_SP,NN_PAIR)) < 0 ) |
|||
jaddstr(retjson,"error","couldnt create pairsock"); |
|||
else if ( nn_connect(pairsock,pairstr) >= 0 ) |
|||
{ |
|||
timeout = 100; |
|||
nn_setsockopt(pairsock,NN_SOL_SOCKET,NN_SNDTIMEO,&timeout,sizeof(timeout)); |
|||
nn_setsockopt(pairsock,NN_SOL_SOCKET,NN_RCVTIMEO,&timeout,sizeof(timeout)); |
|||
LP_requestinit(&Q.R,Q.srchash,Q.desthash,Q.srccoin,Q.satoshis,Q.destcoin,Q.destsatoshis,Q.timestamp,Q.quotetime,DEXselector); |
|||
swap = LP_swapinit(0,0,Q.privkey,&Q.R,&Q); |
|||
swap->N.pair = pairsock; |
|||
autxo->S.swap = swap; |
|||
swap->utxo = autxo; |
|||
printf("alice pairstr.(%s) pairsock.%d\n",pairstr,pairsock); |
|||
if ( OS_thread_create(malloc(sizeof(pthread_t)),NULL,(void *)LP_aliceloop,(void *)swap) == 0 ) |
|||
{ |
|||
jaddstr(retjson,"result","success"); |
|||
jadd(retjson,"trade",LP_quotejson(&Q)); |
|||
jaddnum(retjson,"requestid",Q.R.requestid); |
|||
jaddnum(retjson,"quoteid",Q.R.quoteid); |
|||
} else jaddstr(retjson,"error","couldnt aliceloop"); |
|||
} else printf("connect error %s\n",nn_strerror(nn_errno())); |
|||
printf("connected result.(%s)\n",jprint(retjson,0)); |
|||
if ( jobj(retjson,"error") != 0 ) |
|||
LP_availableset(autxo); |
|||
return(jprint(retjson,1)); |
|||
} |
|||
else |
|||
{ |
|||
LP_availableset(autxo); |
|||
printf("no privkey found\n"); |
|||
return(clonestr("{\"error\",\"no privkey\"}")); |
|||
} |
|||
} |
|||
|
|||
int32_t LP_tradecommand(void *ctx,char *myipaddr,int32_t pubsock,cJSON *argjson,uint8_t *data,int32_t datalen,double profitmargin) |
|||
{ |
|||
char *method,*msg; cJSON *retjson; double qprice,price,bid,ask; struct LP_utxoinfo *autxo,*butxo; int32_t retval = -1; struct LP_quoteinfo Q; |
|||
if ( (method= jstr(argjson,"method")) != 0 && (strcmp(method,"request") == 0 ||strcmp(method,"connect") == 0) ) |
|||
{ |
|||
//printf("TRADECOMMAND.(%s)\n",jprint(argjson,0));
|
|||
retval = 1; |
|||
if ( LP_quoteparse(&Q,argjson) == 0 && bits256_cmp(LP_mypubkey,Q.srchash) == 0 ) |
|||
{ |
|||
if ( (price= LP_myprice(&bid,&ask,Q.srccoin,Q.destcoin)) <= SMALLVAL || ask <= SMALLVAL ) |
|||
{ |
|||
printf("this node has no price for %s/%s\n",Q.srccoin,Q.destcoin); |
|||
return(-3); |
|||
} |
|||
price = ask; |
|||
if ( (qprice= LP_quote_validate(&autxo,&butxo,&Q,1)) <= SMALLVAL ) |
|||
{ |
|||
printf("quote validate error %.0f\n",qprice); |
|||
return(-4); |
|||
} |
|||
if ( qprice < price-0.00000001 ) |
|||
{ |
|||
printf("(%.8f %.8f) quote price %.8f too low vs %.8f for %s/%s\n",bid,ask,qprice,price,Q.srccoin,Q.destcoin); |
|||
return(-5); |
|||
} |
|||
if ( butxo->S.swap == 0 && time(NULL) > butxo->T.swappending ) |
|||
butxo->T.swappending = 0; |
|||
if ( strcmp(method,"request") == 0 ) // bob needs apayment + fee tx's
|
|||
{ |
|||
if ( LP_isavailable(butxo) > 0 ) |
|||
{ |
|||
butxo->T.swappending = Q.timestamp + LP_RESERVETIME; |
|||
retjson = LP_quotejson(&Q); |
|||
butxo->S.otherpubkey = jbits256(argjson,"desthash"); |
|||
LP_unavailableset(butxo,butxo->S.otherpubkey); |
|||
jaddnum(retjson,"quotetime",juint(argjson,"quotetime")); |
|||
jaddnum(retjson,"pending",butxo->T.swappending); |
|||
jaddbits256(retjson,"desthash",butxo->S.otherpubkey); |
|||
jaddbits256(retjson,"pubkey",butxo->S.otherpubkey); |
|||
jaddstr(retjson,"method","reserved"); |
|||
if ( pubsock >= 0 ) |
|||
{ |
|||
msg = jprint(retjson,0); |
|||
LP_send(pubsock,msg,(int32_t)strlen(msg)+1,1); |
|||
} |
|||
jdelete(retjson,"method"); |
|||
jaddstr(retjson,"method2","reserved"); |
|||
jaddstr(retjson,"method","forward"); |
|||
LP_forward(ctx,myipaddr,pubsock,profitmargin,butxo->S.otherpubkey,jprint(retjson,1),1); |
|||
butxo->T.lasttime = (uint32_t)time(NULL); |
|||
printf("set swappending.%u accept qprice %.8f, min %.8f\n",butxo->T.swappending,qprice,price); |
|||
} else printf("warning swappending.%u swap.%p\n",butxo->T.swappending,butxo->S.swap); |
|||
} |
|||
else if ( strcmp(method,"connect") == 0 ) // bob
|
|||
{ |
|||
retval = 4; |
|||
if ( butxo->T.swappending != 0 && butxo->S.swap == 0 ) |
|||
LP_connectstartbob(ctx,pubsock,butxo,argjson,myipaddr,Q.srccoin,Q.destcoin,profitmargin,qprice,&Q); |
|||
else printf("pend.%u swap %p when connect came in (%s)\n",butxo->T.swappending,butxo->S.swap,jprint(argjson,0)); |
|||
} |
|||
} |
|||
} |
|||
return(retval); |
|||
} |
|||
|
|||
char *LP_autotrade(void *ctx,char *myipaddr,int32_t mypubsock,double profitmargin,char *base,char *rel,double maxprice,double volume,int32_t timeout) |
|||
{ |
|||
int64_t satoshis,destsatoshis,desttxfee,txfee,bestdestsatoshis=0; bits256 txid,pubkey; char *obookstr,*retstr; cJSON *orderbook,*asks,*item,*bestitem=0; struct LP_utxoinfo *autxo,*butxo,*bestutxo = 0; int32_t i,vout,numasks,DEXselector=0; uint32_t expiration; double ordermatchprice,bestmetric,metric,bestprice=0.,vol,price; struct LP_quoteinfo Q; struct LP_pubkeyinfo *pubp; |
|||
if ( maxprice <= 0. || volume <= 0. || LP_priceinfofind(base) == 0 || LP_priceinfofind(rel) == 0 ) |
|||
return(clonestr("{\"error\":\"invalid parameter\"}")); |
|||
if ( (autxo= LP_utxo_bestfit(rel,SATOSHIDEN * volume)) == 0 ) |
|||
return(clonestr("{\"error\":\"cant find utxo that is big enough\"}")); |
|||
bestmetric = ordermatchprice = 0.; |
|||
if ( (desttxfee= LP_getestimatedrate(rel) * LP_AVETXSIZE) < LP_MIN_TXFEE ) |
|||
desttxfee = LP_MIN_TXFEE; |
|||
if ( (txfee= LP_getestimatedrate(base) * LP_AVETXSIZE) < LP_MIN_TXFEE ) |
|||
txfee = LP_MIN_TXFEE; |
|||
if ( timeout == 0 ) |
|||
timeout = LP_AUTOTRADE_TIMEOUT; |
|||
if ( (obookstr= LP_orderbook(base,rel)) != 0 ) |
|||
{ |
|||
if ( (orderbook= cJSON_Parse(obookstr)) != 0 ) |
|||
{ |
|||
if ( (asks= jarray(&numasks,orderbook,"asks")) != 0 ) |
|||
{ |
|||
for (i=0; i<numasks; i++) |
|||
{ |
|||
item = jitem(asks,i); |
|||
if ( (price= jdouble(item,"price")) > SMALLVAL && price <= maxprice ) |
|||
{ |
|||
price *= 1.0001; |
|||
if ( price > maxprice ) |
|||
price = maxprice; |
|||
pubkey = jbits256(item,"pubkey"); |
|||
if ( bits256_cmp(pubkey,LP_mypubkey) != 0 && (pubp= LP_pubkeyadd(pubkey)) != 0 && pubp->numerrors < LP_MAXPUBKEY_ERRORS ) |
|||
{ |
|||
if ( bestprice == 0. ) // assumes price ordered asks
|
|||
bestprice = price; |
|||
//printf("item.[%d] %s\n",i,jprint(item,0));
|
|||
txid = jbits256(item,"txid"); |
|||
vout = jint(item,"vout"); |
|||
vol = jdouble(item,"volume"); |
|||
metric = price / bestprice; |
|||
if ( (butxo= LP_utxofind(1,txid,vout)) != 0 && (long long)(vol*SATOSHIDEN) == butxo->S.satoshis && LP_isavailable(butxo) > 0 && LP_ismine(butxo) == 0 && butxo->T.bestflag == 0 ) |
|||
{ |
|||
destsatoshis = ((butxo->S.satoshis - txfee) * price); |
|||
if ( destsatoshis > autxo->payment.value-desttxfee-1 ) |
|||
destsatoshis = autxo->payment.value-desttxfee-1; |
|||
satoshis = (destsatoshis / price + 0.0000000049) - txfee; |
|||
if ( metric < 1.2 && destsatoshis > desttxfee && destsatoshis-desttxfee > (autxo->payment.value >> LP_MINCLIENTVOL) && satoshis-txfee > (butxo->S.satoshis >> LP_MINVOL) && satoshis <= butxo->payment.value-txfee ) |
|||
{ |
|||
printf("value %.8f price %.8f/%.8f best %.8f destsatoshis %.8f * metric %.8f -> (%f)\n",dstr(autxo->payment.value),price,bestprice,bestmetric,dstr(destsatoshis),metric,dstr(destsatoshis) * metric * metric * metric); |
|||
metric = dstr(destsatoshis) * metric * metric * metric; |
|||
if ( bestmetric == 0. || metric < bestmetric ) |
|||
{ |
|||
bestutxo = butxo; |
|||
ordermatchprice = price; |
|||
bestdestsatoshis = destsatoshis; |
|||
bestmetric = metric; |
|||
printf("set best!\n"); |
|||
} |
|||
} else printf("skip.(%d %d %d %d %d) metric %f destsatoshis %.8f value %.8f destvalue %.8f txfees %.8f %.8f sats %.8f\n",metric < 1.2,destsatoshis > desttxfee,destsatoshis-desttxfee > (autxo->payment.value >> LP_MINCLIENTVOL),satoshis-txfee > (butxo->S.satoshis >> LP_MINVOL),satoshis < butxo->payment.value-txfee,metric,dstr(destsatoshis),dstr(butxo->S.satoshis),dstr(autxo->payment.value),dstr(txfee),dstr(desttxfee),dstr(satoshis)); |
|||
} |
|||
else |
|||
{ |
|||
if ( butxo != 0 ) |
|||
printf("%llu %llu %d %d %d: ",(long long)(vol*SATOSHIDEN),(long long)butxo->S.satoshis,vol*SATOSHIDEN == butxo->S.satoshis,LP_isavailable(butxo) > 0,LP_ismine(butxo) == 0); |
|||
printf("cant find butxo.%p or value mismatch %.8f != %.8f\n",butxo,vol,butxo!=0?dstr(butxo->S.satoshis):0); |
|||
} |
|||
} |
|||
} else break; |
|||
} |
|||
} |
|||
free_json(orderbook); |
|||
} |
|||
free(obookstr); |
|||
} |
|||
if ( bestutxo == 0 || ordermatchprice == 0. || bestdestsatoshis == 0 ) |
|||
return(clonestr("{\"error\":\"cant find ordermatch utxo\"}")); |
|||
if ( LP_quoteinfoinit(&Q,bestutxo,rel,ordermatchprice,bestdestsatoshis) < 0 ) |
|||
return(clonestr("{\"error\":\"cant set ordermatch quote\"}")); |
|||
if ( LP_quotedestinfo(&Q,autxo->payment.txid,autxo->payment.vout,autxo->fee.txid,autxo->fee.vout,LP_mypubkey,autxo->coinaddr) < 0 ) |
|||
return(clonestr("{\"error\":\"cant set ordermatch quote info\"}")); |
|||
bestutxo->T.bestflag = (uint32_t)time(NULL); |
|||
if ( (retstr= LP_registerall(0)) != 0 ) |
|||
free(retstr); |
|||
price = LP_query(ctx,myipaddr,mypubsock,profitmargin,"request",&Q); |
|||
bestitem = LP_quotejson(&Q); |
|||
if ( price > SMALLVAL ) |
|||
{ |
|||
if ( price <= maxprice ) |
|||
{ |
|||
price = LP_query(ctx,myipaddr,mypubsock,profitmargin,"connect",&Q); |
|||
LP_requestinit(&Q.R,Q.srchash,Q.desthash,base,Q.satoshis,Q.destcoin,Q.destsatoshis,Q.timestamp,Q.quotetime,DEXselector); |
|||
expiration = (uint32_t)time(NULL) + timeout; |
|||
while ( time(NULL) < expiration ) |
|||
{ |
|||
if ( autxo->S.swap != 0 ) |
|||
break; |
|||
sleep(1); |
|||
} |
|||
if ( autxo->S.swap == 0 ) |
|||
{ |
|||
if ( (pubp= LP_pubkeyadd(bestutxo->pubkey)) != 0 ) |
|||
pubp->numerrors++; |
|||
jaddstr(bestitem,"status","couldnt establish connection"); |
|||
} else jaddstr(bestitem,"status","connected"); |
|||
jaddnum(bestitem,"quotedprice",price); |
|||
jaddnum(bestitem,"maxprice",maxprice); |
|||
jaddnum(bestitem,"requestid",Q.R.requestid); |
|||
jaddnum(bestitem,"quoteid",Q.R.quoteid); |
|||
printf("Alice r.%u q.%u\n",Q.R.requestid,Q.R.quoteid); |
|||
} |
|||
else |
|||
{ |
|||
jaddnum(bestitem,"quotedprice",price); |
|||
jaddnum(bestitem,"maxprice",maxprice); |
|||
jaddstr(bestitem,"status","too expensive"); |
|||
} |
|||
} |
|||
else |
|||
{ |
|||
jaddnum(bestitem,"maxprice",maxprice); |
|||
jaddstr(bestitem,"status","no response to request"); |
|||
} |
|||
if ( autxo->S.swap == 0 ) |
|||
LP_availableset(autxo); |
|||
return(jprint(bestitem,0)); |
|||
} |
|||
|
|||
|
|||
|
|||
|
File diff suppressed because it is too large
@ -1,2 +1,2 @@ |
|||
source userpass |
|||
curl --url "http://127.0.0.1:7779" --data "{\"userpass\":\"$userpass\",\"method\":\"autotrade\",\"txid\":\"$1\",\"vout\":$2,\"coin\":\"REVS\",\"maxprice\":$3}" |
|||
curl --url "http://127.0.0.1:7779" --data "{\"userpass\":\"$userpass\",\"method\":\"autotrade\",\"base\":\"REVS\",\"rel\":\"KMD\",\"volume\":1.01,\"price\":1.234}" |
|||
|
@ -1,2 +1,24 @@ |
|||
source randval |
|||
pkill -15 marketmaker; git pull; cd ..; ./m_mm; ./marketmaker "{\"client\":1,\"passphrase\":\"$randval\"}" & |
|||
pkill -15 marketmaker; |
|||
git pull; |
|||
cd ..; |
|||
./m_mm; |
|||
./marketmaker "{\"gui\":\"nogui\",\"client\":1,\"coins\":[{\"coin\":\"REVS\",\"active\":1, \"asset\":\"REVS\",\"rpcport\":10196},{\"coin\":\"JUMBLR\",\"active\":1, \"asset\":\"JUMBLR\",\"rpcport\":15106}, |
|||
{\"coin\":\"DOGE\", \"name\":\"dogecoin\", \"pubtype\":30, \"p2shtype\":5, \"wiftype\":128, \"txfee\":100000000}, |
|||
{\"active\":0,\"coin\":\"HUSH\",\"name\":\"hush\",\"rpcport\":8822,\"taddr\":28,\"pubtype\":184,\"p2shtype\":189,\"wiftype\":128,\"txfee\":10000 }, |
|||
{\"active\":0,\"coin\":\"ZEC\",\"name\":\"zcash\",\"rpcport\":8232,\"taddr\":28,\"pubtype\":184,\"p2shtype\":189,\"wiftype\":128,\"txfee\":10000 }, |
|||
{\"coin\":\"DGB\", \"name\":\"digibyte\", \"pubtype\":30, \"p2shtype\":5, \"wiftype\":128, \"txfee\":10000}, |
|||
{\"coin\":\"MZC\", \"name\":\"mazacoin\", \"pubtype\":50, \"p2shtype\":9, \"wiftype\":224, \"txfee\":0}, |
|||
{\"coin\":\"SYS\", \"name\":\"syscoin\", \"pubtype\":0, \"p2shtype\":5, \"wiftype\":128, \"txfee\":100000}, |
|||
{\"coin\":\"UNO\", \"name\":\"unobtanium\", \"pubtype\":130, \"p2shtype\":30, \"wiftype\":224, \"txfee\":1000000}, |
|||
{\"coin\":\"ZET\", \"name\":\"zetacoin\", \"pubtype\":80, \"p2shtype\":9, \"wiftype\":224, \"txfee\":10000}, |
|||
{\"coin\":\"ZEC\", \"name\":\"zcash\", \"pubtype\":184, \"p2shtype\":189, \"wiftype\":128, \"txfee\":10000}, |
|||
{\"coin\":\"BTM\", \"name\":\"bitmark\", \"pubtype\":85, \"p2shtype\":5, \"wiftype\":213, \"txfee\":0}, |
|||
{\"coin\":\"CARB\", \"name\":\"carboncoin\", \"pubtype\":47, \"p2shtype\":5, \"wiftype\":175, \"txfee\":0}, |
|||
{\"coin\":\"ANC\", \"name\":\"anoncoin\", \"pubtype\":23, \"p2shtype\":5, \"wiftype\":151, \"txfee\":2000000}, |
|||
{\"coin\":\"FRK\", \"name\":\"franko\", \"pubtype\":35, \"p2shtype\":5, \"wiftype\":163, \"txfee\":0}, |
|||
{\"coin\":\"GAME\", \"name\":\"gamecredits\", \"pubtype\":38, \"p2shtype\":5, \"wiftype\":166, \"txfee\":100000}, |
|||
{\"coin\":\"LTC\", \"name\":\"litecoin\", \"rpcport\":9332, \"pubtype\":48, \"p2shtype\":5, \"wiftype\":176, \"txfee\":100000 }, |
|||
{\"coin\":\"SUPERNET\",\"asset\":\"SUPERNET\",\"rpcport\":11341},{\"coin\":\"WLC\",\"asset\":\"WLC\",\"rpcport\":12167},{\"coin\":\"PANGEA\",\"asset\":\"PANGEA\",\"rpcport\":14068},{\"coin\":\"DEX\",\"asset\":\"DEX\",\"rpcport\":11890},{\"coin\":\"BET\",\"asset\":\"BET\",\"rpcport\":14250},{\"coin\":\"CRYPTO\",\"asset\":\"CRYPTO\",\"rpcport\":8516},{\"coin\":\"HODL\",\"asset\":\"HODL\",\"rpcport\":14431},{\"coin\":\"SHARK\",\"asset\":\"SHARK\",\"rpcport\":10114},{\"coin\":\"BOTS\",\"asset\":\"BOTS\",\"rpcport\":11964},{\"coin\":\"MGW\",\"asset\":\"MGW\",\"rpcport\":12386},{\"coin\":\"COQUI\",\"asset\":\"COQUI\",\"rpcport\":12456},{\"coin\":\"KV\",\"asset\":\"KV\",\"rpcport\":9747},{\"coin\":\"CEAL\",\"asset\":\"CEAL\",\"rpcport\":11116},{\"coin\":\"MESH\",\"asset\":\"MESH\",\"rpcport\":9455} |
|||
], \"userhome\":\"/${HOME#"/"}\",\"passphrase\":\"$randval\"}" & |
|||
|
|||
|
@ -0,0 +1,22 @@ |
|||
source randval |
|||
pkill -15 marketmaker; |
|||
git pull; |
|||
cd ..; |
|||
./m_mm; |
|||
./marketmaker "{\"client\":1,\"coins\":[{\"coin\":\"REVS\",\"active\":1, \"asset\":\"REVS\",\"rpcport\":10196},{\"coin\":\"JUMBLR\",\"active\":1, \"asset\":\"JUMBLR\",\"rpcport\":15106}, |
|||
{\"coin\":\"DOGE\", \"name\":\"dogecoin\", \"pubtype\":30, \"p2shtype\":5, \"wiftype\":128, \"txfee\":100000000}, |
|||
{\"coin\":\"DGB\", \"name\":\"digibyte\", \"pubtype\":30, \"p2shtype\":5, \"wiftype\":128, \"txfee\":10000}, |
|||
{\"coin\":\"MZC\", \"name\":\"mazacoin\", \"pubtype\":50, \"p2shtype\":9, \"wiftype\":224, \"txfee\":0}, |
|||
{\"coin\":\"SYS\", \"name\":\"syscoin\", \"pubtype\":0, \"p2shtype\":5, \"wiftype\":128, \"txfee\":100000}, |
|||
{\"coin\":\"UNO\", \"name\":\"unobtanium\", \"pubtype\":130, \"p2shtype\":30, \"wiftype\":224, \"txfee\":1000000}, |
|||
{\"coin\":\"ZET\", \"name\":\"zetacoin\", \"pubtype\":80, \"p2shtype\":9, \"wiftype\":224, \"txfee\":10000}, |
|||
{\"coin\":\"ZEC\", \"name\":\"zcash\", \"pubtype\":184, \"p2shtype\":189, \"wiftype\":128, \"txfee\":10000}, |
|||
{\"coin\":\"BTM\", \"name\":\"bitmark\", \"pubtype\":85, \"p2shtype\":5, \"wiftype\":213, \"txfee\":0}, |
|||
{\"coin\":\"CARB\", \"name\":\"carboncoin\", \"pubtype\":47, \"p2shtype\":5, \"wiftype\":175, \"txfee\":0}, |
|||
{\"coin\":\"ANC\", \"name\":\"anoncoin\", \"pubtype\":23, \"p2shtype\":5, \"wiftype\":151, \"txfee\":2000000}, |
|||
{\"coin\":\"FRK\", \"name\":\"franko\", \"pubtype\":35, \"p2shtype\":5, \"wiftype\":163, \"txfee\":0}, |
|||
{\"coin\":\"GAME\", \"name\":\"gamecredits\", \"pubtype\":38, \"p2shtype\":5, \"wiftype\":166, \"txfee\":100000}, |
|||
{\"coin\":\"LTC\", \"name\":\"litecoin\", \"rpcport\":9332, \"pubtype\":48, \"p2shtype\":5, \"wiftype\":176, \"txfee\":100000 }, |
|||
{\"coin\":\"SUPERNET\",\"asset\":\"SUPERNET\",\"rpcport\":11341},{\"coin\":\"WLC\",\"asset\":\"WLC\",\"rpcport\":12167},{\"coin\":\"PANGEA\",\"asset\":\"PANGEA\",\"rpcport\":14068},{\"coin\":\"DEX\",\"asset\":\"DEX\",\"rpcport\":11890},{\"coin\":\"BET\",\"asset\":\"BET\",\"rpcport\":14250},{\"coin\":\"CRYPTO\",\"asset\":\"CRYPTO\",\"rpcport\":8516},{\"coin\":\"HODL\",\"asset\":\"HODL\",\"rpcport\":14431},{\"coin\":\"SHARK\",\"asset\":\"SHARK\",\"rpcport\":10114},{\"coin\":\"BOTS\",\"asset\":\"BOTS\",\"rpcport\":11964},{\"coin\":\"MGW\",\"asset\":\"MGW\",\"rpcport\":12386},{\"coin\":\"MVP\",\"asset\":\"MVP\",\"rpcport\":8655},{\"coin\":\"KV\",\"asset\":\"KV\",\"rpcport\":9747},{\"coin\":\"CEAL\",\"asset\":\"CEAL\",\"rpcport\":11116},{\"coin\":\"MESH\",\"asset\":\"MESH\",\"rpcport\":9455} |
|||
], \"userhome\":\"/${HOME#"/"}/Library/Application\ Support\", \"passphrase\":\"$randval\"}" & |
|||
|
@ -1,2 +1,2 @@ |
|||
source userpass |
|||
curl --url "http://127.0.0.1:7779" --data "{\"userpass\":\"$userpass\",\"method\":\"getprice\",\"base\":\"REVS\",\"rel\":\"KMD\"}" |
|||
curl --url "http://127.0.0.1:7779" --data "{\"userpass\":\"$userpass\",\"method\":\"disable\",\"coin\":\"REVS\"}" |
@ -0,0 +1,2 @@ |
|||
source userpass |
|||
curl --url "http://127.0.0.1:7779" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"BTC\"}" |
@ -0,0 +1,2 @@ |
|||
source userpass |
|||
curl --url "http://127.0.0.1:7779" --data "{\"userpass\":\"$userpass\",\"pubkey\":\"6578099f6474d9b8bd66a7a136b922029a989818ec0309aee962dd6ac1862b74\",\"method\":\"forward\",\"method2\":\"getprice\",\"base\":\"REVS\",\"rel\":\"KMD\"}" |
@ -0,0 +1,2 @@ |
|||
source userpass |
|||
curl --url "http://127.0.0.1:7779" --data "{\"userpass\":\"$userpass\",\"method\":\"getcoins\"}" |
@ -0,0 +1,2 @@ |
|||
source userpass |
|||
curl --url "http://127.0.0.1:7779" --data "{\"userpass\":\"$userpass\",\"method\":\"getprices\",\"coin\":\"REVS\"}" |
@ -0,0 +1,2 @@ |
|||
source userpass |
|||
curl --url "http://127.0.0.1:7779" --data "{\"userpass\":\"$userpass\",\"method\":\"getutxos\",\"coin\":\"REVS\"}" |
@ -0,0 +1,2 @@ |
|||
source userpass |
|||
curl --url "http://127.0.0.1:7779" --data "{\"userpass\":\"$userpass\",\"method\":\"help\"}" |
@ -1,2 +1,2 @@ |
|||
source userpass |
|||
curl --url "http://127.0.0.1:7779" --data "{\"userpass\":\"$userpass\",\"method\":\"inventory\",\"coin\":\"KMD\"}" |
|||
curl --url "http://127.0.0.1:7779" --data "{\"userpass\":\"$userpass\",\"method\":\"inventory\",\"coin\":\"BTC\"}" |
|||
|
@ -0,0 +1,2 @@ |
|||
source userpass |
|||
curl --url "http://127.0.0.1:7779" --data "{\"userpass\":\"$userpass\",\"pubkey\":\"6578099f6474d9b8bd66a7a136b922029a989818ec0309aee962dd6ac1862b74\",\"method\":\"forward\",\"method2\":\"lookup\",\"client\":\"$1\"}" |
@ -0,0 +1,7 @@ |
|||
while true |
|||
do |
|||
source userpass |
|||
#curl --url "http://127.0.0.1:7779" --data "{\"userpass\":\"$userpass\",\"method\":\"setprice\",\"base\":\"REVS\",\"rel\":\"KMD\",\"price\":1.234}" |
|||
./s |
|||
sleep 3600 |
|||
done |
@ -0,0 +1,2 @@ |
|||
source userpass |
|||
curl --url "http://127.0.0.1:7779" --data "{\"userpass\":\"$userpass\",\"method\":\"myprices\"}" |
@ -1,2 +1,2 @@ |
|||
source userpass |
|||
curl --url "http://127.0.0.1:7779" --data "{\"userpass\":\"$userpass\",\"method\":\"orderbook\",\"base\":\"REVS\",\"rel\":\"KMD\"}" |
|||
curl --url "http://127.0.0.1:7779" --data "{\"userpass\":\"$userpass\",\"method\":\"orderbook\",\"base\":\"KMD\",\"rel\":\"BTC\"}" |
|||
|
@ -0,0 +1,2 @@ |
|||
source userpass |
|||
curl --url "http://127.0.0.1:7779" --data "{\"userpass\":\"$userpass\",\"pubkey\":\"6578099f6474d9b8bd66a7a136b922029a989818ec0309aee962dd6ac1862b74\",\"method\":\"forward\",\"method2\":\"publish\",\"data\":\"nonsense\"}" |
@ -0,0 +1,3 @@ |
|||
|
|||
source userpass |
|||
curl --url "http://127.0.0.1:7779" --data "{\"userpass\":\"$userpass\",\"method\":\"registerall\",\"numnodes\":10}" |
@ -1,2 +1,19 @@ |
|||
source randval |
|||
pkill -15 marketmaker; git pull; cd ..; ./m_mm; ./marketmaker "{\"profitmargin\":0.01,\"passphrase\":\"$randval\"}" & |
|||
pkill -15 marketmaker; git pull; cd ..; ./m_mm; $1 ./marketmaker "{\"gui\":\"nogui\",\"profitmargin\":0.01,\"passphrase\":\"$randval\",\"coins\":[{\"coin\":\"REVS\",\"active\":1, \"asset\":\"REVS\",\"rpcport\":10196},{\"coin\":\"JUMBLR\",\"active\":1, \"asset\":\"JUMBLR\",\"rpcport\":15106}, |
|||
{\"coin\":\"DOGE\", \"name\":\"dogecoin\", \"pubtype\":30, \"p2shtype\":5, \"wiftype\":128, \"txfee\":100000000}, |
|||
{\"coin\":\"HUSH\",\"name\":\"hush\",\"rpcport\":8822,\"taddr\":28,\"pubtype\":184,\"p2shtype\":189,\"wiftype\":128,\"txfee\":10000 }, |
|||
{\"active\":0,\"coin\":\"ZEC\",\"name\":\"zcash\",\"rpcport\":8232,\"taddr\":28,\"pubtype\":184,\"p2shtype\":189,\"wiftype\":128,\"txfee\":10000 }, |
|||
{\"coin\":\"DGB\", \"name\":\"digibyte\", \"pubtype\":30, \"p2shtype\":5, \"wiftype\":128, \"txfee\":10000}, |
|||
{\"coin\":\"MZC\", \"name\":\"mazacoin\", \"pubtype\":50, \"p2shtype\":9, \"wiftype\":224, \"txfee\":0}, |
|||
{\"coin\":\"SYS\", \"name\":\"syscoin\", \"pubtype\":0, \"p2shtype\":5, \"wiftype\":128, \"txfee\":100000}, |
|||
{\"coin\":\"UNO\", \"name\":\"unobtanium\", \"pubtype\":130, \"p2shtype\":30, \"wiftype\":224, \"txfee\":1000000}, |
|||
{\"coin\":\"ZET\", \"name\":\"zetacoin\", \"pubtype\":80, \"p2shtype\":9, \"wiftype\":224, \"txfee\":10000}, |
|||
{\"coin\":\"ZEC\", \"name\":\"zcash\", \"pubtype\":184, \"p2shtype\":189, \"wiftype\":128, \"txfee\":10000}, |
|||
{\"coin\":\"BTM\", \"name\":\"bitmark\", \"pubtype\":85, \"p2shtype\":5, \"wiftype\":213, \"txfee\":0}, |
|||
{\"coin\":\"CARB\", \"name\":\"carboncoin\", \"pubtype\":47, \"p2shtype\":5, \"wiftype\":175, \"txfee\":0}, |
|||
{\"coin\":\"ANC\", \"name\":\"anoncoin\", \"pubtype\":23, \"p2shtype\":5, \"wiftype\":151, \"txfee\":2000000}, |
|||
{\"coin\":\"FRK\", \"name\":\"franko\", \"pubtype\":35, \"p2shtype\":5, \"wiftype\":163, \"txfee\":0}, |
|||
{\"coin\":\"GAME\", \"name\":\"gamecredits\", \"pubtype\":38, \"p2shtype\":5, \"wiftype\":166, \"txfee\":100000}, |
|||
{\"coin\":\"LTC\", \"name\":\"litecoin\", \"rpcport\":9332, \"pubtype\":48, \"p2shtype\":5, \"wiftype\":176, \"txfee\":100000 }, |
|||
{\"coin\":\"SUPERNET\",\"asset\":\"SUPERNET\",\"rpcport\":11341},{\"coin\":\"WLC\",\"asset\":\"WLC\",\"rpcport\":12167},{\"coin\":\"PANGEA\",\"asset\":\"PANGEA\",\"rpcport\":14068},{\"coin\":\"DEX\",\"asset\":\"DEX\",\"rpcport\":11890},{\"coin\":\"BET\",\"asset\":\"BET\",\"rpcport\":14250},{\"coin\":\"CRYPTO\",\"asset\":\"CRYPTO\",\"rpcport\":8516},{\"coin\":\"HODL\",\"asset\":\"HODL\",\"rpcport\":14431},{\"coin\":\"SHARK\",\"asset\":\"SHARK\",\"rpcport\":10114},{\"coin\":\"BOTS\",\"asset\":\"BOTS\",\"rpcport\":11964},{\"coin\":\"MGW\",\"asset\":\"MGW\",\"rpcport\":12386},{\"coin\":\"COQUI\",\"asset\":\"COQUI\",\"rpcport\":12456},{\"coin\":\"KV\",\"asset\":\"KV\",\"rpcport\":9747},{\"coin\":\"CEAL\",\"asset\":\"CEAL\",\"rpcport\":11116},{\"coin\":\"MESH\",\"asset\":\"MESH\",\"rpcport\":9455} |
|||
]}" & |
|||
|
@ -0,0 +1,17 @@ |
|||
source randval |
|||
pkill -15 marketmaker; git pull; cd ..; ./m_mm; ./marketmaker "{\"profitmargin\":0.01,\"userhome\":\"/${HOME#"/"}/Library/Application\ Support\",\"passphrase\":\"$randval\",\"coins\":[{\"coin\":\"REVS\",\"active\":1, \"asset\":\"REVS\",\"rpcport\":10196},{\"coin\":\"JUMBLR\",\"active\":1, \"asset\":\"JUMBLR\",\"rpcport\":15106}, |
|||
{\"coin\":\"DOGE\", \"name\":\"dogecoin\", \"pubtype\":30, \"p2shtype\":5, \"wiftype\":128, \"txfee\":100000000}, |
|||
{\"coin\":\"DGB\", \"name\":\"digibyte\", \"pubtype\":30, \"p2shtype\":5, \"wiftype\":128, \"txfee\":10000}, |
|||
{\"coin\":\"MZC\", \"name\":\"mazacoin\", \"pubtype\":50, \"p2shtype\":9, \"wiftype\":224, \"txfee\":0}, |
|||
{\"coin\":\"SYS\", \"name\":\"syscoin\", \"pubtype\":0, \"p2shtype\":5, \"wiftype\":128, \"txfee\":100000}, |
|||
{\"coin\":\"UNO\", \"name\":\"unobtanium\", \"pubtype\":130, \"p2shtype\":30, \"wiftype\":224, \"txfee\":1000000}, |
|||
{\"coin\":\"ZET\", \"name\":\"zetacoin\", \"pubtype\":80, \"p2shtype\":9, \"wiftype\":224, \"txfee\":10000}, |
|||
{\"coin\":\"ZEC\", \"name\":\"zcash\", \"pubtype\":184, \"p2shtype\":189, \"wiftype\":128, \"txfee\":10000}, |
|||
{\"coin\":\"BTM\", \"name\":\"bitmark\", \"pubtype\":85, \"p2shtype\":5, \"wiftype\":213, \"txfee\":0}, |
|||
{\"coin\":\"CARB\", \"name\":\"carboncoin\", \"pubtype\":47, \"p2shtype\":5, \"wiftype\":175, \"txfee\":0}, |
|||
{\"coin\":\"ANC\", \"name\":\"anoncoin\", \"pubtype\":23, \"p2shtype\":5, \"wiftype\":151, \"txfee\":2000000}, |
|||
{\"coin\":\"FRK\", \"name\":\"franko\", \"pubtype\":35, \"p2shtype\":5, \"wiftype\":163, \"txfee\":0}, |
|||
{\"coin\":\"GAME\", \"name\":\"gamecredits\", \"pubtype\":38, \"p2shtype\":5, \"wiftype\":166, \"txfee\":100000}, |
|||
{\"coin\":\"LTC\", \"name\":\"litecoin\", \"rpcport\":9332, \"pubtype\":48, \"p2shtype\":5, \"wiftype\":176, \"txfee\":100000 }, |
|||
{\"coin\":\"SUPERNET\",\"asset\":\"SUPERNET\",\"rpcport\":11341},{\"coin\":\"WLC\",\"asset\":\"WLC\",\"rpcport\":12167},{\"coin\":\"PANGEA\",\"asset\":\"PANGEA\",\"rpcport\":14068},{\"coin\":\"DEX\",\"asset\":\"DEX\",\"rpcport\":11890},{\"coin\":\"BET\",\"asset\":\"BET\",\"rpcport\":14250},{\"coin\":\"CRYPTO\",\"asset\":\"CRYPTO\",\"rpcport\":8516},{\"coin\":\"HODL\",\"asset\":\"HODL\",\"rpcport\":14431},{\"coin\":\"SHARK\",\"asset\":\"SHARK\",\"rpcport\":10114},{\"coin\":\"BOTS\",\"asset\":\"BOTS\",\"rpcport\":11964},{\"coin\":\"MGW\",\"asset\":\"MGW\",\"rpcport\":12386},{\"coin\":\"MVP\",\"asset\":\"MVP\",\"rpcport\":8655},{\"coin\":\"KV\",\"asset\":\"KV\",\"rpcport\":9747},{\"coin\":\"CEAL\",\"asset\":\"CEAL\",\"rpcport\":11116},{\"coin\":\"MESH\",\"asset\":\"MESH\",\"rpcport\":9455} |
|||
]}" & |
@ -0,0 +1,2 @@ |
|||
source userpass |
|||
curl --url "http://127.0.0.1:7779" --data "{\"userpass\":\"$userpass\",\"method\":\"swapstatus\"}" |
@ -0,0 +1,2 @@ |
|||
source userpass |
|||
curl --url "http://127.0.0.1:7779" --data "{\"userpass\":\"$userpass\",\"method\":\"swapstatus\",\"requestid\":2291973695,\"quoteid\":3387529385}" |
@ -0,0 +1,2 @@ |
|||
source userpass |
|||
curl --url "http://127.0.0.1:7779" --data "{\"userpass\":\"$userpass\",\"method\":\"getutxos\",\"coin\":\"REVS\"}" |
@ -1,2 +1,2 @@ |
|||
#!/bin/bash |
|||
curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"dex\",\"method\":\"listunspent\",\"address\":\"RYZx1e7kVNTuQ6RTrvTkYeZAz5uJobC3pg\",\"symbol\":\"KMD\"}" |
|||
curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"dex\",\"method\":\"listunspent\",\"address\":\"RNmvQtThVZAbc1tFEFmKAnJZrc9XqciNog\",\"symbol\":\"KMD\"}" |
|||
|
Loading…
Reference in new issue