This commit is contained in:
jl777
2016-10-24 17:58:09 -03:00
parent b68920a15b
commit 303f5c1bf1
2 changed files with 13 additions and 7 deletions

View File

@@ -452,7 +452,7 @@ Value sendtoaddress(const Array& params, bool fHelp)
return wtx.GetHash().GetHex();
}
uint64_t PAX_fiatdest(char *destaddr,uint8_t pubkey33[33],char *coinaddr,int32_t height,char *base,int64_t fiatoshis);
uint64_t PAX_fiatdest(char *fiatbuf,char *destaddr,uint8_t pubkey33[33],char *coinaddr,int32_t height,char *base,int64_t fiatoshis);
Value paxdeposit(const Array& params, bool fHelp)
{
@@ -468,19 +468,23 @@ Value paxdeposit(const Array& params, bool fHelp)
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid Bitcoin address");
int64_t fiatoshis = atof(params[1].get_str().c_str()) * COIN;
std::string base = params[2].get_str();
std::string dest;
komodoshis = PAX_fiatdest(destaddr,pubkey33,(char *)params[0].get_str().c_str(),chainActive.Tip()->nHeight,(char *)base.c_str(),fiatoshis);
std::string dest; char fiatbuf[1024];
komodoshis = PAX_fiatdest(fiatbuf,destaddr,pubkey33,(char *)params[0].get_str().c_str(),chainActive.Tip()->nHeight,(char *)base.c_str(),fiatoshis);
dest.append(destaddr);
CBitcoinAddress destaddress(dest);
if (!destaddress.IsValid())
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid dest Bitcoin address");
for (i=0; i<33; i++)
printf("%02x",pubkey33[i]);
printf(" ht.%d srcaddr.(%s) %s fiatoshis.%lld -> dest.(%s) komodoshis.%llu\n",chainActive.Tip()->nHeight,(char *)params[0].get_str().c_str(),(char *)base.c_str(),(long long)fiatoshis,destaddr,(long long)komodoshis);
EnsureWalletIsUnlocked();
CWalletTx wtx;
SendMoney(destaddress.Get(), komodoshis, fSubtractFeeFromAmount, wtx);
CWalletTx wtx; std::string account,paxstr;
account.append((char *)"PAX");
paxstr.append(fiatbuf);
wtx.mapValue["PAX"] = paxstr;
pwalletMain->SetAddressBook(destaddress.Get(),account,fiatbuf);
SendMoney(destaddress.Get(),komodoshis,fSubtractFeeFromAmount,wtx);
return wtx.GetHash().GetHex();
}