miner: Manually add dummy Orchard output with Orchard miner address

`orchard::Builder` pads to two Actions, but does so using a "no OVK"
policy for dummy outputs, which violates coinbase rules requiring all
shielded outputs to be recoverable. We manually add a dummy output to
sidestep this issue.
This commit is contained in:
Jack Grigg 2022-02-28 18:29:49 +00:00
parent 3fa58149b0
commit 613534bbb3
1 changed files with 13 additions and 0 deletions

View File

@ -269,6 +269,19 @@ public:
auto miner_reward = SetFoundersRewardAndGetMinerValue(ctx);
builder.AddOutput(ovk, to, miner_reward, std::nullopt);
// orchard::Builder pads to two Actions, but does so using a "no OVK" policy for
// dummy outputs, which violates coinbase rules requiring all shielded outputs to
// be recoverable. We manually add a dummy output to sidestep this issue.
// TODO: If/when we have funding streams going to Orchard recipients, this dummy
// output can be removed.
RawHDSeed rawSeed(32, 0);
GetRandBytes(rawSeed.data(), 32);
auto dummyTo = libzcash::OrchardSpendingKey::ForAccount(HDSeed(rawSeed), Params().BIP44CoinType(), 0)
.ToFullViewingKey()
.ToIncomingViewingKey()
.Address(0);
builder.AddOutput(ovk, dummyTo, 0, std::nullopt);
auto bundle = builder.Build();
if (!bundle.has_value()) {
librustzcash_sapling_proving_ctx_free(ctx);