@@ -123,13 +123,26 @@ CMutableTransaction PartiallySignedTransaction::GetUnsignedTx(bool force_unblind
123
123
txin.nSequence = input.sequence .value_or (max_sequence);
124
124
txin.assetIssuance .assetBlindingNonce = input.m_issuance_blinding_nonce ;
125
125
txin.assetIssuance .assetEntropy = input.m_issuance_asset_entropy ;
126
- if (input.m_issuance_value != std::nullopt && input.m_issuance_inflation_keys_amount != std::nullopt && force_unblinded) {
126
+ // If there is a commitment we should set the value to the commitment unless we are forcing unblinded.
127
+ // If we are forcing unblinded but there is no value, we just use the commitment.
128
+ if (input.m_issuance_value != std::nullopt && (input.m_issuance_value_commitment .IsNull () || force_unblinded)) {
127
129
txin.assetIssuance .nAmount .SetToAmount (*input.m_issuance_value );
128
- txin. assetIssuance . nInflationKeys . SetToAmount (*input. m_issuance_inflation_keys_amount );
129
- } else {
130
+ }
131
+ else if (!input. m_issuance_value_commitment . IsNull ()) {
130
132
txin.assetIssuance .nAmount = input.m_issuance_value_commitment ;
133
+ }
134
+ else {
135
+ txin.assetIssuance .nAmount .SetNull ();
136
+ }
137
+ if (input.m_issuance_inflation_keys_amount != std::nullopt && (input.m_issuance_inflation_keys_commitment .IsNull () || force_unblinded)) {
138
+ txin.assetIssuance .nInflationKeys .SetToAmount (*input.m_issuance_value );
139
+ }
140
+ else if (!input.m_issuance_inflation_keys_commitment .IsNull ()) {
131
141
txin.assetIssuance .nInflationKeys = input.m_issuance_inflation_keys_commitment ;
132
142
}
143
+ else {
144
+ txin.assetIssuance .nInflationKeys .SetNull ();
145
+ }
133
146
mtx.vin .push_back (txin);
134
147
}
135
148
for (const PSBTOutput& output : outputs) {
@@ -531,12 +544,9 @@ bool PSBTOutput::Merge(const PSBTOutput& output)
531
544
CTxOut PSBTOutput::GetTxOut () const
532
545
{
533
546
assert (script != std::nullopt);
534
- if (!m_value_commitment.IsNull () && !m_asset_commitment.IsNull ()) {
535
- return CTxOut (m_asset_commitment, m_value_commitment, *script);
536
- }
537
- assert (amount != std::nullopt);
538
- assert (!m_asset.IsNull ());
539
- return CTxOut (CConfidentialAsset (CAsset (m_asset)), CConfidentialValue (*amount), *script);
547
+ assert (amount != std::nullopt || !m_value_commitment.IsNull ());
548
+ assert (!m_asset.IsNull () || !m_asset_commitment.IsNull ());
549
+ return CTxOut (!m_asset_commitment.IsNull () ? m_asset_commitment : CAsset (m_asset), !m_value_commitment.IsNull () ? m_value_commitment : CConfidentialValue (*amount), *script);
540
550
}
541
551
542
552
bool PSBTOutput::IsBlinded () const
0 commit comments