ElementsProject / elements-miniscript

Creative Commons Zero v1.0 Universal
11 stars 14 forks source link

Covenant extension parse example #79

Closed louisinger closed 4 months ago

louisinger commented 4 months ago

given the examples/parse.rs file, I'm trying to decode descriptor using covenant extensions.

let info = miniscript::Descriptor::<bitcoin::PublicKey, extensions::CovenantExt<extensions::CovExtArgs>>::from_str(
      "eltr(02289715c2c4038285fb4fc688a74577eef1c069435ceb58d2c33957f30e2f7fec,and_v(v:pk(02289715c2c4038285fb4fc688a74577eef1c069435ceb58d2c33957f30e2f7fec), value_eq(out_value(0), out_value(1))))"
)

it fails with "Error: unexpected «value_eq(2 args) while parsing Miniscript»" error. Is it possible to add an example with introspections tokens in parse.rs ?

apoelstra commented 4 months ago

Does it work without the spaces?

louisinger commented 4 months ago

Does it work without the spaces?

nop, I've forget to remove them in the OP but before decoding I format the string. Note that the same code works well without covenants tokens.

apoelstra commented 4 months ago

When I run this locally, I get the same error as you, but removing the spaces fixes it.

louisinger commented 4 months ago

indeed... I was using the ValueExpr in the wrong way in my original testing descriptor:

value_eq(out_value(0),0000000000000000))) // explicit value without prefix

it led to the error "unexpected value_eq". my bad. Thanks :pray: I close the issue

apoelstra commented 4 months ago

Awesome, happy to help!