WIP donation
This commit is contained in:
@@ -49,6 +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,
|
||||||
UniValue contextInfo = NullUniValue);
|
UniValue contextInfo = NullUniValue);
|
||||||
virtual ~AsyncRPCOperation_shieldcoinbase();
|
virtual ~AsyncRPCOperation_shieldcoinbase();
|
||||||
|
|
||||||
@@ -73,9 +74,6 @@ private:
|
|||||||
CAmount fee_;
|
CAmount fee_;
|
||||||
PaymentAddress tozaddr_;
|
PaymentAddress tozaddr_;
|
||||||
|
|
||||||
uint256 joinSplitPubKey_;
|
|
||||||
unsigned char joinSplitPrivKey_[crypto_sign_SECRETKEYBYTES];
|
|
||||||
|
|
||||||
std::vector<ShieldCoinbaseUTXO> inputs_;
|
std::vector<ShieldCoinbaseUTXO> inputs_;
|
||||||
|
|
||||||
TransactionBuilder builder_;
|
TransactionBuilder builder_;
|
||||||
|
|||||||
@@ -5290,18 +5290,6 @@ UniValue z_sendmany(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
|||||||
mtx.nVersionGroupId = SAPLING_VERSION_GROUP_ID;
|
mtx.nVersionGroupId = SAPLING_VERSION_GROUP_ID;
|
||||||
mtx.nVersion = SAPLING_TX_VERSION;
|
mtx.nVersion = SAPLING_TX_VERSION;
|
||||||
unsigned int max_tx_size = MAX_TX_SIZE_AFTER_SAPLING;
|
unsigned int max_tx_size = MAX_TX_SIZE_AFTER_SAPLING;
|
||||||
/*
|
|
||||||
const bool sapling = true; //NetworkUpgradeActive(nextBlockHeight, Params().GetConsensus(), Consensus::UPGRADE_SAPLING)) {
|
|
||||||
if (!sapling) {
|
|
||||||
if (NetworkUpgradeActive(nextBlockHeight, Params().GetConsensus(), Consensus::UPGRADE_OVERWINTER)) {
|
|
||||||
mtx.nVersionGroupId = OVERWINTER_VERSION_GROUP_ID;
|
|
||||||
mtx.nVersion = OVERWINTER_TX_VERSION;
|
|
||||||
} else {
|
|
||||||
mtx.fOverwintered = false;
|
|
||||||
mtx.nVersion = 2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
// As a sanity check, estimate and verify that the size of the transaction will be valid.
|
// As a sanity check, estimate and verify that the size of the transaction will be valid.
|
||||||
// Depending on the input notes, the actual tx size may turn out to be larger and perhaps invalid.
|
// Depending on the input notes, the actual tx size may turn out to be larger and perhaps invalid.
|
||||||
@@ -5420,7 +5408,7 @@ UniValue z_shieldcoinbase(const UniValue& params, bool fHelp, const CPubKey& myp
|
|||||||
if (!EnsureWalletIsAvailable(fHelp))
|
if (!EnsureWalletIsAvailable(fHelp))
|
||||||
return NullUniValue;
|
return NullUniValue;
|
||||||
|
|
||||||
if (fHelp || params.size() < 2 || params.size() > 4)
|
if (fHelp || params.size() < 2 || params.size() > 5)
|
||||||
throw runtime_error(
|
throw runtime_error(
|
||||||
"z_shieldcoinbase \"fromaddress\" \"tozaddress\" ( fee ) ( limit )\n"
|
"z_shieldcoinbase \"fromaddress\" \"tozaddress\" ( fee ) ( limit )\n"
|
||||||
"\nShield transparent coinbase funds by sending to a shielded zaddr. This is an asynchronous operation and utxos"
|
"\nShield transparent coinbase funds by sending to a shielded zaddr. This is an asynchronous operation and utxos"
|
||||||
@@ -5492,6 +5480,14 @@ UniValue z_shieldcoinbase(const UniValue& params, bool fHelp, const CPubKey& myp
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint8_t donation = 0;
|
||||||
|
if (params.size() > 4) {
|
||||||
|
donation = params[4].get_int();
|
||||||
|
if (donation < 1 || donation > 10 ) {
|
||||||
|
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid donation percentage, must be an integer between 1 and 10");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int nextBlockHeight = chainActive.Height() + 1;
|
int nextBlockHeight = chainActive.Height() + 1;
|
||||||
bool overwinterActive = nextBlockHeight>=1 ? true : false; // NetworkUpgradeActive(nextBlockHeight, Params().GetConsensus(), Consensus::UPGRADE_OVERWINTER);
|
bool overwinterActive = nextBlockHeight>=1 ? true : false; // NetworkUpgradeActive(nextBlockHeight, Params().GetConsensus(), Consensus::UPGRADE_OVERWINTER);
|
||||||
unsigned int max_tx_size = MAX_TX_SIZE_AFTER_SAPLING;
|
unsigned int max_tx_size = MAX_TX_SIZE_AFTER_SAPLING;
|
||||||
@@ -5592,15 +5588,13 @@ UniValue z_shieldcoinbase(const UniValue& params, bool fHelp, const CPubKey& myp
|
|||||||
contextInfo.push_back(Pair("fromaddress", params[0]));
|
contextInfo.push_back(Pair("fromaddress", params[0]));
|
||||||
contextInfo.push_back(Pair("toaddress", params[1]));
|
contextInfo.push_back(Pair("toaddress", params[1]));
|
||||||
contextInfo.push_back(Pair("fee", ValueFromAmount(nFee)));
|
contextInfo.push_back(Pair("fee", ValueFromAmount(nFee)));
|
||||||
|
contextInfo.push_back(Pair("donation", donation));
|
||||||
|
|
||||||
// Builder (used if Sapling addresses are involved)
|
TransactionBuilder builder = TransactionBuilder( Params().GetConsensus(), nextBlockHeight, pwalletMain);
|
||||||
TransactionBuilder builder = TransactionBuilder(
|
|
||||||
Params().GetConsensus(), nextBlockHeight, pwalletMain);
|
|
||||||
|
|
||||||
// Contextual transaction we will build on
|
// Contextual transaction we will build on
|
||||||
int blockHeight = chainActive.LastTip()->GetHeight();
|
int blockHeight = chainActive.LastTip()->GetHeight();
|
||||||
nextBlockHeight = blockHeight + 1;
|
nextBlockHeight = blockHeight + 1;
|
||||||
// (used if no Sapling addresses are involved)
|
|
||||||
CMutableTransaction contextualTx = CreateNewContextualCMutableTransaction(
|
CMutableTransaction contextualTx = CreateNewContextualCMutableTransaction(
|
||||||
Params().GetConsensus(), nextBlockHeight);
|
Params().GetConsensus(), nextBlockHeight);
|
||||||
contextualTx.nLockTime = chainActive.LastTip()->GetHeight();
|
contextualTx.nLockTime = chainActive.LastTip()->GetHeight();
|
||||||
@@ -5611,7 +5605,7 @@ UniValue z_shieldcoinbase(const UniValue& params, bool fHelp, const CPubKey& myp
|
|||||||
|
|
||||||
// Create operation and add to global queue
|
// Create operation and add to global queue
|
||||||
std::shared_ptr<AsyncRPCQueue> q = getAsyncRPCQueue();
|
std::shared_ptr<AsyncRPCQueue> q = getAsyncRPCQueue();
|
||||||
std::shared_ptr<AsyncRPCOperation> operation( new AsyncRPCOperation_shieldcoinbase(builder, contextualTx, inputs, destaddress, nFee, contextInfo) );
|
std::shared_ptr<AsyncRPCOperation> operation( new AsyncRPCOperation_shieldcoinbase(builder, contextualTx, inputs, destaddress, nFee, donation, contextInfo) );
|
||||||
q->addOperation(operation);
|
q->addOperation(operation);
|
||||||
AsyncRPCOperationId operationId = operation->getId();
|
AsyncRPCOperationId operationId = operation->getId();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user