--- Log opened Thu Jan 28 00:00:28 2021 03:13 -!- darosior [~darosior@194.36.189.246] has quit [Read error: Connection reset by peer] 03:14 -!- darosior [~darosior@194.36.189.246] has joined ##miniscript 05:44 -!- darosior4 [~darosior@194.36.189.246] has joined ##miniscript 05:45 -!- darosior [~darosior@194.36.189.246] has quit [Read error: Connection reset by peer] 05:54 -!- jonatack [~jon@88.124.242.136] has joined ##miniscript 05:54 -!- jonatack [~jon@88.124.242.136] has quit [Client Quit] 07:46 -!- darosior4 is now known as darosior 08:02 -!- jonatack [~jon@88.124.242.136] has joined ##miniscript 08:07 -!- jonatack [~jon@88.124.242.136] has quit [Ping timeout: 246 seconds] 08:07 -!- jonatack [jon@gateway/vpn/airvpn/jonatack] has joined ##miniscript 08:10 -!- jonatack [jon@gateway/vpn/airvpn/jonatack] has quit [Client Quit] 08:13 -!- jonatack [~jon@88.124.242.136] has joined ##miniscript 08:19 -!- jonatack [~jon@88.124.242.136] has quit [Ping timeout: 240 seconds] 08:19 -!- jonatack [jon@gateway/vpn/airvpn/jonatack] has joined ##miniscript 11:44 -!- ghost43_ [~daer@gateway/tor-sasl/daer] has quit [Remote host closed the connection] 11:45 -!- ghost43 [~daer@gateway/tor-sasl/daer] has joined ##miniscript 13:16 < afilini> hi everyone, it's me again: i'm reading the docs of the new release (5.0.2) and while now there are some public methods like "as_inner()" i still think there are some missing stuff: 13:17 < afilini> in particular the inner types like `ShInner` are public but they are generally contained in private modules, which means that they can't be imported from the outside 13:18 < afilini> this also shows up in the docs because the return type of `ShInner` can't be clicked 13:20 < afilini> another thing which is not necessarily wrong but maybe "suboptimal" is that the `inner` field of those structures is also private, which prevents you from matching the inner type 13:22 < afilini> that's not a blocker because you can use `.as_inner()` and then match (once types like `ShInner` are public) with the return type, but in some cases it might be useful to just be able to match everything in one go i think 13:28 < andytoshi> weeird, why did the compiler let us do this 13:28 < andytoshi> sanket1729: can we just make all the descriptor types and all their fields `pub`? 13:28 < andytoshi> sorry afilini i had assumed that rustc would've complained if this were the case 13:29 < andytoshi> and i didn't look too closely at what was made pub, just that "it looked like a lot of stuff" :P 13:30 < sanket1729> afilini: sorry about that, even I though rustc would not have complained 13:30 < sanket1729> will add a fix 13:32 < sanket1729> the rationale to not make the feilds pub was that we wanted to restrict users from creating these directly 13:32 < andytoshi> ah, that makes sense 13:33 < andytoshi> yeah, i think that's reasonable ... we should try to get by with just accessor functions 13:33 < andytoshi> but maybe it'll take a couple iteratinos, if the compiler is being unhelpful 13:47 < sanket1729> andytoshi: It is indeed annoying. With the current API we have to do something like to match completely https://gist.github.com/sanket1729/ea31fd0df897f0d9b07b974b1628daf5 13:48 < andytoshi> lol. hmmm 13:48 < andytoshi> fwiw we already had that amount of pain because of the Arcs 13:48 < andytoshi> same deal with Box btw -- you basically just can't match on recursive structures in Rust 13:48 < sanket1729> But that was not exposed to library users 13:49 < andytoshi> it wasn't? i think it was? 13:49 < sanket1729> whom we expect to only use descriptors 13:49 < andytoshi> nah i'm pretty sure in Liquid we template-match on descriptors by matching on the actual types 13:49 < sanket1729> Yes 13:50 < sanket1729> but I think our rationale was if you dealing with Miniscrpt directly, it's okay to have complexity 13:50 < sanket1729> Does having a DescriptorType API help in this case? 13:50 < andytoshi> i wish we had some sort of template-matching language 13:51 < andytoshi> sanket1729: unforutnately not because you still need a recursive type somehow.. 13:51 < sanket1729> If we have a method that took in a descriptor returned DescriptorType and the miniscript inside it. 13:52 < andytoshi> oh i see 13:52 < sanket1729> I think that is what afilini needs 13:52 < andytoshi> hmmm that's a neat idea 13:53 < sanket1729> Well, our return type would be either Pk, SortedMulti or Miniscript 13:53 < andytoshi> hmm .. we could make it always be Miniscript 13:53 < andytoshi> that would involve allocation for SortedMulti 13:53 < andytoshi> oh, no, we'd have trouble 13:53 < andytoshi> with references 13:54 < andytoshi> ok, i think that's probably still a reasonable API, though it's pretty annoying 13:54 < andytoshi> to have 3 different return types 13:54 < sanket1729> How about also creating the old descriptor enum with a different name? 13:55 < andytoshi> hmmmm 13:55 < sanket1729> I don't know why, but I don't like it. 13:55 < andytoshi> yeah 13:55 < andytoshi> ditto 13:55 < andytoshi> i think returning a pair of DescriptorType and Pk/SortedMulti/Miniscript is the way to go 13:56 < sanket1729> Yeah, I will add a PR for that. 14:22 < sanket1729> welp 14:22 < sanket1729> We forgot about the context otypes 14:22 < sanket1729> *types 14:22 < andytoshi> hm? 14:22 < sanket1729> Miniscript and Miniscript are different types 14:23 < andytoshi> ahh right 14:23 < andytoshi> hmm 14:23 < sanket1729> I don't know how I can return a generic Miniscript 14:23 < andytoshi> yeah i don't tihnk yuo can 14:23 < andytoshi> except by making a new AnyCtx-type thing 14:23 < andytoshi> hm. 14:24 < andytoshi> so maybe we should just keep the .inner() style interface 14:24 < andytoshi> but maybe independently have an accessor for DescriptorType (and nothing else) 14:24 < sanket1729> so, the way might be to just return a DescriptorType and have other methods like into_legacy_miniscript 14:24 < andytoshi> heh yep :) 14:24 < sanket1729> into_segwitv0_miniscript and into_bare_miniscript, into_pk etc. 14:24 < sanket1729> I think those 4 14:25 < andytoshi> i think we can just call them all into_miniscript 14:25 < andytoshi> to the extent the user cares about the distinction 14:25 < andytoshi> it's encoded in the type 14:25 < sanket1729> Ah, right 14:25 < andytoshi> i mean, into_pk and into_sortedmulti should have distinct names :) 14:25 < andytoshi> but all the miniscript-returning ones i think should just be into_miniscirpt 14:25 < sanket1729> yep, agreed 14:43 < afilini> no worries, i also looked at the pr before it was merged and didn't notice anything weird ahaha 14:44 < afilini> in bdk i have a few instances of `match` like this one: https://github.com/bitcoindevkit/bdk/blob/2e0ca4fe05f03d94ebb0b173220de2749c9819bc/src/descriptor/mod.rs#L275-L281 14:47 < afilini> if i wanted to map them 1:1 with the new api then i would need to have access to the `inner` field in order to match everything in one shot 14:48 < afilini> but that's not necessarily the best thing, i guess one way would be to implement my "metadata" trait directly on the inner types, so that i can just call the same method on what's inside 14:49 < afilini> which is i think a pattern that you also use in the library for methods like `.script_pubkey()` etc 14:51 < afilini> also if there's interested for that i could also upstream some of my code. most of those matches are for things like "is this descriptor segwit or legacy?" or "what should i put as redeem_script in a psbt for this descriptor?" 14:52 < andytoshi> if you could break those into separate commits so that they're easy to pick and choose, that'd be awesome 14:52 < afilini> i used to have a method called "is_fixed" but i noticed that you've added "is_derivable" in 5.0+ :) 14:52 < andytoshi> yeah :) 14:53 < andytoshi> this lib is a bit intimidating, we're gonna wind up with 100s of methods on everything and all of us only use a subset of them 14:53 < andytoshi> so i hope we don't wind up with too much inconsistency or redundancy 14:53 < andytoshi> (but i think this is the right way to go) 14:54 < sanket1729> andytoshi: I don't see how all the of method names can be into_miniscirpt() when they return Miniscript objects 14:56 < andytoshi> i mean, they should maybe be as_miniscript() or just miniscript() 14:56 < andytoshi> but i don't understnad your question 14:56 < sanket1729> > but all the miniscript-returning ones i think should just be into_miniscirpt 14:57 < sanket1729> What is your proposed signature? 14:57 < andytoshi> yeah, depending on what they actually do, the into_ prefix should maybe be different 14:57 < andytoshi> fn miniscript(&self) -> Miniscript 14:57 < andytoshi> where Ctx is a specific context 14:57 < andytoshi> depending which descriptor this is being implemented on 14:57 < andytoshi> fn miniscript(&self) -> &Miniscript 14:57 < andytoshi> i meant 14:57 < sanket1729> Well, this is implemented on main Descriptor type 14:58 < andytoshi> ah, i see 14:58 < andytoshi> i don't think we should have a convenience method on the main Descriptor type 14:58 < andytoshi> i think you should have to match and then call the inner method 14:59 < sanket1729> Ah. Now we are on the same page 15:00 < andytoshi> i don't think there's any signature that'd make sense for a method on the main Descriptor type 15:00 < andytoshi> which i think is what you've been hinting at 15:00 < sanket1729> yeah 15:00 < andytoshi> and if you had multiple methods, they'd all have to return a Result 15:01 < andytoshi> but they'd only return Ok on a specific descriptor ... and at that point it'd be more ergonomic to just match on the desrciptor itself 15:01 < sanket1729> yep. and 7 of those methods. 3 for Miniscripts, 3 SortedMultiVec, 1 for pk 15:01 < andytoshi> haha yeah 15:01 < sanket1729> at that point, we might go back and recreate the old enum 15:02 < afilini> as a sidenote, with the new api where do `pk()` descriptors go? are they considered Bare() with the Miniscript inside containing the `pk()` node? 15:02 < andytoshi> yeah i think that's what we did 15:02 < sanket1729> yes, they are Bare 15:02 < andytoshi> it's a bit confusing cuz we couldn't do it with PkH 15:02 < andytoshi> as the miniscript node stores a hsah while the descriptor stores the Pk 15:03 < afilini> that's fine for me, i was just thinking that maybe for consistency you could add a `BareInner` type as well 15:03 < afilini> that could have an Ms and a Pk variant 15:04 < andytoshi> ah .. no, i'd rather have a top-level Pk descriptor than do that 15:04 < andytoshi> but i think i prefer having the existing situation 15:04 < andytoshi> where there is only one kind of Pk 15:05 < afilini> no problem, i was just thinking out loud :) 15:05 < sanket1729> It makes some conceptual sense to have PkH inside bare. But it maybe more confusing 15:05 < afilini> the reasoning was: there's a way purely using `match` to get the raw pk from a pkh(), wpkh(), sh(wpkh()) but not for pk() 15:06 < andytoshi> ahh i see 15:06 < afilini> i mean, i don't really need that for what i'm doing 15:06 < andytoshi> hmm, that is an argument for having a top-level Pk 15:06 < afilini> just saw the inconsistency 15:10 < afilini> actually maybe you can use match on the `node` inside `Miniscript`, basically look for a `Terminal::PkK(_)` 15:11 < afilini> but yeah it's still trated differently than the other pk types 15:11 < andytoshi> yeah 15:11 < andytoshi> fwiw, it is different from the other pk types even in bitcoin .. in that it's the only one with no address format 15:11 < andytoshi> not that that's related :) 15:13 < sanket1729> yeah, but you should'nt really need to do the matching on Astelems inside Miniscript. Miniscript/Descriptor should have all methods so that you would need for your use-case. 15:17 < afilini> ah, one more thing: now that `DescriptorPublicKey` doesn't implement `ToPublicKey` anymore, do you think it makes sense to implement the thing i proposed to mark derived and non-derived keys? 15:17 < andytoshi> like, in the type system? 15:17 < afilini> meaning that we could implement `ToPublicKey` on `DescriptorPublicKey` but not on `DescriptorPublicKey` 15:18 < andytoshi> so, unfortunately we still cannot 15:18 < andytoshi> because of harded derivation steps 15:21 < afilini> not really that, because as you also said in the issue it doesn't really make sense to encode the type of derivation in the actual key type 15:21 < afilini> because you could have different types of derivation in the same descriptor 15:22 < afilini> i'm referring to this comment: https://github.com/rust-bitcoin/rust-miniscript/issues/181#issuecomment-727619331 15:23 < afilini> the problem is that now you can't call `.address()` or `.script_pubkey()` on a descriptor even after you have `.derive()`-d it 15:24 < afilini> because the key type remains the same and the required trait is not implemented on that type 15:25 < afilini> basically i'm just proposing to differentiate the "before derivation" and "after derivation" key type. since it would be guaranteed that there are no wildcards in the "after derivation" type we could implement `ToPublicKey` on it 15:26 < afilini> and with that you would be able to do `descriptor.derive(5).address()` but not `descriptor.address()` directly 15:26 < andytoshi> afilini: you can't call .address() on a derived descriptor because it may not be possible to derive that 15:26 < andytoshi> without secret key data 15:28 < andytoshi> you cannot implement ToPublicKey on a descriptor even if it has no wildcards 15:28 < afilini> oh okay, because hardened wildcards remain un-derived? 15:28 < andytoshi> no, wildcards have nothing to do with it 15:35 -!- elichai2 [sid212594@gateway/web/irccloud.com/x-dcgzhmutntdsthom] has quit [Ping timeout: 246 seconds] 15:37 -!- felixweis_ [sid154231@gateway/web/irccloud.com/x-xnoihktppjcorqez] has joined ##miniscript 15:37 -!- elichai2 [sid212594@gateway/web/irccloud.com/x-djjbiuznzxhrxocp] has joined ##miniscript 15:38 -!- felixweis [sid154231@gateway/web/irccloud.com/x-smefinmvkaltzcwo] has quit [Ping timeout: 260 seconds] 15:38 -!- felixweis_ is now known as felixweis 15:41 < sanket1729> The methods are proving quite ugly than I initially thought. ShInner can possibly return a Miniscript with Legacy or Segwitv0 too. I think I am leaning towards having users match them as_inner() recursively. It's annoying, but I don't see clean way 15:41 < sanket1729> Made the inners as Public Types, but we there are still private inside descriptor struct so that users are forced to call new() methods to construct them in which we do some checks on Miniscripts. 15:42 < andytoshi> oof. yeah, that makes sense 16:05 < sanket1729> afilini, andytoshi : https://github.com/rust-bitcoin/rust-miniscript/pull/232 16:05 < andytoshi> haha the IRC convo is like 10 times the size of the PR 16:05 < sanket1729> the first commit is 2 words diff :P 16:06 < andytoshi> yeah :P 16:11 < andytoshi> ok ack 16:13 < afilini> looks good, thanks! 16:13 < andytoshi> ok publishing 19:21 -!- andytoshi [~apoelstra@unaffiliated/andytoshi] has quit [Remote host closed the connection] 20:40 -!- andytoshi [~apoelstra@unaffiliated/andytoshi] has joined ##miniscript 22:45 -!- geyaeb [~geyaeb@gateway/tor-sasl/geyaeb] has quit [Remote host closed the connection] 22:46 -!- geyaeb [~geyaeb@gateway/tor-sasl/geyaeb] has joined ##miniscript --- Log closed Fri Jan 29 00:00:29 2021