Skip to content

Commit 85c9769

Browse files
committed
rpcserver+taprpc: add issuance reveal data to proof leaf
1 parent 5225722 commit 85c9769

File tree

4 files changed

+864
-605
lines changed

4 files changed

+864
-605
lines changed

rpcserver.go

Lines changed: 56 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5538,14 +5538,68 @@ func (r *rpcServer) marshalUniverseProofLeaf(ctx context.Context,
55385538
return nil, err
55395539
}
55405540

5541-
return &unirpc.AssetProofResponse{
5541+
response := &unirpc.AssetProofResponse{
55425542
Req: req,
55435543
UniverseRoot: uniRoot,
55445544
UniverseInclusionProof: uniProof,
55455545
AssetLeaf: assetLeaf,
55465546
MultiverseRoot: multiverseRoot,
55475547
MultiverseInclusionProof: multiverseProof,
5548-
}, nil
5548+
}
5549+
5550+
// For an issuance proof, it's useful to directly see some of the
5551+
// genesis and meta reveal data in a decoded manner. Since we don't know
5552+
// the proof type, if it was unspecified, we'll only skip this if the
5553+
// proof type is transfer.
5554+
if req.Id.ProofType != unirpc.ProofType_PROOF_TYPE_TRANSFER {
5555+
p, err := proof.Leaf.RawProof.AsSingleProof()
5556+
if err != nil {
5557+
return nil, err
5558+
}
5559+
5560+
// If this isn't a genesis reveal, it means we have a transfer
5561+
// proof after all (perhaps because the proof type was given
5562+
// as ProofType_PROOF_TYPE_UNSPECIFIED).
5563+
if p.GenesisReveal == nil {
5564+
return response, nil
5565+
}
5566+
5567+
genInfo := &taprpc.GenesisInfo{
5568+
GenesisPoint: p.GenesisReveal.FirstPrevOut.String(),
5569+
Name: p.GenesisReveal.Tag,
5570+
MetaHash: p.GenesisReveal.MetaHash[:],
5571+
AssetId: fn.ByteSlice(p.Asset.ID()),
5572+
OutputIndex: p.GenesisReveal.OutputIndex,
5573+
AssetType: taprpc.AssetType(p.Asset.Type),
5574+
}
5575+
issuanceData := &unirpc.IssuanceData{
5576+
GenesisReveal: &taprpc.GenesisReveal{
5577+
GenesisBaseReveal: genInfo,
5578+
},
5579+
}
5580+
5581+
if p.GroupKeyReveal != nil {
5582+
rawKey := p.GroupKeyReveal.RawKey()
5583+
issuanceData.GroupKeyReveal = &taprpc.GroupKeyReveal{
5584+
RawGroupKey: rawKey[:],
5585+
TapscriptRoot: p.GroupKeyReveal.TapscriptRoot(),
5586+
}
5587+
}
5588+
5589+
if p.MetaReveal != nil {
5590+
issuanceData.MetaReveal = &taprpc.AssetMeta{
5591+
Data: p.MetaReveal.Data,
5592+
Type: taprpc.AssetMetaType(
5593+
p.MetaReveal.Type,
5594+
),
5595+
MetaHash: fn.ByteSlice(p.MetaReveal.MetaHash()),
5596+
}
5597+
}
5598+
5599+
response.IssuanceData = issuanceData
5600+
}
5601+
5602+
return response, nil
55495603
}
55505604

55515605
// QueryProof attempts to query for an issuance or transfer proof for a given

0 commit comments

Comments
 (0)