]> Git Repo - VerusCoin.git/commitdiff
test
authorjl777 <[email protected]>
Mon, 24 Oct 2016 20:58:09 +0000 (17:58 -0300)
committerjl777 <[email protected]>
Mon, 24 Oct 2016 20:58:09 +0000 (17:58 -0300)
src/komodo_pax.h
src/wallet/rpcwallet.cpp

index e924fd5f67e88423bc778b279a4990fe684c7db6..a75cdb1e09778c663930d2adbba78aae31e6d547 100644 (file)
@@ -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);
     }
index a27feaa50f7ccec9d997aec034525888cff2b6c7..f214522b3a4b494c4462bdd4b4aeca3b0f24613f 100644 (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();
 }
 
This page took 0.046397 seconds and 4 git commands to generate.