WIP donation
This commit is contained in:
@@ -219,19 +219,21 @@ bool ShieldToAddress::operator()(const libzcash::SaplingPaymentAddress &zaddr) c
|
|||||||
auto dzaddr = "zs1...";
|
auto dzaddr = "zs1...";
|
||||||
auto donationZaddr = DecodePaymentAddress(dzaddr);
|
auto donationZaddr = DecodePaymentAddress(dzaddr);
|
||||||
if (!IsValidPaymentAddress(donationZaddr)) {
|
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
|
//TODO: if donation>0, send X% of value to zaddr and Y% of of value to donatezaddr
|
||||||
// Send all value to the target z-addr
|
// where X+Y=100%
|
||||||
if(donation) {
|
if(donation) {
|
||||||
// add original recipient as first output
|
//TODO: calculate exact values of sendAmount and donationAmount
|
||||||
m_op->builder_.AddSaplingOutput(ovk, zaddr, sendAmount);
|
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<libzcash::SaplingPaymentAddress>(donationZaddr);
|
auto donationZout = boost::get<libzcash::SaplingPaymentAddress>(donationZaddr);
|
||||||
m_op->builder_.AddSaplingOutput(ovk, donationZout, donationAmount);
|
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
|
// zdust as third output, so donation txs are indistinguishable from
|
||||||
// non-donation z_shieldcoinbase txs
|
// non-donation z_shieldcoinbase txs
|
||||||
@@ -240,6 +242,7 @@ bool ShieldToAddress::operator()(const libzcash::SaplingPaymentAddress &zaddr) c
|
|||||||
m_op->builder_.AddSaplingOutput(ovk, sietchZout1, 0);
|
m_op->builder_.AddSaplingOutput(ovk, sietchZout1, 0);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
// Send all value to the target z-addr
|
||||||
m_op->builder_.SendChangeTo(zaddr, ovk);
|
m_op->builder_.SendChangeTo(zaddr, ovk);
|
||||||
|
|
||||||
// Sietchified Shielding of Coinbase Funds
|
// Sietchified Shielding of Coinbase Funds
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ public:
|
|||||||
std::vector<ShieldCoinbaseUTXO> inputs,
|
std::vector<ShieldCoinbaseUTXO> inputs,
|
||||||
std::string toAddress,
|
std::string toAddress,
|
||||||
CAmount fee = SHIELD_COINBASE_DEFAULT_MINERS_FEE,
|
CAmount fee = SHIELD_COINBASE_DEFAULT_MINERS_FEE,
|
||||||
CAmount donation = 0,
|
CAmount donation = 0, //TODO: uint8_t
|
||||||
UniValue contextInfo = NullUniValue);
|
UniValue contextInfo = NullUniValue);
|
||||||
virtual ~AsyncRPCOperation_shieldcoinbase();
|
virtual ~AsyncRPCOperation_shieldcoinbase();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user