-
Notifications
You must be signed in to change notification settings - Fork 388
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixing issuance cases and half blinded cases in PSET #1145
Conversation
@@ -123,13 +123,26 @@ CMutableTransaction PartiallySignedTransaction::GetUnsignedTx(bool force_unblind | |||
txin.nSequence = input.sequence.value_or(max_sequence); | |||
txin.assetIssuance.assetBlindingNonce = input.m_issuance_blinding_nonce; | |||
txin.assetIssuance.assetEntropy = input.m_issuance_asset_entropy; | |||
if (input.m_issuance_value != std::nullopt && input.m_issuance_inflation_keys_amount != std::nullopt && force_unblinded) { | |||
// If there is a commitment we should set the value to the commitment unless we are forcing unblinded. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code handled blinded vs. unblinded issuances badly. It always tried to blind the issuances, even if they were unblinded issuance assets.
Since there are no fields in the PSET spec to define if an issuance should be blinded or not, we will use the presence of the issuance blinding commitment to tell us what to do.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure is related, but it seems very similar?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks similar that it may solve the problem. The use case I was trying to solve was an unblinded re-issuance.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -2048,11 +2048,15 @@ TransactionError CWallet::SignPSBT(PartiallySignedTransaction& psbtx, bool& comp | |||
txin.assetIssuance.nAmount = input.m_issuance_value_commitment; | |||
} else if (input.m_issuance_value) { | |||
txin.assetIssuance.nAmount.SetToAmount(*input.m_issuance_value); | |||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These variables were never cleared, so they retained the value of the previous loop iteration, which resulted in problems when there were multiple inputs beyond the first issuance, as well as problems when reissuing assets (where there are no inflation keys created).
@@ -531,12 +544,9 @@ bool PSBTOutput::Merge(const PSBTOutput& output) | |||
CTxOut PSBTOutput::GetTxOut() const | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would fail on situations where an asset was blinded but a value was not. I simplified the code to ensure that a value or commitment was checked in the assert (note: this will still crash if you don't provide either, maybe we should't assert?). Then it will use whatever combination of what is given.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cf71aa5
to
5954b10
Compare
Tests pass after the assert fix, @apoelstra can you re-ack, even after I merge this? |
re-utACK 5954b10 |
…or rc4 85c25b1 Bump version to -rc4 (Pablo Greco) bb684f2 Update manpages (Pablo Greco) 38e9490 Elements-qt: Fix arrows to increase/decrease Amount (Andrea Bonel) 5954b10 Fixing issuance cases and half blinded cases in PSET (Allen Piscitello) 707cf20 Fix tapscript comment (roconnor-blockstream) 7fb99ff Fix Icon position in dmg (Pablo Greco) Pull request description: Backport #1140 #1141 #1145 and #1146 from master. Fix manpages Bump to -rc4 ACKs for top commit: delta1: utACK 85c25b1 Tree-SHA512: 78a30bec870530275d103b6cab630ebf96b2df39fd03fc426bb16b6743ce9311f7e7128e43bf7a6452d261377e6ac017d61b77cd9ad4e4c20040629ae20e13b4
@@ -476,6 +476,9 @@ BlindingStatus BlindPSBT(PartiallySignedTransaction& psbt, std::map<uint32_t, st | |||
} | |||
} | |||
} | |||
else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer to have this as the if, with the existing code in the else. As it is its difficult to see what if this else relates to when reviewing. i.e.
if (!blind_issuance) {
input_asset_blinders.emplace_back();
} else {
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also all of your else
statements (here and elsewhere) are on new lines which is inconsistent with the rest of the code. Please use
} else {
Instead of
}
else {
Here and in the other changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for code formatting/style wouldn't be better to rely on a GitHub action that enforces shared rules automatically?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would make the code harder to rebase over upstream core changes, unfortunately.
A few minor cases fixed in PSET-related code. Caused either a crash or invalid transactions created in some cases.