Skip to content

Commit 3a7b6c1

Browse files
committed
taprpc: add serialized anchor tx to AssetTransfer RPC message
Include the serialized anchor transaction in the AssetTransfer message returned by the PublishAndLogTransfer RPC endpoint. This allows clients to access the full anchor transaction used by the ChainPorter during the transfer, enabling verification against the provided anchor PSBT.
1 parent 1437bf0 commit 3a7b6c1

File tree

5 files changed

+705
-665
lines changed

5 files changed

+705
-665
lines changed

rpcserver.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3709,6 +3709,19 @@ func marshalOutboundParcel(
37093709
}
37103710
})
37113711

3712+
// Serialize the anchor transaction if it exists.
3713+
var anchorTxBytes []byte
3714+
if parcel.AnchorTx != nil {
3715+
var b bytes.Buffer
3716+
err := parcel.AnchorTx.Serialize(&b)
3717+
if err != nil {
3718+
return nil, fmt.Errorf("unable to serialize anchor "+
3719+
"tx: %w", err)
3720+
}
3721+
3722+
anchorTxBytes = b.Bytes()
3723+
}
3724+
37123725
return &taprpc.AssetTransfer{
37133726
TransferTimestamp: parcel.TransferTime.Unix(),
37143727
AnchorTxHash: anchorTxHash[:],
@@ -3719,6 +3732,7 @@ func marshalOutboundParcel(
37193732
Inputs: rpcInputs,
37203733
Outputs: rpcOutputs,
37213734
Label: parcel.Label,
3735+
AnchorTx: anchorTxBytes,
37223736
}, nil
37233737
}
37243738

taprpc/assetwalletrpc/assetwallet.swagger.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -948,6 +948,11 @@
948948
"label": {
949949
"type": "string",
950950
"description": "An optional short label for the transfer. This label can be used to track\nthe progress of the transfer via the logs or an event subscription.\nMultiple transfers can share the same label."
951+
},
952+
"anchor_tx": {
953+
"type": "string",
954+
"format": "byte",
955+
"description": "The L1 transaction that anchors the Taproot Asset commitment where the\nasset resides."
951956
}
952957
}
953958
},

0 commit comments

Comments
 (0)