-
Notifications
You must be signed in to change notification settings - Fork 111
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ListBurns
RPC
#1178
base: main
Are you sure you want to change the base?
Add ListBurns
RPC
#1178
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,6 +36,8 @@ import ( | |
"github.com/lightninglabs/taproot-assets/rfqmsg" | ||
"github.com/lightninglabs/taproot-assets/rpcperms" | ||
"github.com/lightninglabs/taproot-assets/tapchannel" | ||
"github.com/lightninglabs/taproot-assets/tapdb" | ||
"github.com/lightninglabs/taproot-assets/tapdb/sqlc" | ||
"github.com/lightninglabs/taproot-assets/tapfreighter" | ||
"github.com/lightninglabs/taproot-assets/tapgarden" | ||
"github.com/lightninglabs/taproot-assets/tappsbt" | ||
|
@@ -3312,12 +3314,56 @@ func (r *rpcServer) BurnAsset(ctx context.Context, | |
} | ||
} | ||
|
||
// At this point everything completed correctly, so we log this burn in | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, perhaps we should do this further in the pipeline? So in the same db transaction that we insert the transfer. Otherwise, if we crash here, then the burn is never inserted in the db, and we exit in an inconsistent state. |
||
// our db. | ||
err = r.cfg.AssetStore.InsertBurn( | ||
GeorgeTsagk marked this conversation as resolved.
Show resolved
Hide resolved
|
||
ctx, parcel.AnchorTxHash, in.Note, assetID[:], | ||
serializedGroupKey, in.AmountToBurn, | ||
) | ||
GeorgeTsagk marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return &taprpc.BurnAssetResponse{ | ||
BurnTransfer: parcel, | ||
BurnProof: burnProof, | ||
}, nil | ||
} | ||
|
||
// ListBurns returns a list of burnt assets. Some filters may be defined in the | ||
// request to return more specific results. | ||
func (r *rpcServer) ListBurns(ctx context.Context, | ||
in *taprpc.ListBurnsRequest) (*taprpc.ListBurnsResponse, error) { | ||
|
||
burns, err := r.cfg.AssetStore.QueryBurns( | ||
ctx, sqlc.QueryBurnsParams{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should use the alias |
||
AssetID: in.AssetId, | ||
GroupKey: in.TweakedGroupKey, | ||
AnchorTxid: in.AnchorTxid, | ||
}, | ||
) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
rpcBurns := fn.Map(burns, marshalRpcBurn) | ||
|
||
return &taprpc.ListBurnsResponse{ | ||
Burns: rpcBurns, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Re other comment, I think it would be useful to include the full transfer here, also maybe the raw tx itself? |
||
}, nil | ||
} | ||
|
||
// marshalRpcBurn creates an instance of *taprpc.AssetBurn from the tapdb model. | ||
func marshalRpcBurn(b *tapdb.AssetBurn) *taprpc.AssetBurn { | ||
return &taprpc.AssetBurn{ | ||
Note: b.Note, | ||
AssetId: b.AssetID, | ||
TweakedGroupKey: b.GroupKey, | ||
Amount: b.Amount, | ||
AnchorTxid: b.AnchorTxid[:], | ||
} | ||
} | ||
|
||
// marshalOutboundParcel turns a pending parcel into its RPC counterpart. | ||
func marshalOutboundParcel( | ||
parcel *tapfreighter.OutboundParcel) (*taprpc.AssetTransfer, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: missing wrapped error.