Skip to content

Commit 065401b

Browse files
committed
Merge #674: [rpc]blindrawtransaction accepts more commitments
d584b65 [test]decrese num of inputs on partial blind test (Akio Nakamura) 254b166 [rpc]blindrawtransaction accepts more commitments (Akio Nakamura) Pull request description: In #510 / #550 a requirement that the blinding commitments were equal in amount to the inputs was introduced. This requirement is correct for the final case, but not for partial transactions (e.g. where party 1 blinds their inputs before even handing the transaction over to party 2 to add theirs). In order to hide party 1's input amounts from party 2, blindrawtransaction must allow >= the inputs, since the commitments are shared beforehand (if not, the blinding fails; this may need further investigating). This PR restores the functionality to allow blinding commitments more than or equal to the amount of inputs, which makes the confidential assets demo https://github.com/ElementsProject/confidential-assets-demo functional again. Tree-SHA512: 11c7e1c648aea26be2f4cb47606cd8e9b40d9e0d736a7eeb1989d6fad10f8f06528fd90766cb95e304c9b2c371278b20d7ef61099cb8b6e18b281a260e5de92d
2 parents 3dd46d1 + d584b65 commit 065401b

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

src/wallet/rpcwallet.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5759,8 +5759,8 @@ UniValue blindrawtransaction(const JSONRPCRequest& request)
57595759
std::vector<std::vector<unsigned char> > auxiliary_generators;
57605760
if (request.params.size() > 2) {
57615761
UniValue assetCommitments = request.params[2].get_array();
5762-
if (assetCommitments.size() != 0 && assetCommitments.size() != tx.vin.size()) {
5763-
throw JSONRPCError(RPC_INVALID_PARAMETER, "Asset commitment array must have exactly as many entries as transaction inputs.");
5762+
if (assetCommitments.size() != 0 && assetCommitments.size() < tx.vin.size()) {
5763+
throw JSONRPCError(RPC_INVALID_PARAMETER, "Asset commitment array must have at least as many entries as transaction inputs.");
57645764
}
57655765
for (size_t nIn = 0; nIn < assetCommitments.size(); nIn++) {
57665766
if (assetCommitments[nIn].isStr()) {

test/functional/feature_confidential_transactions.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -496,11 +496,11 @@ def run_test(self):
496496

497497
# Create one part of the transaction to partially blind
498498
rawtx = self.nodes[0].createrawtransaction(
499-
inputs, {dst_addr2: Decimal("0.01")})
499+
inputs[:1], {dst_addr2: Decimal("0.01")})
500500

501501
# Create another part of the transaction to partially blind
502502
rawtx2 = self.nodes[0].createrawtransaction(
503-
inputs,
503+
inputs[1:],
504504
{dst_addr: Decimal("0.1"), dst_addr3: Decimal("1.0")},
505505
0,
506506
False,
@@ -523,13 +523,13 @@ def run_test(self):
523523
# Combine the transactions
524524

525525
# Blinded, but incomplete transaction.
526-
# 3 inputs and 1 output, but no fee output, and
526+
# 1 inputs and 1 output, but no fee output, and
527527
# it was blinded with 3 asset commitments, that means
528528
# the final transaction should have 3 inputs.
529529
btx = CTransaction()
530530
btx.deserialize(io.BytesIO(hex_str_to_bytes(blindtx)))
531531

532-
# Unblinded transaction, with 3 inputs and 2 outputs.
532+
# Unblinded transaction, with 2 inputs and 2 outputs.
533533
# We will add them to the other transaction to make it complete.
534534
ubtx = CTransaction()
535535
ubtx.deserialize(io.BytesIO(hex_str_to_bytes(rawtx2)))
@@ -538,9 +538,11 @@ def run_test(self):
538538
# on top of inputs and outputs of the blinded, but incomplete transaction.
539539
# We also append empty witness instances to make witness arrays match
540540
# vin/vout arrays
541+
btx.vin.append(ubtx.vin[0])
541542
btx.wit.vtxinwit.append(CTxInWitness())
542543
btx.vout.append(ubtx.vout[0])
543544
btx.wit.vtxoutwit.append(CTxOutWitness())
545+
btx.vin.append(ubtx.vin[1])
544546
btx.wit.vtxinwit.append(CTxInWitness())
545547
btx.vout.append(ubtx.vout[1])
546548
btx.wit.vtxoutwit.append(CTxOutWitness())

0 commit comments

Comments
 (0)