Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Partially signed transactions should use OP_0 as placeholder #74

Closed
ysobolev opened this issue Jan 24, 2015 · 7 comments
Closed

Partially signed transactions should use OP_0 as placeholder #74

ysobolev opened this issue Jan 24, 2015 · 7 comments

Comments

@ysobolev
Copy link

I believe many multisig wallets (CoinVaut, BitGo) use the convention that OP_0 is used as a placeholder for missing signatures. I am not sure if it is a standard, but it does appear to be used in many places. Can ScriptMultisig._dummy_signature please be changed to return "\x00" instead? Thanks.

@richardkiss
Copy link
Owner

I agree that there should be a standard placeholder, but my gut feeling has been to put a 0000...0 signature the same length of a standard signature. This way, a partially signed transaction is exactly the same length as the final transaction, which makes it a bit easier to calculate the required transaction fees. I think this is better than OP_0 even though it doesn't match the defacto "standard" that others have adopted. What do you think?

@ysobolev
Copy link
Author

Well, you have an excellent point about fees. By the way, right now, the signature is not all zeros. Anyway, if you want to try to champion another standard, I support that. I agree, OP_0 is not exactly the best placeholder. However, if the majority of users settle on OP_0, that is what you should go with.

@sserrano44
Copy link
Contributor

I had this same issue trying the cryptocorp api and had to monkey patch pycoin to make it work

@richardkiss
Copy link
Owner

Sebastian, can I take a look at your patch?

@ysobolev
Copy link
Author

ysobolev commented Feb 2, 2015

If using 0.53 from GitHub, then the following code works well:
ScriptMultisig._dummy_signature = lambda x, y: "\x00"
If using 0.52, there appears to be a bug and ScriptMultisig.solve needs a rewrite.

@sserrano44
Copy link
Contributor

We endup fixing the input and redeem script

from pycoin.ecdsa import generator_secp256k1
from pycoin.serialize import b2h, stream_to_bytes
from pycoin.key.BIP32Node import BIP32Node
from pycoin.tx.pay_to import ScriptMultisig
from pycoin.tx.script.tools import *
from pycoin.tx.script import der

def dummy_signature(sig_type):
    order = generator_secp256k1.order()
    r, s = order - 1, order // 2
    return der.sigencode_der(r, s) + bytes_from_int(sig_type)

def fix_input_script(inp, redeem_script):
    """replace dummy signatures with OP_0 and add redeem script for digitaloracle compatibility"""
    dummy = b2h(dummy_signature(1))
    ops1 = []
    for op in opcode_list(inp.script):
        if op == dummy:
            op = 'OP_0'
        ops1.append(op)
    # FIXME hack to add redeem script omitted by pycoin
    ops1.append(b2h(redeem_script))
    inp.script = compile(' '.join(ops1))

@richardkiss
Copy link
Owner

As of d09b5e0, you should be able to pass in
signature_placeholder=OP_0 as a kwarg to Tx.sign to use OP_0 as your placeholder.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants