Skip to content

Commit 5954b10

Browse files
author
Allen Piscitello
committed
Fixing issuance cases and half blinded cases in PSET
1 parent fa809af commit 5954b10

File tree

3 files changed

+26
-9
lines changed

3 files changed

+26
-9
lines changed

src/blindpsbt.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,9 @@ BlindingStatus BlindPSBT(PartiallySignedTransaction& psbt, std::map<uint32_t, st
476476
}
477477
}
478478
}
479+
else {
480+
input_asset_blinders.emplace_back();
481+
}
479482
}
480483
}
481484
}

src/psbt.cpp

+19-9
Original file line numberDiff line numberDiff line change
@@ -123,13 +123,26 @@ CMutableTransaction PartiallySignedTransaction::GetUnsignedTx(bool force_unblind
123123
txin.nSequence = input.sequence.value_or(max_sequence);
124124
txin.assetIssuance.assetBlindingNonce = input.m_issuance_blinding_nonce;
125125
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)) {
127129
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()) {
130132
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()) {
131141
txin.assetIssuance.nInflationKeys = input.m_issuance_inflation_keys_commitment;
132142
}
143+
else {
144+
txin.assetIssuance.nInflationKeys.SetNull();
145+
}
133146
mtx.vin.push_back(txin);
134147
}
135148
for (const PSBTOutput& output : outputs) {
@@ -531,12 +544,9 @@ bool PSBTOutput::Merge(const PSBTOutput& output)
531544
CTxOut PSBTOutput::GetTxOut() const
532545
{
533546
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);
540550
}
541551

542552
bool PSBTOutput::IsBlinded() const

src/wallet/wallet.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -2048,11 +2048,15 @@ TransactionError CWallet::SignPSBT(PartiallySignedTransaction& psbtx, bool& comp
20482048
txin.assetIssuance.nAmount = input.m_issuance_value_commitment;
20492049
} else if (input.m_issuance_value) {
20502050
txin.assetIssuance.nAmount.SetToAmount(*input.m_issuance_value);
2051+
} else {
2052+
txin.assetIssuance.nAmount.SetNull();
20512053
}
20522054
if (!input.m_issuance_inflation_keys_commitment.IsNull()) {
20532055
txin.assetIssuance.nInflationKeys = input.m_issuance_inflation_keys_commitment;
20542056
} else if (input.m_issuance_inflation_keys_amount) {
20552057
txin.assetIssuance.nInflationKeys.SetToAmount(*input.m_issuance_inflation_keys_amount);
2058+
} else {
2059+
txin.assetIssuance.nInflationKeys.SetNull();
20562060
}
20572061
if (!input.m_issuance_rangeproof.empty()) {
20582062
txinwit.vchIssuanceAmountRangeproof = input.m_issuance_rangeproof;

0 commit comments

Comments
 (0)