Title: FindAndDelete method in script.h Post by: MatthewLM on June 23, 2012, 05:10:13 PM Hello I'm looking here: https://github.com/bitcoin/bitcoin/blob/master/src/script.h#L482
This is used to remove OP_CODE_SEPARATOR codes and signatures. So from what I can tell the OP_CODE_SERPARATOR codes are just removed if they match the next operator in the loop. For signatures, how do they match? Do the signatures have to match the entire push operation? It seems like it may also match signatures if they come after each other in a push operation like: OP_PUSHDATA1 <num_of_bytes_to_push_for_3_sigs> <sig_bytes> <sig_bytes> <sig_bytes> So it would match if the signature repeats like that? Or would it only match the first one? Also it seems to me that data in front of the signature would cause the signature not to be removed. Any data after the signature is ignored. Is this right? Signature not removed?: OP_PUSHDATA1 <num_of_bytes_to_push> <arbitrary_data> <sig_bytes> Signature removed but not arbitrary data?: OP_PUSHDATA1 <num_of_bytes_to_push> <sig_bytes> <arbitrary_data> Obviously this is important to make OP_CHECKSIG etc. to work. Title: Re: FindAndDelete method in script.h Post by: MatthewLM on June 23, 2012, 08:02:37 PM I have this for the signatures. Is it correct? It searches for push operations and then goes to the beginning of the data to check for a signature. If a signature is found then it is removed:
Code: void CBSubScriptRemoveSignature(u_int8_t * subScript,u_int32_t * subScriptLen,CBScriptStackItem signature){ Title: Re: FindAndDelete method in script.h Post by: genjix on June 26, 2012, 12:10:33 PM I'm not sure what you're asking. Yes it deletes code separators.
Check my code here (I think it is easier to understand): https://gitorious.org/libbitcoin/libbitcoin/blobs/master/src/script.cpp Search for bool script::op_checksigverify(...) You see the look where I create the script_code object? It loops from the last codehash position until the end of all the operations, skipping the signature or any codeseparators. Everything else is pushed to the new script object which is then used for the check_signature function. I would suggest not copying Bitcoin's representation of scripts and instead store the parse tree for scripts. It makes it much easier for the user from an API perspective. Just remember that coinbases are unparsable so you'll need either a special script type or opcode for a raw_script (which is uninterpretable). |