--- Log opened Thu Mar 24 00:00:35 2022 00:22 -!- shesek_ [~shesek@user/shesek] has quit [Remote host closed the connection] 00:22 -!- shesek_ [~shesek@user/shesek] has joined ##miniscript 01:20 -!- shesek_ [~shesek@user/shesek] has quit [Remote host closed the connection] 01:20 -!- shesek_ [~shesek@user/shesek] has joined ##miniscript 01:36 -!- shesek_ [~shesek@user/shesek] has quit [Remote host closed the connection] 01:36 -!- shesek_ [~shesek@user/shesek] has joined ##miniscript 01:59 -!- shesek_ [~shesek@user/shesek] has quit [Remote host closed the connection] 01:59 -!- shesek_ [~shesek@user/shesek] has joined ##miniscript 02:11 -!- shesek_ [~shesek@user/shesek] has quit [Remote host closed the connection] 02:11 -!- shesek_ [~shesek@user/shesek] has joined ##miniscript 02:20 -!- shesek_ [~shesek@user/shesek] has quit [Remote host closed the connection] 02:20 -!- shesek_ [~shesek@user/shesek] has joined ##miniscript 02:35 -!- shesek_ [~shesek@user/shesek] has quit [Remote host closed the connection] 02:35 -!- shesek_ [~shesek@user/shesek] has joined ##miniscript 02:46 -!- shesek_ [~shesek@user/shesek] has quit [Remote host closed the connection] 02:46 -!- shesek_ [~shesek@user/shesek] has joined ##miniscript 03:06 -!- shesek_ [~shesek@user/shesek] has quit [Remote host closed the connection] 03:06 -!- shesek_ [~shesek@user/shesek] has joined ##miniscript 03:30 < afilini1> is it a bug though? i thought spaces were not allowed by design 03:43 -!- shesek_ [~shesek@user/shesek] has quit [Remote host closed the connection] 03:43 -!- shesek_ [~shesek@user/shesek] has joined ##miniscript 04:15 -!- shesek_ [~shesek@user/shesek] has quit [Remote host closed the connection] 04:15 -!- shesek_ [~shesek@user/shesek] has joined ##miniscript 04:18 -!- afilini1 [~afiliniaf@2001:bc8:1828:245::2] has quit [Quit: Reconnecting] 04:18 -!- afilini1 [~afiliniaf@2001:bc8:1828:245::2] has joined ##miniscript 04:19 -!- afilini1 [~afiliniaf@2001:bc8:1828:245::2] has quit [Client Quit] 04:19 -!- afilini1 [~afiliniaf@2001:bc8:1828:245::2] has joined ##miniscript 04:20 -!- afilini1 [~afiliniaf@2001:bc8:1828:245::2] has quit [Client Quit] 04:20 -!- afilini1 [~afilini@2001:bc8:1828:245::2] has joined ##miniscript 04:22 -!- enick_544 [~afilini-m@2001:bc8:1828:245::2] has quit [Quit: Bridge terminating on SIGTERM] 04:22 -!- afilini1 [~afilini@2001:bc8:1828:245::2] has quit [Client Quit] 04:22 -!- enick_87 [~afilini-m@2001:bc8:1828:245::2] has joined ##miniscript 04:29 < darosior> Yeah maybe a better error message but i too always assumed spaces were disallowed. 04:48 -!- shesek_ [~shesek@user/shesek] has quit [Remote host closed the connection] 04:48 -!- shesek_ [~shesek@user/shesek] has joined ##miniscript 05:01 -!- shesek_ [~shesek@user/shesek] has quit [Remote host closed the connection] 05:01 -!- shesek_ [~shesek@user/shesek] has joined ##miniscript 05:12 -!- shesek_ [~shesek@user/shesek] has quit [Remote host closed the connection] 05:12 -!- shesek_ [~shesek@user/shesek] has joined ##miniscript 05:26 -!- shesek_ [~shesek@user/shesek] has quit [Remote host closed the connection] 05:26 -!- shesek_ [~shesek@user/shesek] has joined ##miniscript 05:38 -!- shesek_ [~shesek@user/shesek] has quit [Remote host closed the connection] 05:38 -!- shesek_ [~shesek@user/shesek] has joined ##miniscript 05:59 -!- shesek_ [~shesek@user/shesek] has quit [Remote host closed the connection] 05:59 -!- shesek_ [~shesek@user/shesek] has joined ##miniscript 06:15 -!- shesek_ [~shesek@user/shesek] has quit [Remote host closed the connection] 06:15 -!- shesek_ [~shesek@user/shesek] has joined ##miniscript 06:38 -!- shesek_ [~shesek@user/shesek] has quit [Remote host closed the connection] 06:38 -!- shesek_ [~shesek@user/shesek] has joined ##miniscript 07:21 -!- shesek_ [~shesek@user/shesek] has quit [Remote host closed the connection] 07:21 -!- shesek_ [~shesek@user/shesek] has joined ##miniscript 07:51 -!- shesek_ [~shesek@user/shesek] has quit [Remote host closed the connection] 07:51 -!- shesek_ [~shesek@user/shesek] has joined ##miniscript 08:06 -!- shesek_ [~shesek@user/shesek] has quit [Remote host closed the connection] 08:07 -!- shesek_ [~shesek@user/shesek] has joined ##miniscript 08:15 -!- shesek_ [~shesek@user/shesek] has quit [Remote host closed the connection] 08:16 -!- shesek_ [~shesek@user/shesek] has joined ##miniscript 08:32 -!- shesek_ [~shesek@user/shesek] has quit [Remote host closed the connection] 08:32 -!- shesek_ [~shesek@user/shesek] has joined ##miniscript 08:42 -!- shesek_ [~shesek@user/shesek] has quit [Remote host closed the connection] 08:42 -!- shesek_ [~shesek@user/shesek] has joined ##miniscript 08:57 -!- shesek_ [~shesek@user/shesek] has quit [Remote host closed the connection] 08:57 -!- shesek_ [~shesek@user/shesek] has joined ##miniscript 09:51 -!- shesek_ [~shesek@user/shesek] has quit [Remote host closed the connection] 09:52 -!- shesek_ [~shesek@user/shesek] has joined ##miniscript 10:16 -!- shesek_ [~shesek@user/shesek] has quit [Remote host closed the connection] 10:16 -!- shesek_ [~shesek@user/shesek] has joined ##miniscript 10:35 -!- shesek_ [~shesek@user/shesek] has quit [Remote host closed the connection] 10:36 -!- shesek_ [~shesek@user/shesek] has joined ##miniscript 10:36 < jeremyrubin> then the bug is in C++? 10:36 < jeremyrubin> https://bitcoin.sipa.be/miniscript/ permits spaces 10:37 < jeremyrubin> Or maybe it's just convenience for the JS? 10:38 <@sipa> It's not like we have a spec of the policy language anywhere. 10:38 < jeremyrubin> miniscript input with spaces also accepted 10:38 < jeremyrubin> e.g. analyze and_v(or_c(pk(B),or_c(pk(C), v:older(1000))),pk(A)) 10:53 -!- shesek_ [~shesek@user/shesek] has quit [Remote host closed the connection] 10:53 -!- shesek_ [~shesek@user/shesek] has joined ##miniscript 10:58 <@sipa> ah, yes, the javascript and command-line tool do some syntactic sugar tricks 10:58 <@sipa> so you can write hashes as H etc 10:58 <@sipa> it also removes spaces 11:00 < jeremyrubin> gotcha yeah 11:00 < jeremyrubin> that was my next question but for rust alone -- should we parametrive the Hash type to permit abstract hashes? 11:01 < jeremyrubin> Because if i want to generate a miniscript frag something like and(sha256(X), pk(A)) right now the X always must be concrete 11:01 < jeremyrubin> but we might want to keep it generic (e.g. X ==> submarine_swap_timeout_image) 11:01 < jeremyrubin> and then be able to translate the hashes in later. 11:03 < sanket1729> jeremyrubin: rust-miniscript does not support generic parameter for hash value yet 11:04 < sanket1729> I would not be opposed to supporting it, but it will be lot of code.. 11:04 < sanket1729> And adds yet another generic 11:14 < jeremyrubin> i think it's a neccessary v.s. nice to have sadly 11:14 < jeremyrubin> since in theory if we want to represent e.g. HTLCs theres no other way 11:14 < jeremyrubin> (other than manually implementing the translation a layer up?) 11:15 < jeremyrubin> (i don't need this for sapio or anything, just making a little notebook thing for the pleb.fi tutorial and realized i can't shorthand hashes with rust-ms natively) 11:15 < jeremyrubin> wrt needing Yet-Another-Generic... 11:16 < jeremyrubin> one option would be to use the *same* trait-y thing and have two diff associated types for hashes and keys? 11:16 < jeremyrubin> so you only need one tag? 11:17 -!- shesek_ [~shesek@user/shesek] has quit [Remote host closed the connection] 11:17 -!- shesek_ [~shesek@user/shesek] has joined ##miniscript 11:25 < sanket1729> jeremyrubin: Concept ACK associated types from me. I would like to wait to see what andytoshi thinks 11:26 < sanket1729> we can also add for timelocks 11:27 < sanket1729> Dependent on how ugly the translate APIs gets. 11:29 -!- shesek_ [~shesek@user/shesek] has quit [Remote host closed the connection] 11:30 -!- shesek_ [~shesek@user/shesek] has joined ##miniscript 12:13 < jeremyrubin> sanket1729: yeah, i dont want to make it too messy but that makes sense 12:13 < jeremyrubin> timelocks less pressing since i think protocols largely hardcode those 12:14 < jeremyrubin> but it makes sense that we'd want to have a complete separation from data and structure 12:14 * jeremyrubin in before 'code is data' 12:14 < sanket1729> I face the same issue when trying to write tests with hashes 12:16 < jeremyrubin> btw weird Idea 12:16 < jeremyrubin> allow having a miniscript> 12:16 < jeremyrubin> and then just make all internal types under Old "string" 12:16 < jeremyrubin> and then you can just do 12:16 < jeremyrubin> ms.visit(translate_pks) 12:16 < jeremyrubin> ms.visit(translate_timelocks) 12:17 < jeremyrubin> ms.visit(translate_hashes) 12:17 < jeremyrubin> and you get back either: 12:17 < jeremyrubin> Result, Miniscript>> 12:17 < jeremyrubin> or something like that 12:17 < sanket1729> Seems to work conceptually. But really non-conventional 12:17 < jeremyrubin> i don't think it's that weird 12:18 < jeremyrubin> the weird thing is rust calling Either Result and making Err morally bad 12:18 < jeremyrubin> ;) 12:18 < jeremyrubin> but this would essentially just let you apply visitors over all nodes repeatedly until you finish a conversion 12:19 < jeremyrubin> kinda like a middleware stack for lifting Miniscript => Miniscript 12:20 < sanket1729> Yep, I get it. I would like to think more about this before I form an opinion 12:22 < jeremyrubin> i think it really is just a visitor pattern 12:23 < jeremyrubin> we could do trait Visitor and define a translator fn for visiting each node type 12:23 < jeremyrubin> and the provided impl is just map a onto stays the same 12:24 < jeremyrubin> but yeah it might get verbose 12:29 < sanket1729> We can keep the Miniscript as is, but update the TranslatePk trait to not have function args, but a trait object. In that trait objects, we can methods Key(P) -> Key(Q). That will make it cleaner 12:29 < sanket1729> KeyP::Time -> KeyQ::Time and so on 12:30 < sanket1729> This fixes that Pk = String, all other types must be fixed. But I don't think it's a drawback 12:31 < jeremyrubin> i think that should work 12:31 < jeremyrubin> also for timelocks, we can do something dumb as an immediate workaround 12:32 < jeremyrubin> translate(u16) -> u16 12:32 < jeremyrubin> so then you can just do timelocks = {1: 10 days, 2: 1 block} 12:32 < jeremyrubin> ditto for hashes 12:37 < sanket1729> Yep, this should work and make the code look better. Even tough it is some the exact same thing. `ToPublicKey` trait would also need updates with methods corresponding conversions. 12:38 < sanket1729> I really like it. I think andytoshi on vacation today, let's wait to see what he thinks 12:39 < jeremyrubin> well yeah i guess we could also, since the enums are all pub, make this visitor thing in a separate module too 12:39 < jeremyrubin> so we really don't *need* rust-miniscript to provide this type of feature 12:40 < jeremyrubin> but... having it ergonomic for users / documented how to do it seems good to me 12:40 < jeremyrubin> and maybe theres some subtle things we can do that make it so that you don't accidentally forget to translate a miniscript with templated hashes/locktimes, which would be bad 12:40 < jeremyrubin> (and that can't happen with String, kinda, which is a benefit) 12:49 -!- shesek_ [~shesek@user/shesek] has quit [Remote host closed the connection] 12:49 -!- shesek_ [~shesek@user/shesek] has joined ##miniscript 13:22 -!- shesek_ [~shesek@user/shesek] has quit [Remote host closed the connection] 13:23 -!- shesek_ [~shesek@user/shesek] has joined ##miniscript 13:36 < sanket1729> The typesystem should prevent from calling APIs without completely translated miniscripts. IMO not dealing with intermediate translations will save lots of time 13:40 -!- shesek_ [~shesek@user/shesek] has quit [Remote host closed the connection] 13:40 < jeremyrubin> sanket1729: i forget, is there a reason why we can't turna a TaprootSPendInfo into a Tr descriptor? 13:40 -!- shesek_ [~shesek@user/shesek] has joined ##miniscript 13:40 <@sipa> Bitcoin Core has code for that, IIRC. 13:40 < sanket1729> Tr descriptor should operate on a generic Pk 13:41 < jeremyrubin> Ah so the TSI has a Script type, which can't be lifted? 13:41 < sanket1729> But it has all the information to covert to Tr 13:41 < jeremyrubin> Seems kinda unergonomic because i want to do TSI::with_huffman_tree(...) -> Tr 13:42 < jeremyrubin> i think we covered the use case of building a Tr and getting a TSI out, but not the reverse 13:43 < sanket1729> I would mind an APi that adds this 13:43 < sanket1729> Constuct Tr from spendinfo 13:43 < jeremyrubin> oh? 13:43 < jeremyrubin> what's wrong with it? 13:43 < sanket1729> Sorry 13:43 < sanket1729> I meant 13:43 < sanket1729> would not mind 13:43 < jeremyrubin> ah lol 13:43 < sanket1729> duh 13:43 < jeremyrubin> i was like, that's a polite way of saying no... 13:43 < sanket1729> lol 13:44 < sanket1729> sorry about that. Note that this would only work for Scripts that miniscripts, does not support hidden nodes yet 13:44 < jeremyrubin> i think you'll be pretty pleased when you see the sapio miniscript playground, it lets you write line-by-line policies, shows you the compilation / any errors of each, and then builds a TaprootSpendInfo and shows you that 13:45 < sanket1729> That can be represented in TaprootSpendInfo 13:45 < jeremyrubin> https://twitter.com/JeremyRubin/status/1507096367226765313 13:46 -!- shesek_ [~shesek@user/shesek] has quit [Remote host closed the connection] 13:46 < jeremyrubin> it does make me think that having TSI able to keep templated keys might be useful too 13:47 -!- shesek_ [~shesek@user/shesek] has joined ##miniscript 13:47 < jeremyrubin> where you *know* the huffman encoding 13:47 < jeremyrubin> but might still pass in particular keys later 13:47 < jeremyrubin> e.g., a Miniscript local TSI that holds MS and not Script 13:47 < sanket1729> Are you using a custom taproot descriptor compiler? 13:48 < jeremyrubin> yes sort of 13:49 < jeremyrubin> i'm just bundling this as an applet into sapio studio so that if you're writing a contract and want to playtest that you have valid policy fragments, you can. 13:49 < jeremyrubin> the core logic is to interpret every line as an indpendent policy 13:49 < jeremyrubin> and then tree them up using with_huffman 13:49 < jeremyrubin> nothing too fancy 13:50 < jeremyrubin> (also the keytab thing does translations) 13:51 < sanket1729> Ah, it's a nice incremental demo 13:57 < jeremyrubin> yeah, things are fast enough that as you type it recompiles 13:58 < jeremyrubin> which is really fun 13:58 < jeremyrubin> (and you can't even notice any input/output lag) 14:06 < jeremyrubin> btw i think TaprootSpendInfo is missing serde derives 14:08 < jeremyrubin> probably because the Arc makes it hard 14:08 < jeremyrubin> err oops that's in somewhere else 14:32 -!- shesek_ [~shesek@user/shesek] has quit [Remote host closed the connection] 14:33 -!- shesek_ [~shesek@user/shesek] has joined ##miniscript 15:14 -!- shesek_ [~shesek@user/shesek] has quit [Remote host closed the connection] 15:14 -!- shesek_ [~shesek@user/shesek] has joined ##miniscript 15:18 < shesek_> is TaprootSpendInfo::from_node_info() intentionally not public? for my use case I already have a constructed NodeInfo and don't need to use TaprootBuilder 15:19 < shesek_> oh actually I don't have a constructed NodeInfo, that's private too. I was just implementing this and thought I did 15:20 < shesek_> is the intention that library users always go through either TaprootBuilder or with_huffman_tree()? 15:20 < jeremyrubin> shesek_: yeah i've also been struggling with similar issues 15:21 < jeremyrubin> shuttling the data around between rust-miniscript and rust-bitcoin is kinda rough rn 15:21 < jeremyrubin> see 909, because then you can use the taprootbuilder::with_huffman to get both a TapTree for PSBT and use it to get a matching taprootspendinfo 15:22 < jeremyrubin> that might cover what you're looking for? 15:22 < jeremyrubin> unless you need some super custom tree 15:26 < shesek_> its not for a particular tree that I need, its to enable users to specify custom tree in minsc. like in the second example here: https://min.sc/next/#gist=8bc2f3fa07031260ab32bb01c25fed06 15:27 < shesek_> I'm in the processing of changing tapTweak() (and the + operator which does the same) to retain and return the TaprootSpendInfo with all the associated information, instead of just the final tweaked key 15:28 < jeremyrubin> ah, why not ask users to just give you a weighted ranking of likelihood 15:28 < jeremyrubin> i guess people sometimes know best? 15:29 < shesek_> that's possible too, $internal_pk + [2@`1 OP_ADD 2 OP_EQUAL`, 3@(pk($other_pk) && older(1 day)), 5@0x0a1b2c3d] 15:29 < shesek_> but I thought it makes sense to support both, in case someone has some particular tree that he'd like to use as-is 15:29 < jeremyrubin> but yeah, i have no idea how to take a TaprootBuilder or TaprootSpendInfo and convert it to a Miniscript::TapTree which is required to make a descriptor 15:30 < jeremyrubin> which is sort of the same issue you're solving for 15:31 < jeremyrubin> the crappy soln, which i do in Sapio, is to just re-create the trees independently outside the library 15:31 < shesek_> there's an open PR for an iterator over the (depth, script) that might help 15:31 < jeremyrubin> not really 15:32 < jeremyrubin> we use 3 different representations 15:32 < jeremyrubin> and going betwixt them gives me a headache 15:32 -!- shesek_ is now known as shesek 15:32 < jeremyrubin> repr 1: huffman with probs^-1, repr 2: ordered depth map, repr 3: AST tree 15:32 < jeremyrubin> AST tree and huffman are the only ones i know what to do with 15:33 < jeremyrubin> this ordered depth map thing i've never really gotten 15:33 < jeremyrubin> https://github.com/sapio-lang/sapio/blob/222aa2016f8da2e45f562cd497b61bf88a2f6045/sapio/src/contract/compiler/mod.rs#L379 15:33 < jeremyrubin> you can see here i just, at the miniscript level, make my own huffman to get a Taptree out 15:33 < jeremyrubin> and then i can get a descriptor from that 15:35 < jeremyrubin> and then you can get a builder from that https://github.com/sapio-lang/sapio/blob/072b8835dcf4ba6f8f00f3a5d9034ef8e021e0a7/sapio/src/contract/abi/object.rs#L283 15:38 < jeremyrubin> not sure if that's helpful for you, but i'd try constructing the descriptor tree directly, then using that to iter_scripts, and then using the iter_scripts to make a builder, and then the builder to make a SpendInfo 15:38 < jeremyrubin> the annoying part is that in making the descriptor tree u have to roll your own huffman, but it's like 5 lines of rust sooo 15:39 < jeremyrubin> but going between the 3 reprs makes my head spin 15:41 < jeremyrubin> afk! 15:42 < shesek> for now I'm still not doing taproot descriptors, only rust-bitcoin's plain taproot trees (with policies compiled into Script) 15:42 < shesek> but I'm gonna be tackling that next and it will be useful then, thanks :) 16:13 < jeremyrubin> you can still use the descriptors! 16:13 < jeremyrubin> just reverse your fragments from Script to Miniscript 16:13 < jeremyrubin> and then plug it into a descriptor 16:15 -!- shesek [~shesek@user/shesek] has quit [Remote host closed the connection] 16:16 -!- shesek [~shesek@user/shesek] has joined ##miniscript 16:22 < shesek> oh interesting. unifying the two cases would be great, implementing each separately could be a pita. that wouldn't work with the new elements opcodes though :< 19:35 -!- shesek [~shesek@user/shesek] has quit [Remote host closed the connection] 19:36 -!- shesek [~shesek@user/shesek] has joined ##miniscript 19:51 -!- shesek_ [~shesek@user/shesek] has joined ##miniscript 19:54 -!- shesek [~shesek@user/shesek] has quit [Ping timeout: 256 seconds] 20:12 -!- shesek_ [~shesek@user/shesek] has quit [Remote host closed the connection] 20:12 -!- shesek_ [~shesek@user/shesek] has joined ##miniscript 20:43 -!- shesek_ [~shesek@user/shesek] has quit [Remote host closed the connection] 20:43 -!- shesek_ [~shesek@user/shesek] has joined ##miniscript 21:16 -!- shesek_ [~shesek@user/shesek] has quit [Remote host closed the connection] 21:16 -!- shesek_ [~shesek@user/shesek] has joined ##miniscript 21:54 -!- shesek_ [~shesek@user/shesek] has quit [Remote host closed the connection] 21:54 -!- shesek_ [~shesek@user/shesek] has joined ##miniscript 22:56 -!- shesek_ [~shesek@user/shesek] has quit [Remote host closed the connection] 22:57 -!- shesek_ [~shesek@user/shesek] has joined ##miniscript 23:59 -!- shesek_ [~shesek@user/shesek] has quit [Remote host closed the connection] 23:59 -!- shesek_ [~shesek@user/shesek] has joined ##miniscript --- Log closed Fri Mar 25 00:00:37 2022