Fix logical merge conflicts after merging 4.7.0-rc1

The merge commit includes changes to address direct merge conflicts.
This commit makes the remaining changes necessary to integrate the
Orchard wallet changes with the NU5 consensus changes.
This commit is contained in:
Jack Grigg 2022-03-23 03:19:39 +00:00
parent 9e9f58b26f
commit 85b5595519
5 changed files with 19 additions and 13 deletions

View File

@ -220,7 +220,7 @@ public:
try {
if (orchardBundle.has_value()) {
// Orchard is only usable with v5+ transactions.
dataToBeSigned = ProduceZip244SignatureHash(mtx, orchardBundle.value());
dataToBeSigned = ProduceZip244SignatureHash(mtx, {}, orchardBundle.value());
} else {
CScript scriptCode;
PrecomputedTransactionData txdata(mtx, {});

View File

@ -16,14 +16,17 @@ use orchard::{
use rand_core::OsRng;
use tracing::error;
use zcash_primitives::transaction::{
components::{sapling, transparent, Amount},
sighash::{SignableInput, SIGHASH_ALL},
components::{sapling, Amount},
sighash::SignableInput,
sighash_v5::v5_signature_hash,
txid::TxIdDigester,
Authorization, TransactionData, TxVersion,
};
use crate::{transaction_ffi::PrecomputedTxParts, ORCHARD_PK};
use crate::{
transaction_ffi::{PrecomputedTxParts, TransparentAuth},
ORCHARD_PK,
};
pub struct OrchardSpendInfo {
fvk: FullViewingKey,
@ -165,9 +168,10 @@ pub extern "C" fn orchard_unauthorized_bundle_prove_and_sign(
})
.collect::<Vec<_>>();
let mut rng = OsRng;
let res = bundle
.create_proof(pk)
.and_then(|b| b.apply_signatures(OsRng, *sighash, &signing_keys));
.create_proof(pk, &mut rng)
.and_then(|b| b.apply_signatures(&mut rng, *sighash, &signing_keys));
match res {
Ok(signed) => Box::into_raw(Box::new(signed)),
@ -209,7 +213,7 @@ pub extern "C" fn zcash_builder_zip244_shielded_signature_digest(
struct Signable {}
impl Authorization for Signable {
type TransparentAuth = transparent::Authorized;
type TransparentAuth = TransparentAuth;
type SaplingAuth = sapling::Authorized;
type OrchardAuth = InProgress<Unproven, Unauthorized>;
}
@ -217,11 +221,10 @@ pub extern "C" fn zcash_builder_zip244_shielded_signature_digest(
let txdata: TransactionData<Signable> =
precomputed_tx
.tx
.into_data()
.map_bundles(|b| b, |b| b, |_| Some(bundle.clone()));
let txid_parts = txdata.digest(TxIdDigester);
let sighash = v5_signature_hash(&txdata, SIGHASH_ALL, &SignableInput::Shielded, &txid_parts);
let sighash = v5_signature_hash(&txdata, &SignableInput::Shielded, &txid_parts);
// `v5_signature_hash` output is always 32 bytes.
*unsafe { &mut *sighash_ret } = sighash.as_ref().try_into().unwrap();

View File

@ -60,7 +60,7 @@ pub extern "C" fn zcash_transaction_digests(
}
#[derive(Clone, Debug)]
struct TransparentAuth {
pub(crate) struct TransparentAuth {
all_prev_outputs: Vec<transparent::TxOut>,
}
@ -140,7 +140,7 @@ impl orchard_serialization::MapAuth<orchard::bundle::Authorized, orchard::bundle
}
}
struct PrecomputedAuth;
pub(crate) struct PrecomputedAuth;
impl Authorization for PrecomputedAuth {
type TransparentAuth = TransparentAuth;

View File

@ -17,10 +17,11 @@
uint256 ProduceZip244SignatureHash(
const CTransaction& tx,
const std::vector<CTxOut>& allPrevOutputs,
const orchard::UnauthorizedBundle& orchardBundle)
{
uint256 dataToBeSigned;
PrecomputedTransactionData local(tx);
PrecomputedTransactionData local(tx, allPrevOutputs);
if (!zcash_builder_zip244_shielded_signature_digest(
local.preTx.release(),
orchardBundle.inner.get(),
@ -634,7 +635,7 @@ TransactionBuilderResult TransactionBuilder::Build()
try {
if (orchardBundle.has_value()) {
// Orchard is only usable with v5+ transactions.
dataToBeSigned = ProduceZip244SignatureHash(mtx, orchardBundle.value());
dataToBeSigned = ProduceZip244SignatureHash(mtx, tIns, orchardBundle.value());
} else {
CScript scriptCode;
dataToBeSigned = SignatureHash(scriptCode, mtx, NOT_AN_INPUT, SIGHASH_ALL, 0, consensusBranchId, txdata);

View File

@ -30,6 +30,7 @@ namespace orchard { class UnauthorizedBundle; }
uint256 ProduceZip244SignatureHash(
const CTransaction& tx,
const std::vector<CTxOut>& allPrevOutputs,
const orchard::UnauthorizedBundle& orchardBundle);
namespace orchard {
@ -147,6 +148,7 @@ private:
// ~~~~~~ ^
friend uint256 (::ProduceZip244SignatureHash(
const CTransaction& tx,
const std::vector<CTxOut>& allPrevOutputs,
const UnauthorizedBundle& orchardBundle));
public: