-
Notifications
You must be signed in to change notification settings - Fork 122
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
SealBatch RPC endpoint accepts signed group PSBT #1295
Conversation
Pull Request Test Coverage Report for Build 12865228219Details
💛 - Coveralls |
I think we should have designed the API like this in the first place. Not having the asset ID in there and only relying on the order of things is suboptimal. My initial idea was to do everything in the CLI only: Call But in any case, the previous outpoint should be the thing that can be matched against, as that should be unique per asset. |
c0c6795
to
5299e8b
Compare
ad2028f
to
c42791d
Compare
5299e8b
to
49c2141
Compare
Needs rebase. |
49c2141
to
c4a9222
Compare
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.
Nice work!
Instead of requiring the asset id to be passed, if it can't be included in the PSBT, what about just looking through and testing all unsealed assets and see if the witness is valid for any of them? Might be slower, but would be simpler for the user. |
b801f9f
to
5ca4168
Compare
Changed the base branch to |
c42791d
to
45119f7
Compare
Oli suggested another way which didn't require asset ID in psbt or passed in via arg, we can match on prevout. |
I haven't tried out the CLI arg or the new doc modification. I can do that when I'm online later. |
I just tested this and I'm getting |
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.
tACK, very nice!
Just a couple user experience questions.
@@ -780,6 +780,7 @@ func (r *rpcServer) FundBatch(ctx context.Context, | |||
func (r *rpcServer) SealBatch(ctx context.Context, | |||
req *mintrpc.SealBatchRequest) (*mintrpc.SealBatchResponse, error) { | |||
|
|||
// Unmarshal group witnesses from the request. |
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.
So the idea is that the old way and new way could even be mixed? Since both seem to be parsed and then merged (at least with a collision check, so nothing is overwritten).
Not sure if that's more confusing to the user rather than helpful? I think just from an API perspective it makes sense to keep the old way (as that's perhaps easier to use programmatically). But perhaps we should disallow using both at the same time, to avoid some confusion?
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.
the old way still works for me with this branch, but as mentioned above, the new way fails
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.
Did you switch between branches? Or use my Ledger branch before I rebased it on top of this one?
Not being able to parse the PSBT probably means it's because of the bump in the psbt
library that isn't in this branch. So can you try again with the current version of #1301 that includes this PR?
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.
Still getting unable to parse signed group virtual PSBT: unexpected EOF
with cold-group-key-pedersen
. I'm using chantools
to generate the PSBT, by the way. Maybe I'm not supposed to use that?
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.
Hmm, weird. Can you paste the PSBT here please?
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.
You can give it a try here: https://github.com/lightninglabs/tapdvalidation/tree/sealbatch-signed-group-psbt-test . Follow README.md
, except you'll have to add an extra step to checkout this branch before you run ./start_mini_META
.
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.
You can see here the difference between the old way that worked and the new way that doesn't work: https://github.com/lightninglabs/tapdvalidation/commit/e95ee5b432443570632cc36202c14fb902b4cc9a.
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.
Okay, I figured out my issue. It has been fixed here: https://github.com/lightninglabs/tapdvalidation/commit/2aa7f2f05eb43c7f3e11eb1381759f240057c231 . The problem is I passed a string as signed_group_virtual_psbts
instead of an array of strings.
Can we get a more useful test and error message for this mistake? unable to parse signed group virtual PSBT: unexpected EOF
is super uninformative. I'm a little confused why gRPC accepts a single string instead of require an array for "repeated" fields. I'm not sure why it doesn't enforce this, but I've made this mistake before and the error messages never actually lead me to understand the mistake in a meaningful way.
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.
SealBatchRequest
in mintrpc
is given as
type SealBatchRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
ShortResponse bool `protobuf:"varint,1,opt,name=short_response,json=shortResponse,proto3" json:"short_response,omitempty"`
GroupWitnesses []*taprpc.GroupWitness `protobuf:"bytes,2,rep,name=group_witnesses,json=groupWitnesses,proto3" json:"group_witnesses,omitempty"`
SignedGroupVirtualPsbts []string `protobuf:"bytes,3,rep,name=signed_group_virtual_psbts,json=signedGroupVirtualPsbts,proto3" json:"signed_group_virtual_psbts,omitempty"`
}
Are you using JSON and Python? I think in golang the type checker would have caught this.
unable to parse signed group virtual PSBT: unexpected EOF
is super uninformative
I'll modify the error message to include the signed PSBT as seen by tapd.
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.
Using Python.
It seems to do more clear error messages if I mix up a string , bytes, or int, but for some reason does not check arrays very well.
45119f7
to
e47937b
Compare
This update introduces the `signed_group_virtual_psbts` field to the SealBatchRequest. It enables passing a base64-encoded signed PSBT string into the SealBatch functionality during minting.
e47937b
to
21f44ca
Compare
Unmarshal signed group virtual PSBTs from their string RPC type into psbt.Packet types. Pass the resulting packets to the AssetMinter's SealBatch method.
This commit introduces functionality to ChainPlanter, enabling it to extract a group virtual transaction witness from a provided signed group virtual PSBT.
This commit updates the SealBatch RPC endpoint call to pass a complete signed PSBT directly, instead of extracting the witness and passing it as a separate argument.
Add a repeatable `signed_group_psbt` argument to the mint `seal` command. This allows passing multiple signed group PSBTs to the batch seal process.
Update the external group key signing guide to include the new `--signed-group-psbt` argument for the `seal` command. This ensures the guide reflects the latest functionality for batch processing with signed group PSBTs.
21f44ca
to
65d1b52
Compare
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.
LGTM!
🔥 this was def needed
This PR modifies the
SealBatch
RPC endpoint such that it accepts a complete signed PSBT directly, instead of requiring the witness to be extracted and passed separately.The goal of this PR is to simplify the UX for the external key minting procedure. It's a pretty radical simplification because it replaces the
bitcoin-cli decodepsbt
call from thedocs/external-group-key.md
doc. I think we should include something along these lines in the next release. (cc @dstadulis )This work isn't complete. I ran into a problem: the signed PSBT provided by chantools does not contain the right flags/metadata (such as tapscript root) to be able to map the PSBT to a group key request. The PSBT seems to only contain the witness.
So we might need to include the asset ID mapping in the RPC request. Thoughts on this?
I think I'm going to go with requiring the asset ID to signed PSBT mapping passed in as an arg. Perhaps like this:
I think it's wise to require the genesis asset ID because we never know what might be included in the signed PSBT.