From 0ed14ad955397e63555bf9f685c0d9f16532fe70 Mon Sep 17 00:00:00 2001 From: ca333 Date: Sat, 21 Apr 2018 17:31:09 +0200 Subject: [PATCH] OSX/WIN port conditions --- depends/packages/libsodium.mk | 17 ++++++---- src/cryptoconditions/src/cryptoconditions.c | 7 +++- src/cryptoconditions/src/json_rpc.c | 6 +++- src/paymentdisclosure.h | 4 +++ .../asyncrpcoperation_mergetoaddress.cpp | 6 ++++ .../asyncrpcoperation_shieldcoinbase.cpp | 6 ++++ src/wallet/rpcwallet.cpp | 32 ++++++++++++++++--- zcutil/build-mac.sh | 2 +- 8 files changed, 65 insertions(+), 15 deletions(-) diff --git a/depends/packages/libsodium.mk b/depends/packages/libsodium.mk index 91e6f27b7..efa5d90de 100644 --- a/depends/packages/libsodium.mk +++ b/depends/packages/libsodium.mk @@ -1,17 +1,20 @@ +ifeq ($(build_os),darwin) +package=libsodium +$(package)_version=1.0.11 +$(package)_download_path=https://supernetorg.bintray.com/misc +$(package)_file_name=libsodium-1.0.11.tar.gz +$(package)_sha256_hash=a14549db3c49f6ae2170cbbf4664bd48ace50681045e8dbea7c8d9fb96f9c765 +$(package)_dependencies= +$(package)_config_opts= +else package=libsodium -#<<<<<<< HEAD -#$(package)_version=1.0.11 -#$(package)_download_path=https://supernetorg.bintray.com/misc -#$(package)_file_name=libsodium-1.0.11.tar.gz -#$(package)_sha256_hash=a14549db3c49f6ae2170cbbf4664bd48ace50681045e8dbea7c8d9fb96f9c765 -#======= $(package)_version=1.0.15 $(package)_download_path=https://download.libsodium.org/libsodium/releases/ $(package)_file_name=$(package)-$($(package)_version).tar.gz $(package)_sha256_hash=fb6a9e879a2f674592e4328c5d9f79f082405ee4bb05cb6e679b90afe9e178f4 -#>>>>>>> zcash/master $(package)_dependencies= $(package)_config_opts= +endif define $(package)_preprocess_cmds cd $($(package)_build_subdir); ./autogen.sh diff --git a/src/cryptoconditions/src/cryptoconditions.c b/src/cryptoconditions/src/cryptoconditions.c index 2f136917e..6fd54f245 100644 --- a/src/cryptoconditions/src/cryptoconditions.c +++ b/src/cryptoconditions/src/cryptoconditions.c @@ -13,7 +13,12 @@ #include "src/eval.c" #include "src/json_rpc.c" #include -#include + +#ifdef __LP64__ +#include +#else +#include // Index into CTransaction.vjoinsplit +#endif struct CCType *CCTypeRegistry[] = { diff --git a/src/cryptoconditions/src/json_rpc.c b/src/cryptoconditions/src/json_rpc.c index 42c13612c..13cffec1d 100644 --- a/src/cryptoconditions/src/json_rpc.c +++ b/src/cryptoconditions/src/json_rpc.c @@ -1,8 +1,12 @@ #include "cryptoconditions.h" #include "internal.h" #include -#include +#ifdef __LP64__ +#include +#else +#include // Index into CTransaction.vjoinsplit +#endif static cJSON *jsonCondition(CC *cond) { cJSON *root = cJSON_CreateObject(); diff --git a/src/paymentdisclosure.h b/src/paymentdisclosure.h index e6a995ab4..fddb25bbe 100644 --- a/src/paymentdisclosure.h +++ b/src/paymentdisclosure.h @@ -73,7 +73,11 @@ struct PaymentDisclosurePayload { uint8_t version; // 0 = experimental, 1 = first production version, etc. uint256 esk; // zcash/NoteEncryption.cpp uint256 txid; // primitives/transaction.h + #ifdef __LP64__ + uint64_t js; + #else size_t js; // Index into CTransaction.vjoinsplit + #endif uint8_t n; // Index into JSDescription fields of length ZC_NUM_JS_OUTPUTS libzcash::PaymentAddress zaddr; // zcash/Address.hpp std::string message; // parameter to RPC call diff --git a/src/wallet/asyncrpcoperation_mergetoaddress.cpp b/src/wallet/asyncrpcoperation_mergetoaddress.cpp index fa823f50a..a85f3315c 100644 --- a/src/wallet/asyncrpcoperation_mergetoaddress.cpp +++ b/src/wallet/asyncrpcoperation_mergetoaddress.cpp @@ -753,8 +753,14 @@ UniValue AsyncRPCOperation_mergetoaddress::perform_joinsplit( // Generate the proof, this can take over a minute. boost::array inputs{info.vjsin[0], info.vjsin[1]}; boost::array outputs{info.vjsout[0], info.vjsout[1]}; + #ifdef __LP64__ + boost::array inputMap; + boost::array outputMap; + #else boost::array inputMap; boost::array outputMap; + #endif + uint256 esk; // payment disclosure - secret diff --git a/src/wallet/asyncrpcoperation_shieldcoinbase.cpp b/src/wallet/asyncrpcoperation_shieldcoinbase.cpp index 527f810bc..1bc82fdbe 100644 --- a/src/wallet/asyncrpcoperation_shieldcoinbase.cpp +++ b/src/wallet/asyncrpcoperation_shieldcoinbase.cpp @@ -344,8 +344,14 @@ UniValue AsyncRPCOperation_shieldcoinbase::perform_joinsplit(ShieldCoinbaseJSInf {info.vjsin[0], info.vjsin[1]}; boost::array outputs {info.vjsout[0], info.vjsout[1]}; + + #ifdef __LP64__ + boost::array inputMap; + boost::array outputMap; + #else boost::array inputMap; boost::array outputMap; + #endif uint256 esk; // payment disclosure - secret diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 347c15f2d..6c1c5361b 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -3828,7 +3828,7 @@ UniValue z_sendmany(const UniValue& params, bool fHelp) CMutableTransaction contextualTx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), nextBlockHeight); bool isShielded = !fromTaddr || zaddrRecipients.size() > 0; if (contextualTx.nVersion == 1 && isShielded) { - contextualTx.nVersion = 2; // Tx format should support vjoinsplits + contextualTx.nVersion = 2; // Tx format should support vjoinsplits } if (NetworkUpgradeActive(nextBlockHeight, Params().GetConsensus(), Consensus::UPGRADE_OVERWINTER)) { contextualTx.nExpiryHeight = nextBlockHeight + expiryDelta; @@ -3938,7 +3938,13 @@ UniValue z_shieldcoinbase(const UniValue& params, bool fHelp) CAmount shieldedValue = 0; CAmount remainingValue = 0; size_t estimatedTxSize = 2000; // 1802 joinsplit description + tx overhead + wiggle room + + #ifdef __LP64__ + uint64_t utxoCounter = 0; + #else size_t utxoCounter = 0; + #endif + bool maxedOutFlag = false; size_t mempoolLimit = (nLimit != 0) ? nLimit : (size_t)GetArg("-mempooltxinputlimit", 0); @@ -3994,7 +4000,11 @@ UniValue z_shieldcoinbase(const UniValue& params, bool fHelp) } } + #ifdef __LP64__ + uint64_t numUtxos = inputs.size(); + #else size_t numUtxos = inputs.size(); + #endif if (numUtxos == 0) { throw JSONRPCError(RPC_WALLET_INSUFFICIENT_FUNDS, "Could not find any coinbase funds to shield."); @@ -4023,7 +4033,7 @@ UniValue z_shieldcoinbase(const UniValue& params, bool fHelp) CMutableTransaction contextualTx = CreateNewContextualCMutableTransaction( Params().GetConsensus(), nextBlockHeight); if (contextualTx.nVersion == 1) { - contextualTx.nVersion = 2; // Tx format should support vjoinsplits + contextualTx.nVersion = 2; // Tx format should support vjoinsplits } if (NetworkUpgradeActive(nextBlockHeight, Params().GetConsensus(), Consensus::UPGRADE_OVERWINTER)) { contextualTx.nExpiryHeight = nextBlockHeight + expiryDelta; @@ -4231,8 +4241,13 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) CAmount mergedNoteValue = 0; CAmount remainingUTXOValue = 0; CAmount remainingNoteValue = 0; + #ifdef __LP64__ + uint64_t utxoCounter = 0; + uint64_t noteCounter = 0; + #else size_t utxoCounter = 0; size_t noteCounter = 0; + #endif bool maxedOutUTXOsFlag = false; bool maxedOutNotesFlag = false; size_t mempoolLimit = (nUTXOLimit != 0) ? nUTXOLimit : (size_t)GetArg("-mempooltxinputlimit", 0); @@ -4319,8 +4334,14 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp) } } + #ifdef __LP64__ + uint64_t numUtxos = utxoInputs.size(); //ca333 + uint64_t numNotes = noteInputs.size(); + #else size_t numUtxos = utxoInputs.size(); size_t numNotes = noteInputs.size(); + #endif + if (numUtxos == 0 && numNotes == 0) { throw JSONRPCError(RPC_WALLET_INSUFFICIENT_FUNDS, "Could not find any funds to merge."); @@ -4494,7 +4515,9 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt if ( eligible > 0 ) { if ( eligible != komodo_stake(1,bnTarget,(uint32_t)tipindex->nHeight+1,out.tx->GetHash(),out.i,eligible,(uint32_t)tipindex->nTime,(char *)CBitcoinAddress(address).ToString().c_str()) ) - fprintf(stderr,"validation of winning blocktime failed %u -> eligible.%u\n",*blocktimep,eligible); + { + //fprintf(stderr,"tip.%d validation of winning blocktime failed %u -> eligible.%u\n",(uint32_t)tipindex->nHeight,*blocktimep,eligible); + } else if ( earliest == 0 || eligible < earliest || (eligible == earliest && (*utxovaluep == 0 || nValue < *utxovaluep)) ) { earliest = eligible; @@ -4535,10 +4558,9 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt for (i=0; i