コード例 #1
0
        public TransactionSignature ExtractSignature(MicroChannelParticipant participant, Transaction payment)
        {
            var args = PayToScriptHashTemplate.Instance.ExtractScriptSigParameters(payment.Inputs[0].ScriptSig);

            if (args == null || args.RedeemScript != Redeem)
            {
                throw new MicroPaymentException("Payment uncorrectly signed");
            }
            var multiArgs = PayToMultiSigTemplate.Instance.ExtractScriptPubKeyParameters(Redeem);

            if (multiArgs == null || !multiArgs.PubKeys.Contains(participant.PaymentPubKey))
            {
                throw new MicroPaymentException("Payment uncorrectly signed");
            }
            var i   = Array.IndexOf(multiArgs.PubKeys, participant.PaymentPubKey);
            var sig = args.Signatures[i];

            if (sig == null)
            {
                throw new MicroPaymentException("Payment uncorrectly signed");
            }
            if (args.Signatures.Count(s => s != null) != 1)
            {
                throw new MicroPaymentException("Payment uncorrectly signed");
            }
            return(sig);
        }
コード例 #2
0
		public TransactionSignature ExtractSignature(MicroChannelParticipant participant, Transaction payment)
		{
			var args = PayToScriptHashTemplate.Instance.ExtractScriptSigParameters(payment.Inputs[0].ScriptSig);
			if(args == null || args.RedeemScript != Redeem)
				throw new MicroPaymentException("Payment uncorrectly signed");
			var multiArgs = PayToMultiSigTemplate.Instance.ExtractScriptPubKeyParameters(Redeem);
			if(multiArgs == null || !multiArgs.PubKeys.Contains(participant.PaymentPubKey))
				throw new MicroPaymentException("Payment uncorrectly signed");
			var i = Array.IndexOf(multiArgs.PubKeys, participant.PaymentPubKey);
			var sig = args.Signatures[i];
			if(sig == null)
				throw new MicroPaymentException("Payment uncorrectly signed");
			if(args.Signatures.Count(s => s != null) != 1)
				throw new MicroPaymentException("Payment uncorrectly signed");
			return sig;
		}