WIP donation
This commit is contained in:
@@ -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<libzcash::SaplingPaymentAddress>(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
|
||||
|
||||
Reference in New Issue
Block a user