Some orchard fixes for wallet_tx_builder
This commit is contained in:
parent
708c5354b2
commit
c2281f5425
|
@ -134,7 +134,7 @@ void ThrowInputSelectionError(const InputSelectionError& err) {
|
|||
"`-orchardactionlimit=N` where N >= %u to allow the wallet to attempt "
|
||||
"to construct this transaction.",
|
||||
err.orchardNotes,
|
||||
nOrchardActionLimit,
|
||||
err.maxNotes,
|
||||
err.orchardNotes));
|
||||
}
|
||||
}, err);
|
||||
|
|
|
@ -333,7 +333,7 @@ InputSelectionResult WalletTxBuilder::ResolveInputsAndPayments(
|
|||
}
|
||||
|
||||
if (orchardOutputs > this->maxOrchardActions) {
|
||||
return ExcessOrchardActionsError(spendableMut.orchardNoteMetadata.size());
|
||||
return ExcessOrchardActionsError(spendableMut.orchardNoteMetadata.size(), this->maxOrchardActions);
|
||||
}
|
||||
|
||||
// Set the dust threshold so that we can select enough inputs to avoid
|
||||
|
@ -365,7 +365,7 @@ InputSelectionResult WalletTxBuilder::ResolveInputsAndPayments(
|
|||
}
|
||||
|
||||
if (spendableMut.orchardNoteMetadata.size() > this->maxOrchardActions) {
|
||||
return ExcessOrchardActionsError(spendableMut.orchardNoteMetadata.size());
|
||||
return ExcessOrchardActionsError(spendableMut.orchardNoteMetadata.size(), this->maxOrchardActions);
|
||||
}
|
||||
|
||||
return resolved;
|
||||
|
@ -536,6 +536,11 @@ PrivacyPolicy TransactionEffects::GetRequiredPrivacyPolicy() const
|
|||
}
|
||||
|
||||
|
||||
bool TransactionEffects::InvolvesOrchard() const
|
||||
{
|
||||
return spendable.GetOrchardBalance() > 0 || payments.HasOrchardRecipient();
|
||||
}
|
||||
|
||||
TransactionBuilderResult TransactionEffects::ApproveAndBuild(
|
||||
const Consensus::Params& consensus,
|
||||
const CWallet& wallet,
|
||||
|
@ -557,7 +562,10 @@ TransactionBuilderResult TransactionEffects::ApproveAndBuild(
|
|||
|
||||
// Allow Orchard recipients by setting an Orchard anchor.
|
||||
std::optional<uint256> orchardAnchor;
|
||||
if (spendable.sproutNoteEntries.empty() && nPreferredTxVersion > ZIP225_MIN_TX_VERSION && this->anchorConfirmations > 0) {
|
||||
if (spendable.sproutNoteEntries.empty()
|
||||
&& (InvolvesOrchard() || nPreferredTxVersion > ZIP225_MIN_TX_VERSION)
|
||||
&& this->anchorConfirmations > 0)
|
||||
{
|
||||
auto orchardAnchorHeight = nextBlockHeight - this->anchorConfirmations;
|
||||
if (consensus.NetworkUpgradeActive(orchardAnchorHeight, Consensus::UPGRADE_NU5)) {
|
||||
LOCK(cs_main);
|
||||
|
|
|
@ -190,6 +190,8 @@ public:
|
|||
return fee;
|
||||
}
|
||||
|
||||
bool InvolvesOrchard() const;
|
||||
|
||||
TransactionBuilderResult ApproveAndBuild(
|
||||
const Consensus::Params& consensus,
|
||||
const CWallet& wallet,
|
||||
|
@ -238,8 +240,9 @@ public:
|
|||
class ExcessOrchardActionsError {
|
||||
public:
|
||||
uint32_t orchardNotes;
|
||||
uint32_t maxNotes;
|
||||
|
||||
ExcessOrchardActionsError(uint32_t orchardNotes): orchardNotes(orchardNotes) { }
|
||||
ExcessOrchardActionsError(uint32_t orchardNotes, uint32_t maxNotes): orchardNotes(orchardNotes), maxNotes(maxNotes) { }
|
||||
};
|
||||
|
||||
typedef std::variant<
|
||||
|
@ -289,7 +292,7 @@ private:
|
|||
|
||||
public:
|
||||
WalletTxBuilder(const CWallet& wallet, CFeeRate minRelayFee):
|
||||
wallet(wallet), minRelayFee(minRelayFee) {}
|
||||
wallet(wallet), minRelayFee(minRelayFee), maxOrchardActions(nOrchardActionLimit) {}
|
||||
|
||||
static bool AllowTransparentCoinbase(
|
||||
const std::vector<Payment>& payments,
|
||||
|
|
Loading…
Reference in New Issue