示例#1
0
        public void ReadTLV(TLVReader reader, Network network)
        {
            if (reader.ReadU16() != TLVType)
            {
                throw new FormatException("Invalid TLV type for sign");
            }
            ContractId = reader.ReadUInt256();
            CetSigs    = CetSigs.ParseFromTLV(reader);

            using (var r = reader.StartReadRecord())
            {
                if (r.Type != FundingSignaturesTLVType)
                {
                    throw new FormatException("Invalid TLV type for funding signatures");
                }
                FundingSigs = new List <WitScript>();
                var witnesses = r.ReadU16();
                for (int i = 0; i < witnesses; i++)
                {
                    var elementsCount = reader.ReadU16();
                    var witnessBytes  = new byte[elementsCount][];
                    for (int y = 0; y < elementsCount; y++)
                    {
                        var elementSize = reader.ReadU16();
                        witnessBytes[y] = new byte[elementSize];
                        r.ReadBytes(witnessBytes[y]);
                    }
                    FundingSigs.Add(new WitScript(witnessBytes));
                }
            }
        }
示例#2
0
        public void ReadTLV(TLVReader reader, Network network)
        {
            if (reader.ReadU16() != TLVType)
            {
                throw new FormatException("Invalid TLV type for accept");
            }
            TemporaryContractId = reader.ReadUInt256();
            TotalCollateral     = Money.Satoshis(reader.ReadU64());
            PubKeys             = new PubKeyObject();
            var pk = new byte[33];

            reader.ReadBytes(pk);
            PubKeys.FundingKey    = new PubKey(pk, true);
            PubKeys.PayoutAddress = reader.ReadScript().GetDestinationAddress(network);
            var inputLen = reader.ReadU16();

            FundingInputs = new FundingInput[inputLen];
            for (int i = 0; i < inputLen; i++)
            {
                FundingInputs[i] = FundingInput.ParseFromTLV(reader, network);
            }
            ChangeAddress = reader.ReadScript().GetDestinationAddress(network);
            CetSigs       = CetSigs.ParseFromTLV(reader);
        }