func UpdateWitnessFromProto(uw *pb.UpdateWitness) (*UpdateWitness, error) {
	if uw.LastLevel > 255 {
		return nil, fmt.Errorf("expected LastLevel to be under 255")
	}

	witnesses := make([]chainhash.Hash, len(uw.WitnessHashes))
	for i := range witnesses {
		err := witnesses[i].SetBytes(uw.WitnessHashes[i])
		if err != nil {
			return nil, err
		}
	}

	out := &UpdateWitness{
		Witnesses: witnesses,
		LastLevel: uint8(uw.LastLevel),
	}

	err := out.Key.SetBytes(uw.Key)
	if err != nil {
		return nil, err
	}

	err = out.OldValue.SetBytes(uw.OldValue)
	if err != nil {
		return nil, err
	}

	err = out.NewValue.SetBytes(uw.NewValue)
	if err != nil {
		return nil, err
	}

	err = out.WitnessBitfield.SetBytes(uw.WitnessBitfield)
	if err != nil {
		return nil, err
	}

	return out, nil
}
// UpdateWitnessFromProto converts a protobuf representation of an update witness into an update witness.
UpdateWitnessFromProto converts a protobuf representation of an update witness into an update witness.
// UpdateWitnessFromProto converts a protobuf representation of an update witness into an update witness .
func UpdateWitnessFromProto(uw *pb.UpdateWitness) (*UpdateWitness, error) {
	if uw.LastLevel > 255 {
		return nil, fmt.Errorf("expected LastLevel to be under 255")
	}
	witnesses := make([]chainhash.Hash, len(uw.WitnessHashes))
	for i := range witnesses {
		err := witnesses[i].SetBytes(uw.WitnessHashes[i])
		if err != nil {
			return nil, err
		}
	}
	out := &UpdateWitness{
		Witnesses: witnesses,
		LastLevel: uint8(uw.LastLevel),
	}
	err := out.Key.SetBytes(uw.Key)
	if err != nil {
		return nil, err
	}
	err = out.OldValue.SetBytes(uw.OldValue)
	if err != nil {
		return nil, err
	}
	err = out.NewValue.SetBytes(uw.NewValue)
	if err != nil {
		return nil, err
	}
	err = out.WitnessBitfield.SetBytes(uw.WitnessBitfield)
	if err != nil {
		return nil, err
	}
	return out, nil
}
func UpdateWitnessFromProto ( uw * pb . UpdateWitness ) ( * UpdateWitness , error ) { if uw . LastLevel > 255 { return nil , fmt . Errorf ( " " ) } witnesses := make ( [ ] chainhash . Hash , len ( uw . WitnessHashes ) ) for i := range witnesses { err := witnesses [ i ] . SetBytes ( uw . WitnessHashes [ i ] ) if err != nil { return nil , err } } out := & UpdateWitness { Witnesses : witnesses , LastLevel : uint8 ( uw . LastLevel ) , } err := out . Key . SetBytes ( uw . Key ) if err != nil { return nil , err } err = out . OldValue . SetBytes ( uw . OldValue ) if err != nil { return nil , err } err = out . NewValue . SetBytes ( uw . NewValue ) if err != nil { return nil , err } err = out . WitnessBitfield . SetBytes ( uw . WitnessBitfield ) if err != nil { return nil , err } return out , nil }
UpdateWitnessFromProto converts a protobuf representation of an update witness into an update witness.
UpdateWitnessFromProto converts a protobuf representation of an update witness into an update witness .