Skip to content

Commit a317eca

Browse files
authored
Merge pull request #1166 from psgreco/elements-22-rc6
Backport fixes from master to elements-22.x for rc6
2 parents 433a57a + f669c08 commit a317eca

21 files changed

+569
-42
lines changed

.cirrus.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,10 @@ task:
123123
FILE_ENV: "./ci/test/00_setup_env_native_qt5.sh"
124124

125125
task:
126-
name: '[depends, sanitizers: thread (TSan), no gui] [hirsute]'
126+
name: '[depends, sanitizers: thread (TSan), no gui] [jammy]'
127127
<< : *GLOBAL_TASK_TEMPLATE
128128
container:
129-
image: ubuntu:hirsute
129+
image: ubuntu:jammy
130130
cpu: 6 # Increase CPU and Memory to avoid timeout
131131
memory: 24G
132132
env:
@@ -144,10 +144,10 @@ task:
144144
FILE_ENV: "./ci/test/00_setup_env_native_msan.sh"
145145

146146
task:
147-
name: '[no depends, sanitizers: address/leak (ASan + LSan) + undefined (UBSan) + integer] [hirsute]'
147+
name: '[no depends, sanitizers: address/leak (ASan + LSan) + undefined (UBSan) + integer] [jammy]'
148148
<< : *GLOBAL_TASK_TEMPLATE
149149
container:
150-
image: ubuntu:hirsute
150+
image: ubuntu:jammy
151151
memory: 16G # ELEMENTS: need more memory
152152
cpu: 4 # ELEMENTS: cirrus wants more CPUs if you want more memory
153153
env:
@@ -160,7 +160,7 @@ task:
160160
<< : *GLOBAL_TASK_TEMPLATE
161161
container:
162162
image: ubuntu:focal
163-
cpu: 4 # Increase CPU and memory to avoid timeout
163+
cpu: 8 # Increase CPU and memory to avoid timeout
164164
memory: 16G
165165
env:
166166
<< : *CIRRUS_EPHEMERAL_WORKER_TEMPLATE_ENV

ci/test/00_setup_env_native_asan.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export LC_ALL=C.UTF-8
88

99
export CONTAINER_NAME=ci_native_asan
1010
export PACKAGES="clang llvm python3-zmq qtbase5-dev qttools5-dev-tools libevent-dev bsdmainutils libboost-dev libboost-system-dev libboost-filesystem-dev libboost-test-dev libdb5.3++-dev libminiupnpc-dev libnatpmp-dev libzmq3-dev libqrencode-dev libsqlite3-dev"
11-
export DOCKER_NAME_TAG=ubuntu:hirsute
11+
export DOCKER_NAME_TAG=ubuntu:22.04
1212
export NO_DEPENDS=1
1313
export GOAL="install"
1414
export BITCOIN_CONFIG="--enable-zmq --with-incompatible-bdb --with-gui=qt5 CPPFLAGS='-DARENA_DEBUG -DDEBUG_LOCKORDER' --with-sanitizers=address,integer,undefined CC=clang CXX=clang++"

ci/test/00_setup_env_native_tsan.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
export LC_ALL=C.UTF-8
88

99
export CONTAINER_NAME=ci_native_tsan
10-
export DOCKER_NAME_TAG=ubuntu:hirsute
10+
export DOCKER_NAME_TAG=ubuntu:22.04
1111
export PACKAGES="clang llvm libc++abi-dev libc++-dev python3-zmq"
1212
export DEP_OPTS="CC=clang CXX='clang++ -stdlib=libc++'"
1313
export GOAL="install"

configure.ac

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ AC_PREREQ([2.69])
22
define(_CLIENT_VERSION_MAJOR, 22)
33
define(_CLIENT_VERSION_MINOR, 0)
44
define(_CLIENT_VERSION_BUILD, 0)
5-
define(_CLIENT_VERSION_RC, 5)
5+
define(_CLIENT_VERSION_RC, 6)
66
define(_CLIENT_VERSION_IS_RELEASE, true)
77
define(_COPYRIGHT_YEAR, 2022)
88
define(_COPYRIGHT_HOLDERS,[The %s developers])

doc/elements-tx-format.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ This document assumes some familiarity with Bitcoin and Elements (UTXOs, [Script
2121
| Flags | Yes | 1 byte | `unsigned char` | | 1 if the transaction contains a witness, otherwise 0. All other values are invalid. |
2222
| Num Inputs | Yes | Varies | `VarInt` | | Number of inputs to the transaction. |
2323
| Inputs | Yes | Varies | `Vector<TxIn>` | | |
24-
| Num Inputs | Yes | Varies | `VarInt` | | Number of outputs from the transaction. |
24+
| Num Outputs | Yes | Varies | `VarInt` | | Number of outputs from the transaction. |
2525
| Outputs | Yes | Varies | `Vector<TxOut>` | | |
2626
| Locktime | Yes | 4 bytes | `uint32_t` | Little-endian | See [BIP 113](https://github.com/bitcoin/bips/blob/master/bip-0113.mediawiki). |
2727
| Witness | Only if flags is 1 | Varies | `Witness` | | See [BIP 141](https://github.com/bitcoin/bips/blob/master/bip-0141.mediawiki). Note that Elements witnesses contain more data than Bitcoin witnesses. This extra data is described further below. |
@@ -104,7 +104,7 @@ SegWit transactions have one such witness for each input.
104104
| Script Witness | Yes | Varies | `Vector<hex>` | | The vector represents the witness stack.<br>Can be empty (length of 0). |
105105
| Peg-in Witness | Yes | Varies | `Vector<hex>` | | The vector represents the witness stack.<br>Can be empty (length of 0). |
106106

107-
The range proofs must be empty if their asociated amounts (issuance / inflation keys) are explicit.
107+
The range proofs must be empty if their associated amounts (issuance / inflation keys) are explicit.
108108
Refer [here](https://elementsproject.org/features/confidential-transactions/investigation) for more details on range proofs.
109109

110110
A non-empty peg-in witness stack should always have a length of 6, and the items should be interpreted as follows:
@@ -203,13 +203,13 @@ Deserialization:
203203
| Input #2
204204
| 8d83eb1b0826f46d473003d041116927
205205
| 470e2ce0f7cc0c634a983d438d770ac8 ... Outpoint TXID: c80a778d433d984a630cccf7e02c0e4727691141d00330476df426081beb838d
206-
| 00000000 ........................... Outpoint index
206+
| 00000000 ........................... Outpoint index
207207
|
208208
| 00 ................................. ScriptSig length
209209
| | .................................. ScriptSig (empty)
210210
|
211211
| ffffffff ........................... Sequence number: UINT32_MAX
212-
212+
213213
02 ................................... Num Outputs
214214
|
215215
| Output #1
@@ -239,7 +239,7 @@ Deserialization:
239239
| 03 ................................. Nonce header (0x03 → compressed point)
240240
| 72fdd5c6e805a50d73ab15ec41cfaadc
241241
| be408ecc7a5867621918f1070f84ec95 ... Nonce x-coordinate (big-endian)
242-
|
242+
|
243243
| 16 ................................. ScriptPubKey length (0x16 = 22 bytes)
244244
| | 001424ae71d4804ca7dd1fa66486a8
245245
| | 7af9dff1663c84 ................... ScriptPubKey
@@ -317,18 +317,18 @@ Deserialization:
317317
| | .................................. ScriptSig (empty: segwit transaction)
318318
|
319319
| fdffffff ........................... Sequence number
320-
|
320+
|
321321
| .................................... Asset issuance
322322
| | 000000000000000000000000000000
323323
| | 000000000000000000000000000000
324324
| | 0000 ............................. Asset blinding nonce (0 for new asset issuance)
325-
| |
325+
| |
326326
| | 000000000000000000000000000000
327327
| | 000000000000000000000000000000
328328
| | 0000 ............................. Asset entropy
329329
| |
330330
| | 01 ............................... Amount header (0x01 → explicit, unblinded value)
331-
| | 00000000c4b20100 ................. Amount: 0xc4b20100 = 3,300,000,000 → 33 units (each divisible by 100,000,000)
331+
| | 00000000c4b20100 ................. Amount: 0xc4b20100 = 3,300,000,000 → 33 units (each divisible by 100,000,000)
332332
| |
333333
| | 01 ............................... Num inflation keys header (0x01 → explicit, unblinded value)
334334
| | 0000000029b92700 ................. Value. 0x29b92700 = 700,000,000 inflation keys
@@ -343,7 +343,7 @@ Deserialization:
343343
| 08 ................................. Amount header (0x08 → blinded value)
344344
| 66abe471dfadfb650825abe6f757860b
345345
| 6760d30ff62bc7c9ebd438608f45368b ... Amount x-coordinate (big-endian)
346-
|
346+
|
347347
| 02 ................................. Nonce header (0x02 → blinded value)
348348
| 115750003261bc64bb73d83401a91279
349349
| 6d0c0fb9d54c72751a7ca7a5149a9bdf ... Nonce x-coordinate (big-endian)
@@ -518,7 +518,7 @@ Deserialization:
518518
| 6d521c38ec1ea15734ae22b7c4606441
519519
| 2829c0d0579f0a713d1c04ede979026f ... Asset ID: 6f0279e9ed041c3d710a9f57d0c02928416460c4b722ae3457a11eec381c526d
520520
|
521-
| 01 ................................. Amount header (0x01 → explicit, unblinded value)
521+
| 01 ................................. Amount header (0x01 → explicit, unblinded value)
522522
| 00000000002b09c1 ................... Amount: 0.02820545 L-BTC
523523
|
524524
| 00 ................................. Nonce header (0x00 → null)
@@ -532,7 +532,7 @@ Deserialization:
532532
| 6d521c38ec1ea15734ae22b7c4606441
533533
| 2829c0d0579f0a713d1c04ede979026f ... Asset ID: 6f0279e9ed041c3d710a9f57d0c02928416460c4b722ae3457a11eec381c526d
534534
|
535-
| 01 ................................. Amount header (0x01 → explicit, unblinded value)
535+
| 01 ................................. Amount header (0x01 → explicit, unblinded value)
536536
| 0000000000000027 ................... Amount: 0.00000039 L-BTC
537537
|
538538
| 00 ................................. Nonce header (0x00 → null)
@@ -560,10 +560,10 @@ Deserialization:
560560
| | | f34227cbba1cf25eb0778aa45f8b
561561
| | | 7cb3495046 ..................... Stack item #2
562562
| 06 ................................. Peg-in witness stack length
563-
| | 08 ............................... Stack item #1 length
563+
| | 08 ............................... Stack item #1 length
564564
| | | e8092b0000000000 ............... Peg-in value (little-endian): 0x2b09e8 = 0.02820545 BTC)
565565
| | 20 ............................... Stack item #2 length (0x20 = 32)
566-
| | | 6d521c38ec1ea15734ae22b7c46064
566+
| | | 6d521c38ec1ea15734ae22b7c46064
567567
| | | 412829c0d0579f0a713d1c04ede979
568568
| | | 026f ........................... Asset ID: 6f0279e9ed041c3d710a9f57d0c02928416460c4b722ae3457a11eec381c526d
569569
| | 20 ............................... Stack item #3 length (0x20 = 32)
@@ -592,4 +592,4 @@ Deserialization:
592592
| Output #2 witness
593593
| 00 ................................. Surjection proof length
594594
| 00 ................................. Range proof length
595-
```
595+
```

doc/pset.mediawiki

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,56 @@ The currently defined elements per-input proprietary types are as follows:
255255
|
256256
| 0
257257
| 2
258+
|-
259+
| Explicit Value
260+
| <tt>PSBT_ELEMENTS_IN_EXPLICIT_VALUE = 0x11</tt>
261+
| None
262+
| No key data
263+
| <tt><64-bit little endian int value></tt>
264+
| The explicit value for the input being spent. If provided, <tt>PSBT_ELEMENTS_IN_VALUE_PROOF</tt> must be provided too. Must not be provided if the input's value in the UTXO is already explicit.
265+
|
266+
| 0
267+
| 2
268+
|-
269+
| Explicit Value Proof
270+
| <tt>PSBT_ELEMENTS_IN_VALUE_PROOF = 0x12</tt>
271+
| None
272+
| No key data
273+
| <tt><rangeproof></tt>
274+
| An explicit value rangeproof that proves that the value commitment in this input's UTXO matches the explicit value in <tt>PSBT_ELEMENTS_IN_EXPLICIT_VALUE</tt>. If provided, <tt>PSBT_ELEMENTS_IN_EXPLICIT_VALUE</tt> must be provided too.
275+
|
276+
| 0
277+
| 2
278+
|-
279+
| Explicit Asset
280+
| <tt>PSBT_ELEMENTS_IN_EXPLICIT_ASSET = 0x13</tt>
281+
| None
282+
| No key data
283+
| <tt><32 byte asset tag></tt>
284+
| The explicit asset for the input being spent. If provided, <tt>PSBT_ELEMENTS_IN_ASSET_PROOF</tt> must be provided too. Must not be provided if the input's asset in the UTXO is already explicit.
285+
|
286+
| 0
287+
| 2
288+
|-
289+
| Explicit Asset Proof
290+
| <tt>PSBT_ELEMENTS_IN_ASSET_PROOF = 0x14</tt>
291+
| None
292+
| No key data
293+
| <tt><proof></tt>
294+
| An asset surjection proof with this input's asset as the only asset in the input set in order to prove that the asset commitment in the UTXO matches the explicit asset in <tt>PSBT_ELEMENTS_IN_EXPLICIT_ASSET</tt>. If provided, <tt>PSBT_ELEMENTS_IN_EXPLICIT_ASSET</tt> must be provided too.
295+
|
296+
| 0
297+
| 2
298+
|-
299+
| Blinded Issuance Flag
300+
| <tt>PSBT_ELEMENTS_IN_BLINDED_ISSUANCE = 0x15</tt>
301+
| None
302+
| No key data
303+
| <tt><1 byte boolean></tt>
304+
| A boolean flag. <tt>0x00</tt> indicates the issuance should not be blinded, <tt>0x01</tt> indicates it should be. If not specified, assumed to be <tt>0x01</tt>. Note that this does not indicate actual blinding status, but rather the expected blinding status prior to signing.
305+
|
306+
| 0
307+
| 2
258308
|}
259309

260310
The currently defined elements per-output proprietary types are as follows:

share/setup.nsi.in

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ Var StartMenuGroup
5252
!insertmacro MUI_LANGUAGE English
5353

5454
# Installer attributes
55-
InstallDir $PROGRAMFILES64\Bitcoin
55+
InstallDir $PROGRAMFILES64\Elements
5656
CRCCheck on
5757
XPStyle on
5858
BrandingText " "
@@ -105,7 +105,7 @@ Section -post SEC0001
105105
WriteRegDWORD HKCU "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" NoModify 1
106106
WriteRegDWORD HKCU "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" NoRepair 1
107107
WriteRegStr HKCR "@PACKAGE_TARNAME@" "URL Protocol" ""
108-
WriteRegStr HKCR "@PACKAGE_TARNAME@" "" "URL:Bitcoin"
108+
WriteRegStr HKCR "@PACKAGE_TARNAME@" "" "URL:Elements"
109109
WriteRegStr HKCR "@PACKAGE_TARNAME@\DefaultIcon" "" $INSTDIR\@BITCOIN_GUI_NAME@@EXEEXT@
110110
WriteRegStr HKCR "@PACKAGE_TARNAME@\shell\open\command" "" '"$INSTDIR\@BITCOIN_GUI_NAME@@EXEEXT@" "%1"'
111111
SectionEnd
@@ -138,7 +138,7 @@ Section -un.post UNSEC0001
138138
Delete /REBOOTOK "$SMPROGRAMS\$StartMenuGroup\Uninstall $(^Name).lnk"
139139
Delete /REBOOTOK "$SMPROGRAMS\$StartMenuGroup\$(^Name).lnk"
140140
Delete /REBOOTOK "$SMPROGRAMS\$StartMenuGroup\@PACKAGE_NAME@ (testnet, 64-bit).lnk"
141-
Delete /REBOOTOK "$SMSTARTUP\Bitcoin.lnk"
141+
Delete /REBOOTOK "$SMSTARTUP\Elements.lnk"
142142
Delete /REBOOTOK $INSTDIR\uninstall.exe
143143
Delete /REBOOTOK $INSTDIR\debug.log
144144
Delete /REBOOTOK $INSTDIR\db.log

src/blindpsbt.cpp

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,35 @@ BlindProofResult VerifyBlindProofs(const PSBTOutput& o) {
220220
return BlindProofResult::OK;
221221
}
222222

223+
BlindProofResult VerifyBlindProofs(const PSBTInput& i) {
224+
CTxOut utxo;
225+
if (!i.GetUTXO(utxo)) {
226+
return BlindProofResult::OK;
227+
}
228+
229+
if (i.m_explicit_value != std::nullopt) {
230+
if (i.m_value_proof.empty()) {
231+
return BlindProofResult::MISSING_VALUE_PROOF;
232+
} else if (!utxo.nValue.IsCommitment()) {
233+
return BlindProofResult::NOT_FULLY_BLINDED;
234+
} else if (!VerifyBlindValueProof(*i.m_explicit_value, utxo.nValue, i.m_value_proof, utxo.nAsset)) {
235+
return BlindProofResult::INVALID_VALUE_PROOF;
236+
}
237+
}
238+
239+
if (!i.m_explicit_asset.IsNull()) {
240+
if (i.m_asset_proof.empty()) {
241+
return BlindProofResult::MISSING_ASSET_PROOF;
242+
} else if (!utxo.nAsset.IsCommitment()) {
243+
return BlindProofResult::NOT_FULLY_BLINDED;
244+
} else if (!VerifyBlindAssetProof(i.m_explicit_asset, i.m_asset_proof, utxo.nAsset)) {
245+
return BlindProofResult::INVALID_ASSET_PROOF;
246+
}
247+
}
248+
249+
return BlindProofResult::OK;
250+
}
251+
223252
void CreateAssetCommitment(CConfidentialAsset& conf_asset, secp256k1_generator& asset_gen, const CAsset& asset, const uint256& asset_blinder)
224253
{
225254
conf_asset.vchCommitment.resize(CConfidentialAsset::nCommittedSize);
@@ -386,7 +415,8 @@ BlindingStatus BlindPSBT(PartiallySignedTransaction& psbt, std::map<uint32_t, st
386415
}
387416

388417
// Handle issuances
389-
if (input.m_issuance_value != std::nullopt || input.m_issuance_value_commitment.IsCommitment() || input.m_issuance_inflation_keys_amount != std::nullopt || input.m_issuance_inflation_keys_commitment.IsCommitment()) {
418+
if ((!input.m_blinded_issuance.has_value() || input.m_blinded_issuance.value()) &&
419+
(input.m_issuance_value != std::nullopt || input.m_issuance_value_commitment.IsCommitment() || input.m_issuance_inflation_keys_amount != std::nullopt || input.m_issuance_inflation_keys_commitment.IsCommitment())) {
390420
CAsset issuance_asset;
391421
CAsset reissuance_asset;
392422

src/blindpsbt.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
struct PartiallySignedTransaction;
1919
struct PSBTOutput;
20+
struct PSBTInput;
2021

2122
enum class BlindingStatus
2223
{
@@ -52,5 +53,6 @@ BlindingStatus BlindPSBT(PartiallySignedTransaction& psbt, std::map<uint32_t, st
5253
bool VerifyBlindValueProof(CAmount value, const CConfidentialValue& conf_value, const std::vector<unsigned char>& proof, const CConfidentialAsset& conf_asset);
5354
bool VerifyBlindAssetProof(const uint256& asset, const std::vector<unsigned char>& proof, const CConfidentialAsset& conf_asset);
5455
BlindProofResult VerifyBlindProofs(const PSBTOutput& o);
56+
BlindProofResult VerifyBlindProofs(const PSBTInput& i);
5557

5658
#endif //BITCOIN_BLINDPSBT_H

src/miner.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ void BlockAssembler::resetBlock()
112112
nFees = 0;
113113
}
114114

115-
std::unique_ptr<CBlockTemplate> BlockAssembler::CreateNewBlock(const CScript& scriptPubKeyIn, std::chrono::seconds min_tx_age, DynaFedParamEntry* proposed_entry, CScript const* commit_script)
115+
std::unique_ptr<CBlockTemplate> BlockAssembler::CreateNewBlock(const CScript& scriptPubKeyIn, std::chrono::seconds min_tx_age, DynaFedParamEntry* proposed_entry, const std::vector<CScript>* commit_scripts)
116116
{
117117
assert(min_tx_age >= std::chrono::seconds(0));
118118
int64_t nTimeStart = GetTimeMicros();
@@ -206,8 +206,10 @@ std::unique_ptr<CBlockTemplate> BlockAssembler::CreateNewBlock(const CScript& sc
206206
}
207207
coinbaseTx.vin[0].scriptSig = CScript() << nHeight << OP_0;
208208
// Non-consensus commitment output before finishing coinbase transaction
209-
if (commit_script) {
210-
coinbaseTx.vout.insert(coinbaseTx.vout.begin(), CTxOut(policyAsset, 0, *commit_script));
209+
if (commit_scripts && !commit_scripts->empty()) {
210+
for (auto commit_script: *commit_scripts) {
211+
coinbaseTx.vout.insert(std::prev(coinbaseTx.vout.end()), CTxOut(policyAsset, 0, commit_script));
212+
}
211213
}
212214
pblock->vtx[0] = MakeTransactionRef(std::move(coinbaseTx));
213215
pblocktemplate->vchCoinbaseCommitment = GenerateCoinbaseCommitment(*pblock, pindexPrev, chainparams.GetConsensus());

0 commit comments

Comments
 (0)