Ejemplo n.º 1
0
        public override bool CanCombineScriptSig(Script scriptPubKey, Script a, Script b)
        {
            var escrow = EscrowScriptBuilder.ExtractEscrowScriptPubKeyParameters(scriptPubKey);

            if (escrow == null)
            {
                return(false);
            }
            var aSigs = EscrowScriptBuilder.ExtractScriptSigParameters(a);
            var bSigs = EscrowScriptBuilder.ExtractScriptSigParameters(b);

            if (aSigs == null || bSigs == null)
            {
                return(true);
            }
            return(aSigs.Length == bSigs.Length);
        }
Ejemplo n.º 2
0
        public override Script CombineScriptSig(Script scriptPubKey, Script a, Script b)
        {
            // Combine all the signatures we've got:
            var aSigs = EscrowScriptBuilder.ExtractScriptSigParameters(a);

            if (aSigs == null)
            {
                return(b);
            }
            var bSigs = EscrowScriptBuilder.ExtractScriptSigParameters(b);

            if (bSigs == null)
            {
                return(a);
            }
            if (aSigs.Length == 1)
            {
                var sig = aSigs[0] ?? bSigs[0];
                return(new Script(Op.GetPushOp(sig.ToBytes())));
            }

            int sigCount = 0;

            TransactionSignature[] sigs = new TransactionSignature[2];
            for (int i = 0; i < 2; i++)
            {
                var aSig = i < aSigs.Length ? aSigs[i] : null;
                var bSig = i < bSigs.Length ? bSigs[i] : null;
                var sig  = aSig ?? bSig;
                if (sig != null)
                {
                    sigs[i] = sig;
                    sigCount++;
                }
                if (sigCount == 2)
                {
                    break;
                }
            }
            if (sigCount == 2)
            {
                sigs = sigs.Where(s => s != null && s != TransactionSignature.Empty).ToArray();
            }
            return(EscrowScriptBuilder.GenerateScriptSig(sigs));
        }