Open pputnik opened 7 months ago
p.s. it was ver 0.6.12.
Ver 0.6.14 throws unexpected keyword argument 'strict'
but it was needed by https://github.com/1200wd/bitcoinlib/issues/338
Without that "strict" the same error as above.
confirmed this is an inelegant way to fail for a nonstandard output. @pputnik this is caused because the output 195 in that tx appears to be custom and doesn't have an address in the traditional sense.
@mccwdev happy to create a pr to handle this properly. I suggest supporting script_type=nonstandard. This has the side effect of allowing malformed strings p2tr, etc strings pass through without raising errors, instead being misidentified as type unknown or nonstandard.
happy for an alternative approach.
@arshbot could you please explain why it "doesn't have an address in the traditional sense"? I see the block reward is passed to 196 addresses. Does the error appear because the block reward passed not to one but to many?
Thank you.
@pputnik when you "send" bitcoin, you're really just putting a new lock (scriptpubkey) on a subset of coins you own. We use the same kind of locks all the time, most of the time use a pubkey in some form/fashion/placement. These patterns of locking and pubkey storage often map to an address type (p2pkh, p2sh, p2tr, etc).
But not always. Addresses are probably poorly named for what they actually are (but great name for ux). They're basically part template to describe where to find corresponding signature when spent, and part fingerprint to correlate to a sensitive signing material. Sometimes you aren't using a typical way of storing the pubkey. Sometimes you aren't using a typical way to correlate signing material.
I see the block reward is passed to 196 addresses. Does the error appear because the block reward passed not to one but to many?
not at all, that's irrelevant. It's because the output script
OP_PUSHBYTES_36 7aa02f855906258a82089dc02b13d600ce8636d2d34ec5804556859a98c7dbef02000100
is not a specific pattern. I mean look at this, it's not even a lock. I don't know what this bit of data is, but i think anyone could spend this utxo. This is further confirmed by the input script in the corresponding spending tx
OP_PUSHBYTES_1 01
because there's no real lock in the output script, all the input script has to do is toss a 1 (aka true
) so the script evaluates as success and the utxo is spendable. honestly totally goofy, i don't know why someone did this. the value of the utxo (and of most of the inputs in the spening tx) is also a flat 0, which you don't really see often.
Thank you for the explanation.
Whilst the library author is away - could you please share your fix, either in the form of PR or not?
Thank you very much.
could you please share your fix, either in the form of PR or not?
PR is probably best, but I won't go to the effort unless the maintainer ACKs the approach.
The problem is two-fold:
Script.parse_bytes
that needs to be ironed out.Output
object needs to support unknown
or nonstandard
script types. This has a lot of implications, mostly in terms of "don't try to generate things erroneously" @arshbot, thanks for you clear explanation and analysing the problem.
I noticed, if you disable caching the transaction is correctly parsed (the incorrect output is ignored). But trying to access the address results in an exception.
The problem is indeed that the Output, Key and Address objects do not support unknown scripts and should probably ignore them if a strict=False option is set. If you have some ideas and would like to fix these issues with a PR, you are more then welcome.
The reason for the strict option, which defaults to True, is to avoid creation of incorrect transactions or output scripts that can result in loss of funds.
@arshbot, please ^_^
Way to reproduce:
The error:
The only reason I can think about - it's a block reward but unlike what I've seen before, there are many recipients (not one).
Could you help, please?