|
6 | 6 | "fmt" |
7 | 7 | "io" |
8 | 8 | "runtime" |
| 9 | + "sort" |
| 10 | + "strconv" |
| 11 | + "strings" |
9 | 12 | "sync" |
10 | 13 |
|
11 | 14 | "github.com/btcsuite/btcd/btcec/v2" |
@@ -178,10 +181,10 @@ func verifyTaprootProof(anchor *wire.MsgTx, proof *TaprootProof, |
178 | 181 | ) |
179 | 182 |
|
180 | 183 | return nil, fmt.Errorf("%w: derived_keys=%s, expected_key=%x, "+ |
181 | | - "output_index=%d, internal_key=%x, method=%s", |
| 184 | + "output_index=%d, internal_key=%x, asset_id=%s, method=%s", |
182 | 185 | commitment.ErrInvalidTaprootProof, keysForLog, expectedKey, |
183 | 186 | proof.OutputIndex, proof.InternalKey.SerializeCompressed(), |
184 | | - method) |
| 187 | + a.ID().String(), method) |
185 | 188 | } |
186 | 189 |
|
187 | 190 | // verifyInclusionProof verifies the InclusionProof is valid. |
@@ -373,9 +376,26 @@ func (p *Proof) verifyV0ExclusionProofs( |
373 | 376 | // Correctly validated proofs are removed from the set. That means, if |
374 | 377 | // there are any outputs left in the set, it means that there are |
375 | 378 | // missing proofs for those outputs. |
376 | | - if len(p2trOutputs) > 0 { |
377 | | - return nil, fmt.Errorf("%w: missing exclusion proof(s)", |
378 | | - ErrInvalidCommitmentProof) |
| 379 | + if len(p2trOutputs) != 0 { |
| 380 | + // Collect and sort the missing output indexes for stable |
| 381 | + // logging/errors. |
| 382 | + indexes := make([]int, 0, len(p2trOutputs)) |
| 383 | + for i := range p2trOutputs { |
| 384 | + indexes = append(indexes, int(i)) |
| 385 | + } |
| 386 | + sort.Ints(indexes) |
| 387 | + |
| 388 | + // Format as "0, 3, 7". |
| 389 | + parts := make([]string, len(indexes)) |
| 390 | + for i, v := range indexes { |
| 391 | + parts[i] = strconv.Itoa(v) |
| 392 | + } |
| 393 | + missing := strings.Join(parts, ", ") |
| 394 | + |
| 395 | + log.Errorf("Missing exclusion proofs for p2tr output "+ |
| 396 | + "indexes: %s", missing) |
| 397 | + return nil, fmt.Errorf("%w: missing exclusion proofs for "+ |
| 398 | + "outputs", ErrInvalidCommitmentProof) |
379 | 399 | } |
380 | 400 |
|
381 | 401 | return commitVersions, nil |
|
0 commit comments