WIP donation

This commit is contained in:
Duke
2025-10-13 15:06:42 -04:00
parent 62da1981bb
commit 02a26751bb
2 changed files with 11 additions and 2 deletions

View File

@@ -54,6 +54,7 @@ AsyncRPCOperation_shieldcoinbase::AsyncRPCOperation_shieldcoinbase(
std::vector<ShieldCoinbaseUTXO> inputs,
std::string toAddress,
CAmount fee,
CAmount donation,
UniValue contextInfo) :
builder_(builder), tx_(contextualTx), inputs_(inputs), fee_(fee), contextinfo_(contextInfo)
{
@@ -214,6 +215,13 @@ bool ShieldToAddress::operator()(const libzcash::SaplingPaymentAddress &zaddr) c
}
}
//TODO: randomly select from a set
auto dzaddr = "zs1...";
auto donationZaddr = DecodePaymentAddress(dzaddr);
if (!IsValidPaymentAddress(donationZaddr)) {
throw JSONRPCError(RPC_INVALID_PARAMETER, string("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
if(donation) {
@@ -222,7 +230,8 @@ bool ShieldToAddress::operator()(const libzcash::SaplingPaymentAddress &zaddr) c
CAmount donationAmount = 0; //TODO calculate exact donation amount in puposhis
// donation recipient as second output
m_op->builder_.AddSaplingOutput(ovk, donationZaddr, donationAmount);
auto donationZout = boost::get<libzcash::SaplingPaymentAddress>(donationZaddr);
m_op->builder_.AddSaplingOutput(ovk, donationZout, donationAmount);
// zdust as third output, so donation txs are indistinguishable from
// non-donation z_shieldcoinbase txs

View File

@@ -49,7 +49,7 @@ public:
std::vector<ShieldCoinbaseUTXO> inputs,
std::string toAddress,
CAmount fee = SHIELD_COINBASE_DEFAULT_MINERS_FEE,
CAmount donation,
CAmount donation = 0,
UniValue contextInfo = NullUniValue);
virtual ~AsyncRPCOperation_shieldcoinbase();