diff --git a/src/komodo_pax.h b/src/komodo_pax.h index e924fd5f6..a75cdb1e0 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -283,9 +283,10 @@ int32_t komodo_paxprices(int32_t *heights,uint64_t *prices,int32_t max,char *bas return(num); } -uint64_t PAX_fiatdest(char *destaddr,uint8_t pubkey33[33],char *coinaddr,int32_t height,char *origbase,int64_t fiatoshis) +uint64_t PAX_fiatdest(char *fiatbuf,char *destaddr,uint8_t pubkey33[33],char *coinaddr,int32_t height,char *origbase,int64_t fiatoshis) { uint8_t shortflag = 0; char base[4]; int32_t i,baseid,relid; uint8_t addrtype,rmd160[20]; uint64_t komodoshis = 0; + fiatbuf[0] = 0; if ( strcmp(base,(char *)"KMD") == 0 || strcmp(base,(char *)"kmd") == 0 ) return(0); for (i=0; i<3; i++) @@ -296,6 +297,7 @@ uint64_t PAX_fiatdest(char *destaddr,uint8_t pubkey33[33],char *coinaddr,int32_t komodoshis = komodo_paxprice(height,base,(char *)"KMD",(uint64_t)fiatoshis); if ( bitcoin_addr2rmd160(&addrtype,rmd160,coinaddr) == 20 ) { + // put JSON into fiatbuf enough to replicate/validate PAX_pubkey(pubkey33,addrtype,rmd160,base,shortflag,fiatoshis); bitcoin_address(destaddr,KOMODO_PUBTYPE,pubkey33,33); } diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index a27feaa50..f214522b3 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -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(); }