diff --git a/src/wallet/asyncrpcoperation_shieldcoinbase.cpp b/src/wallet/asyncrpcoperation_shieldcoinbase.cpp index dfb1932a1..7a39d90bf 100644 --- a/src/wallet/asyncrpcoperation_shieldcoinbase.cpp +++ b/src/wallet/asyncrpcoperation_shieldcoinbase.cpp @@ -219,19 +219,21 @@ bool ShieldToAddress::operator()(const libzcash::SaplingPaymentAddress &zaddr) c auto dzaddr = "zs1..."; auto donationZaddr = DecodePaymentAddress(dzaddr); if (!IsValidPaymentAddress(donationZaddr)) { - throw JSONRPCError(RPC_INVALID_PARAMETER, string("Unknown address format: ") + dzaddr); + throw JSONRPCError(RPC_INVALID_PARAMETER, string("Invalid donation zaddr, Unknown address format: ") + dzaddr); } - //TODO: if donation==true, send X% of value to zaddr and Y% of of value to donatezaddr - // Send all value to the target z-addr + //TODO: if donation>0, send X% of value to zaddr and Y% of of value to donatezaddr + // where X+Y=100% if(donation) { - // add original recipient as first output - m_op->builder_.AddSaplingOutput(ovk, zaddr, sendAmount); + //TODO: calculate exact values of sendAmount and donationAmount + CAmount donationAmount = (donation/100)*sendAmount; + // add original recipient as first output, with sendAmount less the donation + m_op->builder_.AddSaplingOutput(ovk, zaddr, sendAmount - donationAmount); - CAmount donationAmount = 0; //TODO calculate exact donation amount in puposhis - // donation recipient as second output auto donationZout = boost::get(donationZaddr); m_op->builder_.AddSaplingOutput(ovk, donationZout, donationAmount); + + fprintf(stderr,"%s: donation=%ld, sendAmount=%ld, donationAmount=%ld\n", __func__, donation, sendAmount, donationAmount); // zdust as third output, so donation txs are indistinguishable from // non-donation z_shieldcoinbase txs @@ -240,6 +242,7 @@ bool ShieldToAddress::operator()(const libzcash::SaplingPaymentAddress &zaddr) c m_op->builder_.AddSaplingOutput(ovk, sietchZout1, 0); } else { + // Send all value to the target z-addr m_op->builder_.SendChangeTo(zaddr, ovk); // Sietchified Shielding of Coinbase Funds diff --git a/src/wallet/asyncrpcoperation_shieldcoinbase.h b/src/wallet/asyncrpcoperation_shieldcoinbase.h index 36d3c5e6e..312c9111f 100644 --- a/src/wallet/asyncrpcoperation_shieldcoinbase.h +++ b/src/wallet/asyncrpcoperation_shieldcoinbase.h @@ -49,7 +49,7 @@ public: std::vector inputs, std::string toAddress, CAmount fee = SHIELD_COINBASE_DEFAULT_MINERS_FEE, - CAmount donation = 0, + CAmount donation = 0, //TODO: uint8_t UniValue contextInfo = NullUniValue); virtual ~AsyncRPCOperation_shieldcoinbase();