Example #1
0
 public static bool TryParse(string str, out PartialSignature?sig)
 {
     if (str == null)
     {
         throw new ArgumentNullException(nameof(str));
     }
     sig = null;
     try
     {
         var bytes = Encoders.Hex.DecodeData(str);
         if (bytes.Length < 2 + 33 + 1 || bytes[0] != 0x22 || bytes[1] != 0x02)
         {
             return(false);
         }
         var pk     = new NBitcoin.PubKey(bytes.AsSpan().Slice(2, 33).ToArray());
         var siglen = bytes[2 + 33];
         if (siglen < 75 && bytes.Length != 2 + 33 + 1 + siglen)
         {
             return(false);
         }
         var sigBytes = bytes.AsSpan().Slice(2 + 33 + 1).ToArray();
         if (!TransactionSignature.IsValid(sigBytes))
         {
             return(false);
         }
         var s = new TransactionSignature(sigBytes);
         sig = new PartialSignature(pk, s);
         return(true);
     }
     catch
     {
         return(false);
     }
 }
        private CetSigs CreateCetSigs()
        {
            if (FundingKey is null || OffererRewards is null)
            {
                throw new InvalidOperationException("Invalid state for creating CetSigs");
            }
            var refund    = BuildRefund();
            var signature = refund.SignInput(FundingKey, GetFundCoin());
            var cetSig    = new CetSigs()
            {
                OutcomeSigs = OffererRewards
                              .Select(o => (o.Key, SignCET(FundingKey, o.Key)))
                              .ToDictionary(kv => kv.Key, kv => kv.Item2),
                RefundSig = new PartialSignature(FundingKey.PubKey, signature)
            };

            return(cetSig);
        }