WIP donation
This commit is contained in:
@@ -54,6 +54,7 @@ AsyncRPCOperation_shieldcoinbase::AsyncRPCOperation_shieldcoinbase(
|
|||||||
std::vector<ShieldCoinbaseUTXO> inputs,
|
std::vector<ShieldCoinbaseUTXO> inputs,
|
||||||
std::string toAddress,
|
std::string toAddress,
|
||||||
CAmount fee,
|
CAmount fee,
|
||||||
|
CAmount donation,
|
||||||
UniValue contextInfo) :
|
UniValue contextInfo) :
|
||||||
builder_(builder), tx_(contextualTx), inputs_(inputs), fee_(fee), contextinfo_(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
|
//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
|
// Send all value to the target z-addr
|
||||||
if(donation) {
|
if(donation) {
|
||||||
@@ -222,7 +230,8 @@ bool ShieldToAddress::operator()(const libzcash::SaplingPaymentAddress &zaddr) c
|
|||||||
|
|
||||||
CAmount donationAmount = 0; //TODO calculate exact donation amount in puposhis
|
CAmount donationAmount = 0; //TODO calculate exact donation amount in puposhis
|
||||||
// donation recipient as second output
|
// 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
|
// zdust as third output, so donation txs are indistinguishable from
|
||||||
// non-donation z_shieldcoinbase txs
|
// non-donation z_shieldcoinbase txs
|
||||||
|
|||||||
@@ -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,
|
CAmount donation = 0,
|
||||||
UniValue contextInfo = NullUniValue);
|
UniValue contextInfo = NullUniValue);
|
||||||
virtual ~AsyncRPCOperation_shieldcoinbase();
|
virtual ~AsyncRPCOperation_shieldcoinbase();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user