You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

105 lines
3.4 KiB

7 years ago
/******************************************************************************
* 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_etomic.c
// marketmaker
//
//
// Created by artem on 24.01.18.
//
#include <cpp-ethereum/etomicswap/etomiclib.h>
7 years ago
#define ETOMIC_ALICECONTRACT "0xe1D4236C5774D35Dc47dcc2E5E0CcFc463A3289c"
#define ETOMIC_BOBCONTRACT "0x9387Fd3a016bB0205e4e131Dde886B9d2BC000A2"
#define ETOMIC_SATOSHICAT "0000000000"
7 years ago
int32_t LP_etomicsymbol(char *activesymbol,char *etomic,char *symbol)
7 years ago
{
struct iguana_info *coin;
7 years ago
etomic[0] = activesymbol[0] = 0;
7 years ago
if ( (coin= LP_coinfind(symbol)) != 0 )
7 years ago
{
7 years ago
strcpy(etomic,coin->etomic);
7 years ago
if ( etomic[0] != 0 )
strcpy(activesymbol,"ETOMIC");
else strcpy(activesymbol,symbol);
}
7 years ago
return(etomic[0] != 0);
}
char *LP_etomicalice_start(struct basilisk_swap *swap)
{
AliceSendsEthPaymentInput input; AliceSendsErc20PaymentInput input20; BasicTxData txData;
7 years ago
// set input and txData fields from the swap data structure
memset(&txData,0,sizeof(txData));
if ( strcmp(swap->I.alicestr,"ETH") == 0 )
{
memset(&input,0,sizeof(input));
return(aliceSendsEthPayment(input,txData));
7 years ago
}
else
{
memset(&input20,0,sizeof(input20));
return(aliceSendsErc20Payment(input20,txData));
7 years ago
}
7 years ago
return(0);
7 years ago
}
7 years ago
int32_t LP_etomic_priv2addr(char *coinaddr,bits256 privkey)
{
char str[65],*addrstr;
bits256_str(str,privkey);
if ( (addrstr= privKey2Addr(str)) != 0 )
{
7 years ago
printf("priv2addr got %s\n",addrstr);
7 years ago
strcpy(coinaddr,addrstr);
free(addrstr);
return(0);
}
return(-1);
}
7 years ago
int32_t LP_etomic_priv2pub(uint8_t *pub64,bits256 privkey)
7 years ago
{
7 years ago
char *pubstr,str[72]; int32_t retval = -1;
7 years ago
bits256_str(str,privkey);
7 years ago
if ( (pubstr= getPubKeyFromPriv(str)) != 0 )
{
7 years ago
if ( strlen(pubstr) == 130 && pubstr[0] == '0' && pubstr[1] == 'x' )
7 years ago
{
7 years ago
decode_hex(pub64,64,pubstr+2);
7 years ago
retval = 64;
7 years ago
}
free(pubstr);
}
return(retval);
}
7 years ago
int32_t LP_etomic_pub2addr(char *coinaddr,uint8_t pub64[64])
7 years ago
{
7 years ago
char pubkeystr[131],*addrstr;
7 years ago
strcpy(pubkeystr,"0x");
7 years ago
init_hexbytes_noT(pubkeystr+2,pub64,64);
7 years ago
if ( (addrstr= pubKey2Addr(pubkeystr)) != 0 )
7 years ago
{
strcpy(coinaddr,addrstr);
free(addrstr);
return((int32_t)strlen(coinaddr));
}
return(-1);
}